Migrate footer to use Markdown blocks.

Introduce uwsgi reloading for Python changes.
This commit is contained in:
Dorian 2017-09-29 09:27:56 -04:00
parent 69f73a2abf
commit 02aebf74bf
9 changed files with 47 additions and 16 deletions

View File

@ -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',

View File

@ -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.*/}
<Row className='justify-content-center'>
<Col lg='3'>s
<NavigationMenu menu={ this.props.siteMenu } />
<NavigationMenu menu={ this.props.menu } />
</Col>
<Col lg='8' className='ice-floe'>
<Switch>
@ -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,

View File

@ -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 {
<Container>
<Row className='justify-content-end'>
<Col lg='8'>
<footer>{ this.props.footer }</footer>
<MarkdownBlock { ...this.props.footer } id='footer' />
</Col>
</Row>
</Container>

View File

@ -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 (
<span id={ this.props.id } dangerouslySetInnerHTML={{__html: rawMarkup}} />
);
}
}
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)
);

View File

@ -167,7 +167,7 @@ ul.navigation-bar > li > a {
}
/*** Footer ***/
footer {
#footer {
font-family: var(--console-font-family);
font-size: small;
font-weight: bold;

View File

@ -45,7 +45,7 @@ body.daytime {
}
/*** Footer ***/
body.daytime footer {
body.daytime #footer {
color: var(--daytime-footer-text-colour);
}

View File

@ -45,7 +45,7 @@ body.evening {
}
/*** Footer ***/
body.evening footer {
body.evening #footer {
color: var(--evening-footer-text-colour);
}

View File

@ -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()"',
])

View File

@ -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(<MarkdownBlock />)
expect(<EditableMarkdownBlock />)
.to.not.eql(
<div>
<h1>Loading...</h1>
@ -27,7 +27,7 @@ describe('JournalMarkdownViewer', () => {
</div>
);
expect(<MarkdownBlock />)
expect(<EditableMarkdownBlock />)
.to.contain(
<div>
<h1 />