Make terminology consistent for sites and pages.

This commit is contained in:
Dorian 2016-11-22 10:47:24 -05:00
parent 6ced790023
commit fbed252028
6 changed files with 42 additions and 42 deletions

View File

@ -22,7 +22,7 @@ logger = logging.getLogger(__name__)
# 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():
# TODO Make testable and configurable
@ -42,7 +42,7 @@ def app_config():
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():
site = None
db_session = database.SQLAlchemy.session

View File

@ -14,9 +14,9 @@ import {ThemeManager} from "./theme_manager";
import {UserInfo} from "./user_info";
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 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 UPDATE_USER_ACTION = "UPDATE_USER";
export const LOGOUT_USER_ACTION = "LOGOUT_USER";
@ -26,22 +26,22 @@ export const SWITCH_THEME_ACTION = "SWITCH_THEME";
export function initializeApp(applicationStore) {
// TODO: Add ability to load application state / persistent settings from local storage.
applicationStore.dispatch(fetchAppSiteInfo());
applicationStore.dispatch(fetchSiteInfo());
applicationStore.dispatch(initialUser());
applicationStore.dispatch(fetchNavigationMenu());
applicationStore.dispatch(loadArticle());
applicationStore.dispatch(fetchSiteMenu());
applicationStore.dispatch(loadPage());
applicationStore.dispatch(loadTheme());
}
export function fetchArticle(articleId='') {
export function fetchPage(pageSlug='') {
return (dispatch) => {
let page_url = `/api/pages/${articleId}`;
if (articleId === '') {
let page_url = `/api/pages/${pageSlug}`;
if (pageSlug === '') {
console.info(`Loading landing page.`);
page_url = '/api/pages'
} else {
console.info(`Loading... ${articleId}`);
console.info(`Loading... ${pageSlug}`);
}
return fetch(page_url)
@ -59,20 +59,20 @@ export function fetchArticle(articleId='') {
let articleContent = Reflect.get(json, 'content');
let title = Reflect.get(json, 'title');
if (articleContent === undefined) {
if (articleId === 'error') {
articleContent = `ERROR - No content found for "${articleId}"!`;
if (pageSlug === 'error') {
articleContent = `ERROR - No content found for "${pageSlug}"!`;
} 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 fetch("/api/app/menu")
return fetch("/api/site/menu")
.then((response) => {
// TODO: Add better error handling.
// if (response.ok) {
@ -88,9 +88,9 @@ export function fetchNavigationMenu() {
}
}
export function fetchAppSiteInfo() {
export function fetchSiteInfo() {
return (dispatch) => {
return fetch("/api/app")
return fetch("/api/site")
.then((response) => {
// TODO: Add better error handling.
@ -110,20 +110,20 @@ export function fetchAppSiteInfo() {
name: json.config.name,
tagline: json.config.tagline
};
return dispatch(updateAppSiteInfo(appSiteInfo));
return dispatch(updateSiteInfo(appSiteInfo));
});
}
}
export function updateAppSiteInfo(appSiteInfo) {
export function updateSiteInfo(siteInfo) {
return {
type: UPDATE_APP_SITE_INFO_ACTION,
site: appSiteInfo
type: UPDATE_SITE_INFO_ACTION,
site: siteInfo
};
}
// TODO: Implement this better.
export function saveArticle(content) {
export function savePage(content) {
return (dispatch) => {
return fetch(`/api/pages/${content.id}`, {
method: "POST",
@ -143,18 +143,18 @@ export function saveArticle(content) {
if (articleId === 'error') {
articleContent = `ERROR - No content found for "${articleId}"!`;
} 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...
return {
type: LOAD_ARTICLE_ACTION,
type: LOAD_PAGE_ACTION,
content: {...article}
};
}

View File

@ -20,7 +20,7 @@ import {ConnectedNavigationMenu} from "../views/navigation_menu";
class App extends React.Component {
static get propTypes() {
return {
siteFooter: React.PropTypes.string,
footer: React.PropTypes.string,
siteName: React.PropTypes.string,
logo: React.PropTypes.string,
tagline: React.PropTypes.string
@ -67,7 +67,7 @@ class App extends React.Component {
export const WiredApp = connect(
(state) => {
return {
'siteFooter': state.site.footer,
'footer': state.site.footer,
'siteName': state.site.name,
'logo': state.site.logo,
'tagline': state.site.tagline

View File

@ -13,9 +13,9 @@ import * as actions from './actions';
// TODO Improve setup of reducers.
function articleStateReducer(state = "Loading...", action) {
function pageStateReducer(state = "Loading...", action) {
switch (action.type) {
case actions.LOAD_ARTICLE_ACTION:
case actions.LOAD_PAGE_ACTION:
return action.content;
default:
return state;
@ -32,16 +32,16 @@ function menuStateReducer(state = [], action) {
}
const DEFAULT_APP_SITE_INFO = {
const DEFAULT_SITE_INFO = {
name: "Rookeries",
logo: "/static/images/mr-penguin-amber.svg",
tagline: "Simple Site Scaffolding",
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) {
case actions.UPDATE_APP_SITE_INFO_ACTION:
case actions.UPDATE_SITE_INFO_ACTION:
return action.site;
default:
return state;
@ -94,10 +94,10 @@ function editorStateReducer(state = {...DEFAULT_EDITOR_STATE}, action) {
}
const reducer = combineReducers({
page: articleStateReducer,
page: pageStateReducer,
editor: editorStateReducer,
menu: menuStateReducer,
site: appSiteInfoStateReducer,
site: siteInfoStateReducer,
user: userLoginStateReducer,
theme: themeStateReducer,
routing: routerReducer

View File

@ -15,14 +15,14 @@ import {Provider} from "react-redux";
import {Routes} from "./routes";
import {appStore} from "../stores";
import {initializeApp, fetchArticle} from "../actions";
import {initializeApp, fetchPage} from "../actions";
export default function () {
initializeApp(appStore);
const history = syncHistoryWithStore(browserHistory, appStore);
history.listen((location) => {
appStore.dispatch(fetchArticle(location.pathname.substring(1)))
appStore.dispatch(fetchPage(location.pathname.substring(1)))
});
const RookeriesWiredApp = (

View File

@ -15,7 +15,7 @@ import highlighter from "highlight.js";
import {Button, Panel} from "react-bootstrap";
import FontAwesome from "react-fontawesome";
import {fetchArticle, saveArticle} from '../actions';
import {fetchPage, savePage} from '../actions';
import {appStore} from "../stores";
/*
@ -70,7 +70,7 @@ export class JournalMarkdownView extends React.Component {
componentDidMount() {
let pageToLoad = this.props.params.pageId;
appStore.dispatch(fetchArticle(pageToLoad));
appStore.dispatch(fetchPage(pageToLoad));
this.updateEditAllowance(this.props.userCanEdit);
}
@ -110,7 +110,7 @@ export class JournalMarkdownView extends React.Component {
title: this.props.title,
content: this.state.displayContent
};
appStore.dispatch(saveArticle(pageContent));
appStore.dispatch(savePage(pageContent));
}
updateEditAllowance(allowEdits) {