From 02aebf74bf8c998d85e822e12b63c2b3ea608630 Mon Sep 17 00:00:00 2001 From: Dorian Pula Date: Fri, 29 Sep 2017 09:27:56 -0400 Subject: [PATCH] Migrate footer to use Markdown blocks. Introduce uwsgi reloading for Python changes. --- rookeries/sites/views.py | 2 +- src/containers/App.js | 11 +++++--- src/containers/SiteFooter.js | 5 ++-- src/views/MarkdownBlock.js | 28 +++++++++++++++++-- static/css/penguin-common-theme.css | 2 +- static/css/penguin-daytime-theme.css | 2 +- static/css/penguin-evening-theme.css | 2 +- tasks/server.py | 5 +++- tests/js/test_journal_markdown_viewer_view.js | 6 ++-- 9 files changed, 47 insertions(+), 16 deletions(-) diff --git a/rookeries/sites/views.py b/rookeries/sites/views.py index b2a3596..6411590 100644 --- a/rookeries/sites/views.py +++ b/rookeries/sites/views.py @@ -74,7 +74,7 @@ def get_site(): 'name': 'Rookeries', 'favicon': '/static/images/mr-penguin-amber-favicon.ico', 'config': { - 'footer': 'Rookeries - © 2013-2016 - Amber Penguin Software', + 'footer': 'Rookeries - © 2013-2017 - Amber Penguin Software', 'name': 'Rookeries', 'tagline': 'Simple Site Construction', 'logo': '/static/images/mr-penguin-amber.svg', diff --git a/src/containers/App.js b/src/containers/App.js index f8a86a4..0e06654 100644 --- a/src/containers/App.js +++ b/src/containers/App.js @@ -26,7 +26,7 @@ import {PageBlock} from '../views/MarkdownBlock'; class App extends Component { static get propTypes() { return { - siteMenu: PropTypes.object, + menu: PropTypes.object, footer: PropTypes.string, siteName: PropTypes.string, logo: PropTypes.string, @@ -58,7 +58,7 @@ class App extends Component { {/*TODO Extract as Main body and navigation sidebar containers.*/} s - + @@ -78,8 +78,11 @@ class App extends Component { export const RookeriesApp = withRouter(connect( (state) => { return { - 'siteMenu': state.menu, - 'footer': state.site.footer, + 'menu': state.menu, + 'footer': { + 'slug': '_header', + 'content': state.site.footer, + }, 'siteName': state.site.name, 'logo': state.site.logo, 'tagline': state.site.tagline, diff --git a/src/containers/SiteFooter.js b/src/containers/SiteFooter.js index dc1f74f..e0de633 100644 --- a/src/containers/SiteFooter.js +++ b/src/containers/SiteFooter.js @@ -9,9 +9,10 @@ Site footer import {h, Component} from 'preact'; /** @jsx h*/ import {Row, Col, Container} from 'reactstrap'; - import PropTypes from 'prop-types'; +import {MarkdownBlock} from '../views/MarkdownBlock'; + export class SiteFooter extends Component { static get propTypes() { @@ -25,7 +26,7 @@ export class SiteFooter extends Component { -
{ this.props.footer }
+
diff --git a/src/views/MarkdownBlock.js b/src/views/MarkdownBlock.js index 8ea8fd9..a407f00 100644 --- a/src/views/MarkdownBlock.js +++ b/src/views/MarkdownBlock.js @@ -31,8 +31,32 @@ export const EditorPaneState = { editableOpen: 2 }; - export class MarkdownBlock extends Component { + static get propTypes() { + return { + id: PropTypes.string, + slug: PropTypes.string, + content: PropTypes.string, + } + } + + render() { + let md = markdown({ + html: true, + highlight: (code_) => { + return highlighter.highlightAuto(code_).value; + } + }); + let rawMarkup = md.render(this.props.content); + + return ( + + ); + } +} + + +export class EditableMarkdownBlock extends Component { static get propTypes() { return { slug: PropTypes.string, @@ -181,5 +205,5 @@ export const PageBlock = withRouter( 'editorTheme': state.editor.theme, 'userCanEdit': state.user.token !== '' }; - })(MarkdownBlock) + })(EditableMarkdownBlock) ); diff --git a/static/css/penguin-common-theme.css b/static/css/penguin-common-theme.css index 953ded3..ce64ed9 100644 --- a/static/css/penguin-common-theme.css +++ b/static/css/penguin-common-theme.css @@ -167,7 +167,7 @@ ul.navigation-bar > li > a { } /*** Footer ***/ -footer { +#footer { font-family: var(--console-font-family); font-size: small; font-weight: bold; diff --git a/static/css/penguin-daytime-theme.css b/static/css/penguin-daytime-theme.css index d569512..14f39b6 100644 --- a/static/css/penguin-daytime-theme.css +++ b/static/css/penguin-daytime-theme.css @@ -45,7 +45,7 @@ body.daytime { } /*** Footer ***/ -body.daytime footer { +body.daytime #footer { color: var(--daytime-footer-text-colour); } diff --git a/static/css/penguin-evening-theme.css b/static/css/penguin-evening-theme.css index ccd6d12..5b45d2e 100644 --- a/static/css/penguin-evening-theme.css +++ b/static/css/penguin-evening-theme.css @@ -45,7 +45,7 @@ body.evening { } /*** Footer ***/ -body.evening footer { +body.evening #footer { color: var(--evening-footer-text-colour); } diff --git a/tasks/server.py b/tasks/server.py index dfc7bdf..9836c4a 100644 --- a/tasks/server.py +++ b/tasks/server.py @@ -40,7 +40,7 @@ def wait(ctx, timeout=10): @inv.task(prepare_assets) -def run(ctx, port=5000): +def run(ctx, port=5000, dev_mode=False): """ Run the API app in a server By default this runs a production uWSGI server. @@ -49,11 +49,14 @@ def run(ctx, port=5000): :param port: The port to run the API app on. 5000 by default. """ + autoreload_flag = '' if not dev_mode else '--py-autoreload 1' + uwsgi_cmd = ' '.join([ 'uwsgi', f'--http :{port}', '--master', '--processes 4', + autoreload_flag, '--module "rookeries:make_rookeries_app()"', ]) diff --git a/tests/js/test_journal_markdown_viewer_view.js b/tests/js/test_journal_markdown_viewer_view.js index a68bcb6..4a99bdd 100644 --- a/tests/js/test_journal_markdown_viewer_view.js +++ b/tests/js/test_journal_markdown_viewer_view.js @@ -2,7 +2,7 @@ import {h} from "preact"; /** @jsx h */ -import { MarkdownBlock } from "../../src/views/MarkdownBlock"; +import { EditableMarkdownBlock } from "../../src/views/MarkdownBlock"; import chai, {assert, expect} from "chai"; import assertJsx from "preact-jsx-chai"; @@ -19,7 +19,7 @@ describe('JournalMarkdownViewer', () => { describe("Fetching of Articles by view linked to store", () => { it('The view should default to a loading text when initializing and then calling for data', () => { - expect() + expect() .to.not.eql(

Loading...

@@ -27,7 +27,7 @@ describe('JournalMarkdownViewer', () => {
); - expect() + expect() .to.contain(