diff --git a/client/coral-admin/src/actions/settings.js b/client/coral-admin/src/actions/settings.js index 32f56e111..d6eb183ad 100644 --- a/client/coral-admin/src/actions/settings.js +++ b/client/coral-admin/src/actions/settings.js @@ -39,7 +39,7 @@ export const updateDomainlist = (listName, list) => { }; export const saveSettingsToServer = () => (dispatch, getState) => { - let settings = getState().settings.toJS().settings; + let settings = getState().settings.toJS(); if (settings.charCount) { settings.charCount = parseInt(settings.charCount); } diff --git a/client/coral-admin/src/containers/Configure/CommentSettings.js b/client/coral-admin/src/containers/Configure/CommentSettings.js index 1051bb0ba..5a14cf565 100644 --- a/client/coral-admin/src/containers/Configure/CommentSettings.js +++ b/client/coral-admin/src/containers/Configure/CommentSettings.js @@ -51,6 +51,12 @@ const updateClosedMessage = (updateSettings) => (event) => { updateSettings({closedMessage}); }; +const updateCustomCssUrl = (updateSettings) => (event) => { + console.log('updateCustomCssUrl', event.target.value); + const customCssUrl = event.target.value; + updateSettings({customCssUrl}); +}; + // If we are changing the measure we need to recalculate using the old amount // Same thing if we are just changing the amount const updateClosedTimeout = (updateSettings, ts, isMeasure) => (event) => { @@ -165,7 +171,7 @@ const CommentSettings = ({fetchingSettings, title, updateSettings, settingsError - +
{lang.t('configure.close-after')}
@@ -188,6 +194,18 @@ const CommentSettings = ({fetchingSettings, title, updateSettings, settingsError
+ +
+ {lang.t('configure.custom-css-url')} +

{lang.t('configure.custom-css-url-desc')}

+
+ +
+
); }; diff --git a/client/coral-admin/src/containers/Configure/Configure.js b/client/coral-admin/src/containers/Configure/Configure.js index c9c88eeee..1ec78dcd2 100644 --- a/client/coral-admin/src/containers/Configure/Configure.js +++ b/client/coral-admin/src/containers/Configure/Configure.js @@ -165,7 +165,9 @@ class Configure extends Component { } } -const mapStateToProps = state => state.settings.toJS(); +const mapStateToProps = state => ({ + settings: state.settings.toJS() +}); export default connect(mapStateToProps)(Configure); const lang = new I18n(translations); diff --git a/client/coral-admin/src/reducers/settings.js b/client/coral-admin/src/reducers/settings.js index 70c52f028..a02cac198 100644 --- a/client/coral-admin/src/reducers/settings.js +++ b/client/coral-admin/src/reducers/settings.js @@ -2,14 +2,12 @@ import {Map, List} from 'immutable'; import * as actions from '../actions/settings'; const initialState = Map({ - settings: Map({ - wordlist: Map({ - banned: List(), - suspect: List() - }), - domains: Map({ - whitelist: List() - }) + wordlist: Map({ + banned: List(), + suspect: List() + }), + domains: Map({ + whitelist: List() }), saveSettingsError: null, fetchSettingsError: null, @@ -54,10 +52,10 @@ export default function settings (state = initialState, action) { .set('fetchSettingsError', action.error); case actions.WORDLIST_UPDATED: return state - .setIn(['settings', 'wordlist', action.listName], action.list); + .setIn(['wordlist', action.listName], action.list); case actions.DOMAINLIST_UPDATED: return state - .setIn(['settings', 'domains', action.listName], action.list); + .setIn(['domains', action.listName], action.list); default: return state; } diff --git a/client/coral-admin/src/translations.json b/client/coral-admin/src/translations.json index e549d1f56..9c9f92868 100644 --- a/client/coral-admin/src/translations.json +++ b/client/coral-admin/src/translations.json @@ -48,6 +48,8 @@ "copy": "Copy to Clipboard" }, "configure": { + "custom-css-url": "Custom CSS URL", + "custom-css-url-desc": "URL of a CSS stylesheet that will override default Embed Stream styles. Can be internal or external.", "dashboard": "Dashboard", "enable-pre-moderation": "Enable pre-moderation", "enable-pre-moderation-text": "Moderators must approve any comment before it is published.", @@ -158,6 +160,8 @@ "username_flags": "" }, "configure": { + "custom-css-url": "URL CSS a medida", + "custom-css-url-desc": "URL de una hoja de estilo que va a sobrescribir los estilos por defecto de Embed Stream. Puede ser interna o externa.", "dashboard": "Panel", "enable-pre-moderation": "Habilitar pre-moderación", "enable-pre-moderation-text": "Los moderadores deben aprobar cada comentario antes de que sea publicado.", diff --git a/models/setting.js b/models/setting.js index adbf60d83..0987b141d 100644 --- a/models/setting.js +++ b/models/setting.js @@ -24,6 +24,10 @@ const SettingSchema = new Schema({ type: Boolean, default: false }, + customCssUrl: { + type: String, + default: '' + }, infoBoxContent: { type: String, default: '' diff --git a/routes/embed/index.js b/routes/embed/index.js index 400d2eb4b..ccc872c1f 100644 --- a/routes/embed/index.js +++ b/routes/embed/index.js @@ -1,10 +1,14 @@ const express = require('express'); const router = express.Router(); +const SettingsService = require('../../services/settings'); router.use('/:embed', (req, res, next) => { switch (req.params.embed) { case 'stream': - return res.render('embed/stream', {}); + return SettingsService.retrieve() + .then(({customCssUrl}) => { + return res.render('embed/stream', {customCssUrl}); + }); default: // will return a 404. diff --git a/views/embed/stream.ejs b/views/embed/stream.ejs index 722864338..77b392b5f 100644 --- a/views/embed/stream.ejs +++ b/views/embed/stream.ejs @@ -5,6 +5,9 @@ + <% if (locals.customCssUrl) { %> + + <% } %>