Make terminology consistent for sites and pages.
This commit is contained in:
parent
6ced790023
commit
fbed252028
|
@ -22,7 +22,7 @@ logger = logging.getLogger(__name__)
|
||||||
# TODO: Add in functionality to create and updates sites and menus.
|
# TODO: Add in functionality to create and updates sites and menus.
|
||||||
|
|
||||||
|
|
||||||
@rookeries_app.route('/api/app', methods=['GET'])
|
@rookeries_app.route('/api/site', methods=['GET'])
|
||||||
def app_config():
|
def app_config():
|
||||||
# TODO Make testable and configurable
|
# TODO Make testable and configurable
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ def app_config():
|
||||||
return flask.jsonify(site.to_json())
|
return flask.jsonify(site.to_json())
|
||||||
|
|
||||||
|
|
||||||
@rookeries_app.route('/api/app/menu', methods=['GET'])
|
@rookeries_app.route('/api/site/menu', methods=['GET'])
|
||||||
def menu_config():
|
def menu_config():
|
||||||
site = None
|
site = None
|
||||||
db_session = database.SQLAlchemy.session
|
db_session = database.SQLAlchemy.session
|
||||||
|
|
|
@ -14,9 +14,9 @@ import {ThemeManager} from "./theme_manager";
|
||||||
import {UserInfo} from "./user_info";
|
import {UserInfo} from "./user_info";
|
||||||
import {DEFAULT_USER_LOGIN} from "./reducers";
|
import {DEFAULT_USER_LOGIN} from "./reducers";
|
||||||
|
|
||||||
export const LOAD_ARTICLE_ACTION = "LOAD_ARTICLE";
|
export const LOAD_PAGE_ACTION = "LOAD_ARTICLE";
|
||||||
export const LOAD_MENU_ACTION = "LOAD_MENU";
|
export const LOAD_MENU_ACTION = "LOAD_MENU";
|
||||||
export const UPDATE_APP_SITE_INFO_ACTION = "UPDATE_APP_SITE_INFO";
|
export const UPDATE_SITE_INFO_ACTION = "UPDATE_APP_SITE_INFO";
|
||||||
export const LOAD_INITIAL_USER_ACTION = "INITIAL_USER";
|
export const LOAD_INITIAL_USER_ACTION = "INITIAL_USER";
|
||||||
export const UPDATE_USER_ACTION = "UPDATE_USER";
|
export const UPDATE_USER_ACTION = "UPDATE_USER";
|
||||||
export const LOGOUT_USER_ACTION = "LOGOUT_USER";
|
export const LOGOUT_USER_ACTION = "LOGOUT_USER";
|
||||||
|
@ -26,22 +26,22 @@ export const SWITCH_THEME_ACTION = "SWITCH_THEME";
|
||||||
|
|
||||||
export function initializeApp(applicationStore) {
|
export function initializeApp(applicationStore) {
|
||||||
// TODO: Add ability to load application state / persistent settings from local storage.
|
// TODO: Add ability to load application state / persistent settings from local storage.
|
||||||
applicationStore.dispatch(fetchAppSiteInfo());
|
applicationStore.dispatch(fetchSiteInfo());
|
||||||
applicationStore.dispatch(initialUser());
|
applicationStore.dispatch(initialUser());
|
||||||
applicationStore.dispatch(fetchNavigationMenu());
|
applicationStore.dispatch(fetchSiteMenu());
|
||||||
applicationStore.dispatch(loadArticle());
|
applicationStore.dispatch(loadPage());
|
||||||
applicationStore.dispatch(loadTheme());
|
applicationStore.dispatch(loadTheme());
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fetchArticle(articleId='') {
|
export function fetchPage(pageSlug='') {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
|
|
||||||
let page_url = `/api/pages/${articleId}`;
|
let page_url = `/api/pages/${pageSlug}`;
|
||||||
if (articleId === '') {
|
if (pageSlug === '') {
|
||||||
console.info(`Loading landing page.`);
|
console.info(`Loading landing page.`);
|
||||||
page_url = '/api/pages'
|
page_url = '/api/pages'
|
||||||
} else {
|
} else {
|
||||||
console.info(`Loading... ${articleId}`);
|
console.info(`Loading... ${pageSlug}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return fetch(page_url)
|
return fetch(page_url)
|
||||||
|
@ -59,20 +59,20 @@ export function fetchArticle(articleId='') {
|
||||||
let articleContent = Reflect.get(json, 'content');
|
let articleContent = Reflect.get(json, 'content');
|
||||||
let title = Reflect.get(json, 'title');
|
let title = Reflect.get(json, 'title');
|
||||||
if (articleContent === undefined) {
|
if (articleContent === undefined) {
|
||||||
if (articleId === 'error') {
|
if (pageSlug === 'error') {
|
||||||
articleContent = `ERROR - No content found for "${articleId}"!`;
|
articleContent = `ERROR - No content found for "${pageSlug}"!`;
|
||||||
} else {
|
} else {
|
||||||
dispatch(fetchArticle("error"));
|
dispatch(fetchPage("error"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return dispatch(loadArticle({id: articleId, content: articleContent, title: title}));
|
return dispatch(loadPage({id: pageSlug, content: articleContent, title: title}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fetchNavigationMenu() {
|
export function fetchSiteMenu() {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
return fetch("/api/app/menu")
|
return fetch("/api/site/menu")
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
// TODO: Add better error handling.
|
// TODO: Add better error handling.
|
||||||
// if (response.ok) {
|
// if (response.ok) {
|
||||||
|
@ -88,9 +88,9 @@ export function fetchNavigationMenu() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fetchAppSiteInfo() {
|
export function fetchSiteInfo() {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
return fetch("/api/app")
|
return fetch("/api/site")
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
|
|
||||||
// TODO: Add better error handling.
|
// TODO: Add better error handling.
|
||||||
|
@ -110,20 +110,20 @@ export function fetchAppSiteInfo() {
|
||||||
name: json.config.name,
|
name: json.config.name,
|
||||||
tagline: json.config.tagline
|
tagline: json.config.tagline
|
||||||
};
|
};
|
||||||
return dispatch(updateAppSiteInfo(appSiteInfo));
|
return dispatch(updateSiteInfo(appSiteInfo));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateAppSiteInfo(appSiteInfo) {
|
export function updateSiteInfo(siteInfo) {
|
||||||
return {
|
return {
|
||||||
type: UPDATE_APP_SITE_INFO_ACTION,
|
type: UPDATE_SITE_INFO_ACTION,
|
||||||
site: appSiteInfo
|
site: siteInfo
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Implement this better.
|
// TODO: Implement this better.
|
||||||
export function saveArticle(content) {
|
export function savePage(content) {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
return fetch(`/api/pages/${content.id}`, {
|
return fetch(`/api/pages/${content.id}`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
@ -143,18 +143,18 @@ export function saveArticle(content) {
|
||||||
if (articleId === 'error') {
|
if (articleId === 'error') {
|
||||||
articleContent = `ERROR - No content found for "${articleId}"!`;
|
articleContent = `ERROR - No content found for "${articleId}"!`;
|
||||||
} else {
|
} else {
|
||||||
dispatch(fetchArticle("error"));
|
dispatch(fetchPage("error"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return dispatch(loadArticle({id: articleId, content: articleContent, title: title}));
|
return dispatch(loadPage({id: articleId, content: articleContent, title: title}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function loadArticle(article={content: 'Loading content... Please wait.', title: 'Loading...'}) {
|
export function loadPage(article={content: 'Loading content... Please wait.', title: 'Loading...'}) {
|
||||||
// TODO: Extract editor setup and session info...
|
// TODO: Extract editor setup and session info...
|
||||||
return {
|
return {
|
||||||
type: LOAD_ARTICLE_ACTION,
|
type: LOAD_PAGE_ACTION,
|
||||||
content: {...article}
|
content: {...article}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import {ConnectedNavigationMenu} from "../views/navigation_menu";
|
||||||
class App extends React.Component {
|
class App extends React.Component {
|
||||||
static get propTypes() {
|
static get propTypes() {
|
||||||
return {
|
return {
|
||||||
siteFooter: React.PropTypes.string,
|
footer: React.PropTypes.string,
|
||||||
siteName: React.PropTypes.string,
|
siteName: React.PropTypes.string,
|
||||||
logo: React.PropTypes.string,
|
logo: React.PropTypes.string,
|
||||||
tagline: React.PropTypes.string
|
tagline: React.PropTypes.string
|
||||||
|
@ -67,7 +67,7 @@ class App extends React.Component {
|
||||||
export const WiredApp = connect(
|
export const WiredApp = connect(
|
||||||
(state) => {
|
(state) => {
|
||||||
return {
|
return {
|
||||||
'siteFooter': state.site.footer,
|
'footer': state.site.footer,
|
||||||
'siteName': state.site.name,
|
'siteName': state.site.name,
|
||||||
'logo': state.site.logo,
|
'logo': state.site.logo,
|
||||||
'tagline': state.site.tagline
|
'tagline': state.site.tagline
|
||||||
|
|
|
@ -13,9 +13,9 @@ import * as actions from './actions';
|
||||||
// TODO Improve setup of reducers.
|
// TODO Improve setup of reducers.
|
||||||
|
|
||||||
|
|
||||||
function articleStateReducer(state = "Loading...", action) {
|
function pageStateReducer(state = "Loading...", action) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case actions.LOAD_ARTICLE_ACTION:
|
case actions.LOAD_PAGE_ACTION:
|
||||||
return action.content;
|
return action.content;
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
|
@ -32,16 +32,16 @@ function menuStateReducer(state = [], action) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const DEFAULT_APP_SITE_INFO = {
|
const DEFAULT_SITE_INFO = {
|
||||||
name: "Rookeries",
|
name: "Rookeries",
|
||||||
logo: "/static/images/mr-penguin-amber.svg",
|
logo: "/static/images/mr-penguin-amber.svg",
|
||||||
tagline: "Simple Site Scaffolding",
|
tagline: "Simple Site Scaffolding",
|
||||||
footer: "Rookeries - © 2013-2016 - Amber Penguin Software"
|
footer: "Rookeries - © 2013-2016 - Amber Penguin Software"
|
||||||
};
|
};
|
||||||
|
|
||||||
function appSiteInfoStateReducer(state = {...DEFAULT_APP_SITE_INFO}, action) {
|
function siteInfoStateReducer(state = {...DEFAULT_SITE_INFO}, action) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case actions.UPDATE_APP_SITE_INFO_ACTION:
|
case actions.UPDATE_SITE_INFO_ACTION:
|
||||||
return action.site;
|
return action.site;
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
|
@ -94,10 +94,10 @@ function editorStateReducer(state = {...DEFAULT_EDITOR_STATE}, action) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const reducer = combineReducers({
|
const reducer = combineReducers({
|
||||||
page: articleStateReducer,
|
page: pageStateReducer,
|
||||||
editor: editorStateReducer,
|
editor: editorStateReducer,
|
||||||
menu: menuStateReducer,
|
menu: menuStateReducer,
|
||||||
site: appSiteInfoStateReducer,
|
site: siteInfoStateReducer,
|
||||||
user: userLoginStateReducer,
|
user: userLoginStateReducer,
|
||||||
theme: themeStateReducer,
|
theme: themeStateReducer,
|
||||||
routing: routerReducer
|
routing: routerReducer
|
||||||
|
|
|
@ -15,14 +15,14 @@ import {Provider} from "react-redux";
|
||||||
|
|
||||||
import {Routes} from "./routes";
|
import {Routes} from "./routes";
|
||||||
import {appStore} from "../stores";
|
import {appStore} from "../stores";
|
||||||
import {initializeApp, fetchArticle} from "../actions";
|
import {initializeApp, fetchPage} from "../actions";
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
initializeApp(appStore);
|
initializeApp(appStore);
|
||||||
const history = syncHistoryWithStore(browserHistory, appStore);
|
const history = syncHistoryWithStore(browserHistory, appStore);
|
||||||
|
|
||||||
history.listen((location) => {
|
history.listen((location) => {
|
||||||
appStore.dispatch(fetchArticle(location.pathname.substring(1)))
|
appStore.dispatch(fetchPage(location.pathname.substring(1)))
|
||||||
});
|
});
|
||||||
|
|
||||||
const RookeriesWiredApp = (
|
const RookeriesWiredApp = (
|
||||||
|
|
|
@ -15,7 +15,7 @@ import highlighter from "highlight.js";
|
||||||
import {Button, Panel} from "react-bootstrap";
|
import {Button, Panel} from "react-bootstrap";
|
||||||
import FontAwesome from "react-fontawesome";
|
import FontAwesome from "react-fontawesome";
|
||||||
|
|
||||||
import {fetchArticle, saveArticle} from '../actions';
|
import {fetchPage, savePage} from '../actions';
|
||||||
import {appStore} from "../stores";
|
import {appStore} from "../stores";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -70,7 +70,7 @@ export class JournalMarkdownView extends React.Component {
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
let pageToLoad = this.props.params.pageId;
|
let pageToLoad = this.props.params.pageId;
|
||||||
appStore.dispatch(fetchArticle(pageToLoad));
|
appStore.dispatch(fetchPage(pageToLoad));
|
||||||
this.updateEditAllowance(this.props.userCanEdit);
|
this.updateEditAllowance(this.props.userCanEdit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ export class JournalMarkdownView extends React.Component {
|
||||||
title: this.props.title,
|
title: this.props.title,
|
||||||
content: this.state.displayContent
|
content: this.state.displayContent
|
||||||
};
|
};
|
||||||
appStore.dispatch(saveArticle(pageContent));
|
appStore.dispatch(savePage(pageContent));
|
||||||
}
|
}
|
||||||
|
|
||||||
updateEditAllowance(allowEdits) {
|
updateEditAllowance(allowEdits) {
|
||||||
|
|
Loading…
Reference in New Issue