Merge pull request #146 from netlify/fix-demo-ui
WIP: Change how single entries are fetched to avoid loading full list
This commit is contained in:
commit
78daa574af
@ -36,7 +36,14 @@ collections: # A list of collections the CMS should be able to edit
|
|||||||
file: "_data/settings.json"
|
file: "_data/settings.json"
|
||||||
description: "General Site Settings"
|
description: "General Site Settings"
|
||||||
fields:
|
fields:
|
||||||
- {label: "Global title", name: site_title, widget: "string"}
|
- {label: "Global title", name: "site_title", widget: "string"}
|
||||||
|
- label: "Post Settings"
|
||||||
|
name: posts
|
||||||
|
widget: "object"
|
||||||
|
fields:
|
||||||
|
- {label: "Number of posts on frontpage", name: front_limit, widget: number}
|
||||||
|
- {label: "Default Author", name: author, widget: string}
|
||||||
|
- {label: "Default Thumbnail", name: thumb, widget: image, class: "thumb"}
|
||||||
|
|
||||||
- name: "authors"
|
- name: "authors"
|
||||||
label: "Authors"
|
label: "Authors"
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
content: '{"site_title": "CMS Demo"}'
|
content: '{"site_title": "CMS Demo"}'
|
||||||
},
|
},
|
||||||
"authors.yml": {
|
"authors.yml": {
|
||||||
content: 'authors:\n - name: Mathias\n description: Co-founder @ Netlify\n'
|
content: 'authors:\n - name: Mathias\n description: Co-founder @ Netlify\n - name: Chris\n description: Co-founder @ Netlify\n'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,7 +87,31 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var GeneralPreview = createClass({
|
||||||
|
render: function() {
|
||||||
|
var entry = this.props.entry;
|
||||||
|
var title = entry.getIn(['data', 'site_title']);
|
||||||
|
var posts = entry.getIn(['data', 'posts']);
|
||||||
|
var thumb = posts && posts.get('thumb');
|
||||||
|
|
||||||
|
return h('div', {},
|
||||||
|
h('h1', {}, title),
|
||||||
|
h('dl', {},
|
||||||
|
h('dt', {}, 'Posts on Frontpage'),
|
||||||
|
h('dd', {}, posts && posts.get('front_limit') || '0'),
|
||||||
|
|
||||||
|
h('dt', {}, 'Default Author'),
|
||||||
|
h('dd', {}, posts && posts.get('author') || 'None'),
|
||||||
|
|
||||||
|
h('dt', {}, 'Default Thumbnail'),
|
||||||
|
h('dd', {}, thumb && h('img', {src: this.props.getMedia(thumb).toString()}))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
CMS.registerPreviewTemplate("posts", PostPreview);
|
CMS.registerPreviewTemplate("posts", PostPreview);
|
||||||
|
CMS.registerPreviewTemplate("general", GeneralPreview);
|
||||||
CMS.registerPreviewStyle("/example.css");
|
CMS.registerPreviewStyle("/example.css");
|
||||||
CMS.registerEditorComponent({
|
CMS.registerEditorComponent({
|
||||||
id: "youtube",
|
id: "youtube",
|
||||||
|
@ -91,7 +91,6 @@
|
|||||||
"@kadira/storybook": "^1.36.0",
|
"@kadira/storybook": "^1.36.0",
|
||||||
"autoprefixer": "^6.3.3",
|
"autoprefixer": "^6.3.3",
|
||||||
"bricks.js": "^1.7.0",
|
"bricks.js": "^1.7.0",
|
||||||
"textarea-caret-position": "^0.1.1",
|
|
||||||
"dateformat": "^1.0.12",
|
"dateformat": "^1.0.12",
|
||||||
"fuzzy": "^0.1.1",
|
"fuzzy": "^0.1.1",
|
||||||
"immutability-helper": "^2.0.0",
|
"immutability-helper": "^2.0.0",
|
||||||
@ -120,6 +119,7 @@
|
|||||||
"react-router": "^2.5.1",
|
"react-router": "^2.5.1",
|
||||||
"react-router-redux": "^4.0.5",
|
"react-router-redux": "^4.0.5",
|
||||||
"react-simple-dnd": "^0.1.2",
|
"react-simple-dnd": "^0.1.2",
|
||||||
|
"react-sortable": "^1.2.0",
|
||||||
"react-toolbox": "^1.2.1",
|
"react-toolbox": "^1.2.1",
|
||||||
"react-topbar-progress-indicator": "^1.0.0",
|
"react-topbar-progress-indicator": "^1.0.0",
|
||||||
"react-waypoint": "^3.1.3",
|
"react-waypoint": "^3.1.3",
|
||||||
@ -131,6 +131,7 @@
|
|||||||
"semaphore": "^1.0.5",
|
"semaphore": "^1.0.5",
|
||||||
"slate": "^0.14.14",
|
"slate": "^0.14.14",
|
||||||
"slate-drop-or-paste-images": "^0.2.0",
|
"slate-drop-or-paste-images": "^0.2.0",
|
||||||
|
"textarea-caret-position": "^0.1.1",
|
||||||
"uuid": "^2.0.3",
|
"uuid": "^2.0.3",
|
||||||
"whatwg-fetch": "^1.0.0"
|
"whatwg-fetch": "^1.0.0"
|
||||||
},
|
},
|
||||||
|
@ -181,13 +181,10 @@ export function loadEntry(entry, collection, slug) {
|
|||||||
const state = getState();
|
const state = getState();
|
||||||
const backend = currentBackend(state.config);
|
const backend = currentBackend(state.config);
|
||||||
dispatch(entryLoading(collection, slug));
|
dispatch(entryLoading(collection, slug));
|
||||||
let getPromise;
|
return backend.getEntry(collection, slug)
|
||||||
if (entry && entry.get('path') && entry.get('partial')) {
|
.then(loadedEntry => (
|
||||||
getPromise = backend.getEntry(entry.get('collection'), entry.get('slug'), entry.get('path'));
|
dispatch(entryLoaded(collection, loadedEntry))
|
||||||
} else {
|
));
|
||||||
getPromise = backend.lookupEntry(collection, slug);
|
|
||||||
}
|
|
||||||
return getPromise.then(loadedEntry => dispatch(entryLoaded(collection, loadedEntry)));
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import GitHubBackend from './github/implementation';
|
|||||||
import NetlifyGitBackend from './netlify-git/implementation';
|
import NetlifyGitBackend from './netlify-git/implementation';
|
||||||
import { resolveFormat } from '../formats/formats';
|
import { resolveFormat } from '../formats/formats';
|
||||||
import { createEntry } from '../valueObjects/Entry';
|
import { createEntry } from '../valueObjects/Entry';
|
||||||
import { FILES, FOLDER } from '../constants/collectionTypes';
|
import Collection from '../valueObjects/Collection';
|
||||||
|
|
||||||
class LocalStorageAuthStore {
|
class LocalStorageAuthStore {
|
||||||
storageKey = 'nf-cms-user';
|
storageKey = 'nf-cms-user';
|
||||||
@ -20,8 +20,9 @@ class LocalStorageAuthStore {
|
|||||||
|
|
||||||
const slugFormatter = (template, entryData) => {
|
const slugFormatter = (template, entryData) => {
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
return template.replace(/\{\{([^\}]+)\}\}/g, (_, name) => {
|
const identifier = entryData.get('title', entryData.get('path'));
|
||||||
switch (name) {
|
return template.replace(/\{\{([^\}]+)\}\}/g, (_, field) => {
|
||||||
|
switch (field) {
|
||||||
case 'year':
|
case 'year':
|
||||||
return date.getFullYear();
|
return date.getFullYear();
|
||||||
case 'month':
|
case 'month':
|
||||||
@ -29,10 +30,9 @@ const slugFormatter = (template, entryData) => {
|
|||||||
case 'day':
|
case 'day':
|
||||||
return (`0${ date.getDate() }`).slice(-2);
|
return (`0${ date.getDate() }`).slice(-2);
|
||||||
case 'slug':
|
case 'slug':
|
||||||
const identifier = entryData.get('title', entryData.get('path'));
|
return identifier.trim().toLowerCase().replace(/[^a-z0-9\.\-_]+/gi, '-');
|
||||||
return identifier.trim().toLowerCase().replace(/[^a-z0-9\.\-\_]+/gi, '-');
|
|
||||||
default:
|
default:
|
||||||
return entryData.get(name);
|
return entryData.get(field);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -42,7 +42,7 @@ class Backend {
|
|||||||
this.implementation = implementation;
|
this.implementation = implementation;
|
||||||
this.authStore = authStore;
|
this.authStore = authStore;
|
||||||
if (this.implementation === null) {
|
if (this.implementation === null) {
|
||||||
throw 'Cannot instantiate a Backend with no implementation';
|
throw new Error('Cannot instantiate a Backend with no implementation');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,6 +53,7 @@ class Backend {
|
|||||||
this.implementation.setUser(stored);
|
this.implementation.setUser(stored);
|
||||||
return stored;
|
return stored;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
authComponent() {
|
authComponent() {
|
||||||
@ -67,49 +68,33 @@ class Backend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
listEntries(collection) {
|
listEntries(collection) {
|
||||||
const type = collection.get('type');
|
const collectionModel = new Collection(collection);
|
||||||
if (type === FOLDER) {
|
const listMethod = this.implementation[collectionModel.listMethod()];
|
||||||
return this.implementation.entriesByFolder(collection)
|
return listMethod.call(this.implementation, collection)
|
||||||
.then(loadedEntries => (
|
.then(loadedEntries => (
|
||||||
loadedEntries.map(loadedEntry => createEntry(collection.get('name'), loadedEntry.file.path.split('/').pop().replace(/\.[^\.]+$/, ''), loadedEntry.file.path, { raw: loadedEntry.data }))
|
loadedEntries.map(loadedEntry => createEntry(
|
||||||
|
collection.get('name'),
|
||||||
|
collectionModel.entrySlug(loadedEntry.file.path),
|
||||||
|
loadedEntry.file.path,
|
||||||
|
{ raw: loadedEntry.data, label: loadedEntry.file.label }
|
||||||
|
))
|
||||||
))
|
))
|
||||||
.then(entries => (
|
.then(entries => (
|
||||||
{
|
{
|
||||||
entries: entries.map(this.entryWithFormat(collection)),
|
entries: entries.map(this.entryWithFormat(collection)),
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
} else if (type === FILES) {
|
|
||||||
const collectionFiles = collection.get('files').map(collectionFile => ({ path: collectionFile.get('file'), label: collectionFile.get('label') }));
|
|
||||||
return this.implementation.entriesByFiles(collection, collectionFiles)
|
|
||||||
.then(loadedEntries => (
|
|
||||||
loadedEntries.map(loadedEntry => createEntry(collection.get('name'), loadedEntry.file.path.split('/').pop().replace(/\.[^\.]+$/, ''), loadedEntry.file.path, { raw: loadedEntry.data, label: loadedEntry.file.label }))
|
|
||||||
))
|
|
||||||
.then(entries => (
|
|
||||||
{
|
|
||||||
entries: entries.map(this.entryWithFormat(collection)),
|
|
||||||
}
|
|
||||||
));
|
|
||||||
}
|
|
||||||
return Promise.reject(`Couldn't process collection type ${ type }`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have the file path. Fetch and parse the file.
|
getEntry(collection, slug) {
|
||||||
getEntry(collection, slug, path) {
|
return this.implementation.getEntry(collection, slug, new Collection(collection).entryPath(slug))
|
||||||
return this.implementation.getEntry(collection, slug, path).then(this.entryWithFormat(collection));
|
.then(loadedEntry => this.entryWithFormat(collection, slug)(createEntry(
|
||||||
}
|
collection.get('name'),
|
||||||
|
slug,
|
||||||
// Will fetch the whole list of files from GitHub and load each file, then looks up for entry.
|
loadedEntry.file.path,
|
||||||
// (Files are persisted in local storage - only expensive on the first run for each file).
|
{ raw: loadedEntry.data, label: loadedEntry.file.label }
|
||||||
lookupEntry(collection, slug) {
|
|
||||||
const type = collection.get('type');
|
|
||||||
if (type === FOLDER) {
|
|
||||||
return this.implementation.entriesByFolder(collection)
|
|
||||||
.then(loadedEntries => (
|
|
||||||
loadedEntries.map(loadedEntry => createEntry(collection.get('name'), loadedEntry.file.path.split('/').pop().replace(/\.[^\.]+$/, ''), loadedEntry.file.path, { raw: loadedEntry.data }))
|
|
||||||
))
|
))
|
||||||
.then(response => response.filter(entry => entry.slug === slug)[0])
|
);
|
||||||
.then(this.entryWithFormat(collection));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
newEntry(collection) {
|
newEntry(collection) {
|
||||||
@ -120,49 +105,66 @@ class Backend {
|
|||||||
return (entry) => {
|
return (entry) => {
|
||||||
const format = resolveFormat(collectionOrEntity, entry);
|
const format = resolveFormat(collectionOrEntity, entry);
|
||||||
if (entry && entry.raw) {
|
if (entry && entry.raw) {
|
||||||
entry.data = format && format.fromFile(entry.raw);
|
return Object.assign(entry, { data: format && format.fromFile(entry.raw) });
|
||||||
return entry;
|
|
||||||
} else {
|
|
||||||
return format.fromFile(entry);
|
|
||||||
}
|
}
|
||||||
|
return format.fromFile(entry);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
unpublishedEntries(page, perPage) {
|
unpublishedEntries(page, perPage) {
|
||||||
return this.implementation.unpublishedEntries(page, perPage).then((response) => {
|
return this.implementation.unpublishedEntries(page, perPage)
|
||||||
return {
|
.then(loadedEntries => loadedEntries.filter(entry => entry !== null))
|
||||||
pagination: response.pagination,
|
.then(entries => (
|
||||||
entries: response.entries.map(this.entryWithFormat('editorialWorkflow')),
|
entries.map((loadedEntry) => {
|
||||||
};
|
const entry = createEntry('draft', loadedEntry.slug, loadedEntry.file.path, { raw: loadedEntry.data });
|
||||||
});
|
entry.metaData = loadedEntry.metaData;
|
||||||
|
return entry;
|
||||||
|
})
|
||||||
|
))
|
||||||
|
.then(entries => ({
|
||||||
|
pagination: 0,
|
||||||
|
entries: entries.map(this.entryWithFormat('editorialWorkflow')),
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
unpublishedEntry(collection, slug) {
|
unpublishedEntry(collection, slug) {
|
||||||
return this.implementation.unpublishedEntry(collection, slug).then(this.entryWithFormat(collection));
|
return this.implementation.unpublishedEntry(collection, slug)
|
||||||
|
.then((loadedEntry) => {
|
||||||
|
const entry = createEntry('draft', loadedEntry.slug, loadedEntry.file.path, { raw: loadedEntry.data });
|
||||||
|
entry.metaData = loadedEntry.metaData;
|
||||||
|
return entry;
|
||||||
|
})
|
||||||
|
.then(this.entryWithFormat(collection, slug));
|
||||||
}
|
}
|
||||||
|
|
||||||
persistEntry(config, collection, entryDraft, MediaFiles, options) {
|
persistEntry(config, collection, entryDraft, MediaFiles, options) {
|
||||||
|
const collectionModel = new Collection(collection);
|
||||||
const newEntry = entryDraft.getIn(['entry', 'newRecord']) || false;
|
const newEntry = entryDraft.getIn(['entry', 'newRecord']) || false;
|
||||||
|
|
||||||
const parsedData = {
|
const parsedData = {
|
||||||
title: entryDraft.getIn(['entry', 'data', 'title'], 'No Title'),
|
title: entryDraft.getIn(['entry', 'data', 'title'], 'No Title'),
|
||||||
description: entryDraft.getIn(['entry', 'data', 'description'], 'No Description'),
|
description: entryDraft.getIn(['entry', 'data', 'description'], 'No Description!'),
|
||||||
};
|
};
|
||||||
|
|
||||||
const entryData = entryDraft.getIn(['entry', 'data']).toJS();
|
const entryData = entryDraft.getIn(['entry', 'data']).toJS();
|
||||||
let entryObj;
|
let entryObj;
|
||||||
if (newEntry) {
|
if (newEntry) {
|
||||||
|
if (!collectionModel.allowNewEntries()) {
|
||||||
|
throw (new Error('Not allowed to create new entries in this collection'));
|
||||||
|
}
|
||||||
const slug = slugFormatter(collection.get('slug'), entryDraft.getIn(['entry', 'data']));
|
const slug = slugFormatter(collection.get('slug'), entryDraft.getIn(['entry', 'data']));
|
||||||
|
const path = collectionModel.entryPath(slug);
|
||||||
entryObj = {
|
entryObj = {
|
||||||
path: `${ collection.get('folder') }/${ slug }.md`,
|
path,
|
||||||
slug,
|
slug,
|
||||||
raw: this.entryToRaw(collection, entryData),
|
raw: this.entryToRaw(collection, Object.assign({ path }, entryData)),
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
const path = entryDraft.getIn(['entry', 'path']);
|
||||||
entryObj = {
|
entryObj = {
|
||||||
path: entryDraft.getIn(['entry', 'path']),
|
path,
|
||||||
slug: entryDraft.getIn(['entry', 'slug']),
|
slug: entryDraft.getIn(['entry', 'slug']),
|
||||||
raw: this.entryToRaw(collection, entryData),
|
raw: this.entryToRaw(collection, Object.assign({ path }, entryData)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,20 +203,20 @@ class Backend {
|
|||||||
export function resolveBackend(config) {
|
export function resolveBackend(config) {
|
||||||
const name = config.getIn(['backend', 'name']);
|
const name = config.getIn(['backend', 'name']);
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
throw 'No backend defined in configuration';
|
throw new Error('No backend defined in configuration');
|
||||||
}
|
}
|
||||||
|
|
||||||
const authStore = new LocalStorageAuthStore();
|
const authStore = new LocalStorageAuthStore();
|
||||||
|
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case 'test-repo':
|
case 'test-repo':
|
||||||
return new Backend(new TestRepoBackend(config, slugFormatter), authStore);
|
return new Backend(new TestRepoBackend(config), authStore);
|
||||||
case 'github':
|
case 'github':
|
||||||
return new Backend(new GitHubBackend(config, slugFormatter), authStore);
|
return new Backend(new GitHubBackend(config), authStore);
|
||||||
case 'netlify-git':
|
case 'netlify-git':
|
||||||
return new Backend(new NetlifyGitBackend(config, slugFormatter), authStore);
|
return new Backend(new NetlifyGitBackend(config), authStore);
|
||||||
default:
|
default:
|
||||||
throw `Backend not found: ${ name }`;
|
throw new Error(`Backend not found: ${ name }`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ export default class API {
|
|||||||
metaData = data;
|
metaData = data;
|
||||||
return this.readFile(data.objects.entry, null, data.branch);
|
return this.readFile(data.objects.entry, null, data.branch);
|
||||||
})
|
})
|
||||||
.then(file => ({ metaData, file }))
|
.then(fileData => ({ metaData, fileData }))
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import semaphore from 'semaphore';
|
import semaphore from 'semaphore';
|
||||||
import { createEntry } from '../../valueObjects/Entry';
|
|
||||||
import AuthenticationPage from './AuthenticationPage';
|
import AuthenticationPage from './AuthenticationPage';
|
||||||
import API from './API';
|
import API from './API';
|
||||||
|
|
||||||
@ -9,7 +8,7 @@ export default class GitHub {
|
|||||||
constructor(config) {
|
constructor(config) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
if (config.getIn(['backend', 'repo']) == null) {
|
if (config.getIn(['backend', 'repo']) == null) {
|
||||||
throw 'The GitHub backend needs a "repo" in the backend configuration.';
|
throw new Error('The GitHub backend needs a "repo" in the backend configuration.');
|
||||||
}
|
}
|
||||||
this.repo = config.getIn(['backend', 'repo']);
|
this.repo = config.getIn(['backend', 'repo']);
|
||||||
this.branch = config.getIn(['backend', 'branch']) || 'master';
|
this.branch = config.getIn(['backend', 'branch']) || 'master';
|
||||||
@ -32,34 +31,41 @@ export default class GitHub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
entriesByFolder(collection) {
|
entriesByFolder(collection) {
|
||||||
return this.api.listFiles(collection.get('folder')).then(files => this.entriesByFiles(collection, files));
|
return this.api.listFiles(collection.get('folder'))
|
||||||
|
.then(this.fetchFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
entriesByFiles(collection, files) {
|
entriesByFiles(collection) {
|
||||||
|
const files = collection.get('files').map(collectionFile => ({
|
||||||
|
path: collectionFile.get('file'),
|
||||||
|
label: collectionFile.get('label'),
|
||||||
|
}));
|
||||||
|
return this.fetchFiles(files);
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchFiles = (files) => {
|
||||||
const sem = semaphore(MAX_CONCURRENT_DOWNLOADS);
|
const sem = semaphore(MAX_CONCURRENT_DOWNLOADS);
|
||||||
const promises = [];
|
const promises = [];
|
||||||
files.forEach((file) => {
|
files.forEach((file) => {
|
||||||
promises.push(new Promise((resolve, reject) => {
|
promises.push(new Promise((resolve, reject) => (
|
||||||
return sem.take(() => this.api.readFile(file.path, file.sha).then((data) => {
|
sem.take(() => this.api.readFile(file.path, file.sha).then((data) => {
|
||||||
resolve(
|
resolve({ file, data });
|
||||||
{
|
|
||||||
file,
|
|
||||||
data,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
sem.leave();
|
sem.leave();
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
sem.leave();
|
sem.leave();
|
||||||
reject(err);
|
reject(err);
|
||||||
}));
|
}))
|
||||||
}));
|
)));
|
||||||
});
|
});
|
||||||
return Promise.all(promises);
|
return Promise.all(promises);
|
||||||
}
|
};
|
||||||
|
|
||||||
// Fetches a single entry.
|
// Fetches a single entry.
|
||||||
getEntry(collection, slug, path) {
|
getEntry(collection, slug, path) {
|
||||||
return this.api.readFile(path).then(data => createEntry(collection, slug, path, { raw: data }));
|
return this.api.readFile(path).then(data => ({
|
||||||
|
file: { path },
|
||||||
|
data,
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
persistEntry(entry, mediaFiles = [], options = {}) {
|
persistEntry(entry, mediaFiles = [], options = {}) {
|
||||||
@ -72,16 +78,19 @@ export default class GitHub {
|
|||||||
const promises = [];
|
const promises = [];
|
||||||
branches.map((branch) => {
|
branches.map((branch) => {
|
||||||
promises.push(new Promise((resolve, reject) => {
|
promises.push(new Promise((resolve, reject) => {
|
||||||
const contentKey = branch.ref.split('refs/heads/cms/').pop();
|
const slug = branch.ref.split('refs/heads/cms/').pop();
|
||||||
return sem.take(() => this.api.readUnpublishedBranchFile(contentKey).then((data) => {
|
return sem.take(() => this.api.readUnpublishedBranchFile(slug).then((data) => {
|
||||||
if (data === null || data === undefined) {
|
if (data === null || data === undefined) {
|
||||||
resolve(null);
|
resolve(null);
|
||||||
sem.leave();
|
sem.leave();
|
||||||
} else {
|
} else {
|
||||||
const entryPath = data.metaData.objects.entry;
|
const path = data.metaData.objects.entry;
|
||||||
const entry = createEntry('draft', contentKey, entryPath, { raw: data.file });
|
resolve({
|
||||||
entry.metaData = data.metaData;
|
slug,
|
||||||
resolve(entry);
|
file: { path },
|
||||||
|
data: data.fileData,
|
||||||
|
metaData: data.metaData,
|
||||||
|
});
|
||||||
sem.leave();
|
sem.leave();
|
||||||
}
|
}
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
@ -91,21 +100,17 @@ export default class GitHub {
|
|||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
return Promise.all(promises);
|
return Promise.all(promises);
|
||||||
}).then((entries) => {
|
|
||||||
const filteredEntries = entries.filter(entry => entry !== null);
|
|
||||||
return {
|
|
||||||
pagination: 0,
|
|
||||||
entries: filteredEntries,
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
unpublishedEntry(collection, slug) {
|
unpublishedEntry(collection, slug) {
|
||||||
return this.unpublishedEntries().then(response => (
|
return this.api.readUnpublishedBranchFile(slug)
|
||||||
response.entries.filter((entry) => {
|
.then(data => ({
|
||||||
return entry.metaData && entry.slug === slug;
|
slug,
|
||||||
})[0]
|
file: { path: data.metaData.objects.entry },
|
||||||
));
|
data: data.fileData,
|
||||||
|
metaData: data.metaData,
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
updateUnpublishedEntryStatus(collection, slug, newStatus) {
|
updateUnpublishedEntryStatus(collection, slug, newStatus) {
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
import AuthenticationPage from './AuthenticationPage';
|
import AuthenticationPage from './AuthenticationPage';
|
||||||
import { createEntry } from '../../valueObjects/Entry';
|
|
||||||
|
|
||||||
function getSlug(path) {
|
function getFile(path) {
|
||||||
const m = path.match(/([^\/]+?)(\.[^\/\.]+)?$/);
|
const segments = path.split('/');
|
||||||
return m && m[1];
|
let obj = window.repoFiles;
|
||||||
|
while (obj && segments.length) {
|
||||||
|
obj = obj[segments.shift()];
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class TestRepo {
|
export default class TestRepo {
|
||||||
@ -41,14 +44,22 @@ export default class TestRepo {
|
|||||||
return Promise.resolve(entries);
|
return Promise.resolve(entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
entriesByFiles(collection, files) {
|
entriesByFiles(collection) {
|
||||||
throw new Error('Not implemented yet');
|
const files = collection.get('files').map(collectionFile => ({
|
||||||
|
path: collectionFile.get('file'),
|
||||||
|
label: collectionFile.get('label'),
|
||||||
|
}));
|
||||||
|
return Promise.all(files.map(file => ({
|
||||||
|
file,
|
||||||
|
data: getFile(file.path).content,
|
||||||
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
lookupEntry(collection, slug) {
|
getEntry(collection, slug, path) {
|
||||||
return this.entries(collection).then(response => (
|
return Promise.resolve({
|
||||||
response.entries.filter(entry => entry.slug === slug)[0]
|
file: { path },
|
||||||
));
|
data: getFile(path).content
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
persistEntry(entry, mediaFiles = [], options) {
|
persistEntry(entry, mediaFiles = [], options) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import React, { PropTypes } from 'react';
|
import React, { PropTypes } from 'react';
|
||||||
import MarkupIt, { Syntax, BLOCKS, STYLES, ENTITIES } from 'markup-it';
|
import MarkupIt, { Syntax, BLOCKS, STYLES, ENTITIES } from 'markup-it';
|
||||||
import { omit } from 'lodash';
|
import { omit } from 'lodash';
|
||||||
|
import registry from '../../lib/registry';
|
||||||
|
|
||||||
const defaultSchema = {
|
const defaultSchema = {
|
||||||
[BLOCKS.DOCUMENT]: 'article',
|
[BLOCKS.DOCUMENT]: 'article',
|
||||||
@ -44,43 +45,16 @@ function sanitizeProps(props) {
|
|||||||
return omit(props, notAllowedAttributes);
|
return omit(props, notAllowedAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderToken(schema, token, index = 0, key = '0') {
|
|
||||||
const type = token.get('type');
|
|
||||||
const data = token.get('data');
|
|
||||||
const text = token.get('text');
|
|
||||||
const tokens = token.get('tokens');
|
|
||||||
const nodeType = schema[type];
|
|
||||||
key = `${ key }.${ index }`;
|
|
||||||
|
|
||||||
// Only render if type is registered as renderer
|
|
||||||
if (typeof nodeType !== 'undefined') {
|
|
||||||
let children = null;
|
|
||||||
if (tokens.size) {
|
|
||||||
children = tokens.map((token, idx) => renderToken(schema, token, idx, key));
|
|
||||||
} else if (type === 'text') {
|
|
||||||
children = text;
|
|
||||||
}
|
|
||||||
if (nodeType !== null) {
|
|
||||||
let props = { key, token };
|
|
||||||
if (typeof nodeType !== 'function') {
|
|
||||||
props = { key, ...sanitizeProps(data.toJS()) };
|
|
||||||
}
|
|
||||||
// If this is a react element
|
|
||||||
return React.createElement(nodeType, props, children);
|
|
||||||
} else {
|
|
||||||
// If this is a text node
|
|
||||||
return children;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class MarkupItReactRenderer extends React.Component {
|
export default class MarkupItReactRenderer extends React.Component {
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
const { syntax } = props;
|
const { syntax } = props;
|
||||||
this.parser = new MarkupIt(syntax);
|
this.parser = new MarkupIt(syntax);
|
||||||
|
this.plugins = {};
|
||||||
|
registry.getEditorComponents().forEach((component) => {
|
||||||
|
this.plugins[component.get('id')] = component;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
@ -89,10 +63,51 @@ export default class MarkupItReactRenderer extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderToken(schema, token, index = 0, key = '0') {
|
||||||
|
const type = token.get('type');
|
||||||
|
const data = token.get('data');
|
||||||
|
const text = token.get('text');
|
||||||
|
const tokens = token.get('tokens');
|
||||||
|
const nodeType = schema[type];
|
||||||
|
key = `${ key }.${ index }`;
|
||||||
|
|
||||||
|
// Only render if type is registered as renderer
|
||||||
|
if (typeof nodeType !== 'undefined') {
|
||||||
|
let children = null;
|
||||||
|
if (tokens.size) {
|
||||||
|
children = tokens.map((token, idx) => this.renderToken(schema, token, idx, key));
|
||||||
|
} else if (type === 'text') {
|
||||||
|
children = text;
|
||||||
|
}
|
||||||
|
if (nodeType !== null) {
|
||||||
|
let props = { key, token };
|
||||||
|
if (typeof nodeType !== 'function') {
|
||||||
|
props = { key, ...sanitizeProps(data.toJS()) };
|
||||||
|
}
|
||||||
|
// If this is a react element
|
||||||
|
return React.createElement(nodeType, props, children);
|
||||||
|
} else {
|
||||||
|
// If this is a text node
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const plugin = this.plugins[token.get('type')];
|
||||||
|
if (plugin) {
|
||||||
|
const output = plugin.toPreview(token.get('data').toJS());
|
||||||
|
return typeof output === 'string' ?
|
||||||
|
<span dangerouslySetInnerHTML={{ __html: output}} /> :
|
||||||
|
output;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { value, schema } = this.props;
|
const { value, schema } = this.props;
|
||||||
const content = this.parser.toContent(value);
|
const content = this.parser.toContent(value);
|
||||||
return renderToken({ ...defaultSchema, ...schema }, content.get('token'));
|
return this.renderToken({ ...defaultSchema, ...schema }, content.get('token'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ import ReactDOM from 'react-dom';
|
|||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
import { ScrollSyncPane } from '../ScrollSync';
|
import { ScrollSyncPane } from '../ScrollSync';
|
||||||
import registry from '../../lib/registry';
|
import registry from '../../lib/registry';
|
||||||
|
import Collection from '../../valueObjects/Collection';
|
||||||
import { resolveWidget } from '../Widgets';
|
import { resolveWidget } from '../Widgets';
|
||||||
import Preview from './Preview';
|
import Preview from './Preview';
|
||||||
import styles from './PreviewPane.css';
|
import styles from './PreviewPane.css';
|
||||||
@ -26,7 +27,9 @@ export default class PreviewPane extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
renderPreview() {
|
renderPreview() {
|
||||||
const component = registry.getPreviewTemplate(this.props.collection.get('name')) || Preview;
|
const { entry, collection } = this.props;
|
||||||
|
const collectionModel = new Collection(collection);
|
||||||
|
const component = registry.getPreviewTemplate(collectionModel.templateName(entry.get('slug'))) || Preview;
|
||||||
const previewProps = {
|
const previewProps = {
|
||||||
...this.props,
|
...this.props,
|
||||||
widgetFor: this.widgetFor,
|
widgetFor: this.widgetFor,
|
||||||
|
@ -3,6 +3,8 @@ import UnknownControl from './Widgets/UnknownControl';
|
|||||||
import UnknownPreview from './Widgets/UnknownPreview';
|
import UnknownPreview from './Widgets/UnknownPreview';
|
||||||
import StringControl from './Widgets/StringControl';
|
import StringControl from './Widgets/StringControl';
|
||||||
import StringPreview from './Widgets/StringPreview';
|
import StringPreview from './Widgets/StringPreview';
|
||||||
|
import NumberControl from './Widgets/NumberControl';
|
||||||
|
import NumberPreview from './Widgets/NumberPreview';
|
||||||
import ListControl from './Widgets/ListControl';
|
import ListControl from './Widgets/ListControl';
|
||||||
import ListPreview from './Widgets/ListPreview';
|
import ListPreview from './Widgets/ListPreview';
|
||||||
import TextControl from './Widgets/TextControl';
|
import TextControl from './Widgets/TextControl';
|
||||||
@ -13,13 +15,17 @@ import ImageControl from './Widgets/ImageControl';
|
|||||||
import ImagePreview from './Widgets/ImagePreview';
|
import ImagePreview from './Widgets/ImagePreview';
|
||||||
import DateTimeControl from './Widgets/DateTimeControl';
|
import DateTimeControl from './Widgets/DateTimeControl';
|
||||||
import DateTimePreview from './Widgets/DateTimePreview';
|
import DateTimePreview from './Widgets/DateTimePreview';
|
||||||
|
import ObjectControl from './Widgets/ObjectControl';
|
||||||
|
import ObjectPreview from './Widgets/ObjectPreview';
|
||||||
|
|
||||||
registry.registerWidget('string', StringControl, StringPreview);
|
registry.registerWidget('string', StringControl, StringPreview);
|
||||||
registry.registerWidget('text', TextControl, TextPreview);
|
registry.registerWidget('text', TextControl, TextPreview);
|
||||||
|
registry.registerWidget('number', NumberControl, NumberPreview);
|
||||||
registry.registerWidget('list', ListControl, ListPreview);
|
registry.registerWidget('list', ListControl, ListPreview);
|
||||||
registry.registerWidget('markdown', MarkdownControl, MarkdownPreview);
|
registry.registerWidget('markdown', MarkdownControl, MarkdownPreview);
|
||||||
registry.registerWidget('image', ImageControl, ImagePreview);
|
registry.registerWidget('image', ImageControl, ImagePreview);
|
||||||
registry.registerWidget('datetime', DateTimeControl, DateTimePreview);
|
registry.registerWidget('datetime', DateTimeControl, DateTimePreview);
|
||||||
|
registry.registerWidget('object', ObjectControl, ObjectPreview);
|
||||||
registry.registerWidget('unknown', UnknownControl, UnknownPreview);
|
registry.registerWidget('unknown', UnknownControl, UnknownPreview);
|
||||||
|
|
||||||
export function resolveWidget(name) {
|
export function resolveWidget(name) {
|
||||||
|
72
src/components/Widgets/ListControl.css
Normal file
72
src/components/Widgets/ListControl.css
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
:global(.list-item-dragging) {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.addButton {
|
||||||
|
display: block;
|
||||||
|
cursor: pointer;
|
||||||
|
margin: 20px 0;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
&::before {
|
||||||
|
content: "+";
|
||||||
|
display: inline-block;
|
||||||
|
margin-right: 5px;
|
||||||
|
width: 15px;
|
||||||
|
height: 15px;
|
||||||
|
border: 1px solid #444;
|
||||||
|
border-radius: 100%;
|
||||||
|
background: transparent;
|
||||||
|
line-height: 13px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.removeButton {
|
||||||
|
position: absolute;
|
||||||
|
top: 5px;
|
||||||
|
right: 5px;
|
||||||
|
display: inline-block;
|
||||||
|
cursor: pointer;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
width: 15px;
|
||||||
|
height: 15px;
|
||||||
|
border: 1px solid #444;
|
||||||
|
border-radius: 100%;
|
||||||
|
line-height: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggleButton {
|
||||||
|
position: absolute;
|
||||||
|
top: 5px;
|
||||||
|
left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item {
|
||||||
|
position: relative;
|
||||||
|
padding-left: 20px;
|
||||||
|
cursor: move;
|
||||||
|
}
|
||||||
|
|
||||||
|
.objectLabel {
|
||||||
|
border: 1px solid #e8eae8;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
padding: 20px;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.objectControl {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.expanded {
|
||||||
|
}
|
||||||
|
|
||||||
|
.collapsed {
|
||||||
|
& .objectLabel {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
& .objectControl {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,132 @@
|
|||||||
import React, { Component, PropTypes } from 'react';
|
import React, { Component, PropTypes } from 'react';
|
||||||
|
import { List, Map, fromJS } from 'immutable';
|
||||||
|
import { sortable } from 'react-sortable';
|
||||||
|
import ObjectControl from './ObjectControl';
|
||||||
|
import styles from './ListControl.css';
|
||||||
|
|
||||||
|
function ListItem(props) {
|
||||||
|
return <div {...props} className={`list-item ${ props.className }`}>{props.children}</div>;
|
||||||
|
}
|
||||||
|
ListItem.propTypes = {
|
||||||
|
className: PropTypes.string,
|
||||||
|
children: PropTypes.node,
|
||||||
|
};
|
||||||
|
ListItem.displayName = 'list-item';
|
||||||
|
|
||||||
|
const SortableListItem = sortable(ListItem);
|
||||||
|
|
||||||
export default class ListControl extends Component {
|
export default class ListControl extends Component {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
onChange: PropTypes.func.isRequired,
|
onChange: PropTypes.func.isRequired,
|
||||||
value: PropTypes.node,
|
value: PropTypes.node,
|
||||||
|
field: PropTypes.node,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = { itemStates: Map() };
|
||||||
|
}
|
||||||
|
|
||||||
handleChange = (e) => {
|
handleChange = (e) => {
|
||||||
this.props.onChange(e.target.value.split(',').map(item => item.trim()));
|
this.props.onChange(e.target.value.split(',').map(item => item.trim()));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
handleAdd = (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const { value, onChange } = this.props;
|
||||||
|
|
||||||
|
onChange((value || List()).push(Map()));
|
||||||
|
};
|
||||||
|
|
||||||
|
handleChangeFor(index) {
|
||||||
|
return (newValue) => {
|
||||||
|
const { value, onChange } = this.props;
|
||||||
|
onChange(value.set(index, newValue));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
handleRemove(index) {
|
||||||
|
return (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const { value, onChange } = this.props;
|
||||||
|
onChange(value.remove(index));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
handleToggle(index) {
|
||||||
|
return (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const { itemStates } = this.state;
|
||||||
|
this.setState({
|
||||||
|
itemStates: itemStates.setIn([index, 'collapsed'], !itemStates.getIn([index, 'collapsed'])),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
objectLabel(item) {
|
||||||
|
const { field } = this.props;
|
||||||
|
const fields = field.get('fields');
|
||||||
|
const first = fields.first();
|
||||||
|
const value = item.get(first.get('name'));
|
||||||
|
return value || `No ${ first.get('name') }`;
|
||||||
|
}
|
||||||
|
|
||||||
|
handleSort = (obj) => {
|
||||||
|
this.setState({ draggingIndex: obj.draggingIndex });
|
||||||
|
if ('items' in obj) {
|
||||||
|
this.props.onChange(fromJS(obj.items));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
renderItem(item, index) {
|
||||||
|
const { value, field, getMedia, onAddMedia, onRemoveMedia } = this.props;
|
||||||
|
const { itemStates, draggedItem } = this.state;
|
||||||
|
const collapsed = itemStates.getIn([index, 'collapsed']);
|
||||||
|
const classNames = [styles.item, collapsed ? styles.collapsed : styles.expanded];
|
||||||
|
|
||||||
|
return (<SortableListItem
|
||||||
|
key={index}
|
||||||
|
updateState={this.handleSort}
|
||||||
|
items={value ? value.toJS() : []}
|
||||||
|
draggingIndex={this.state.draggingIndex}
|
||||||
|
sortId={index}
|
||||||
|
outline="list"
|
||||||
|
>
|
||||||
|
<div className={classNames.join(' ')}>
|
||||||
|
<div className={styles.objectLabel}>{this.objectLabel(item)}</div>
|
||||||
|
<div className={styles.objectControl}>
|
||||||
|
<ObjectControl
|
||||||
|
value={item}
|
||||||
|
field={field}
|
||||||
|
onChange={this.handleChangeFor(index)}
|
||||||
|
getMedia={getMedia}
|
||||||
|
onAddMedia={onAddMedia}
|
||||||
|
onRemoveMedia={onRemoveMedia}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<button className={styles.toggleButton} onClick={this.handleToggle(index)}>
|
||||||
|
{collapsed ? '+' : '-'}
|
||||||
|
</button>
|
||||||
|
<button className={styles.removeButton} onClick={this.handleRemove(index)}>x</button>
|
||||||
|
</div>
|
||||||
|
</SortableListItem>);
|
||||||
|
}
|
||||||
|
|
||||||
|
renderListControl() {
|
||||||
|
const { value, field } = this.props;
|
||||||
|
return (<div>
|
||||||
|
{value && value.map((item, index) => this.renderItem(item, index))}
|
||||||
|
<div><button className={styles.addButton} onClick={this.handleAdd}>new</button></div>
|
||||||
|
</div>);
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { value } = this.props;
|
const { value, field } = this.props;
|
||||||
|
|
||||||
|
if (field.get('fields')) {
|
||||||
|
return this.renderListControl();
|
||||||
|
}
|
||||||
|
|
||||||
return <input type="text" value={value ? value.join(', ') : ''} onChange={this.handleChange} />;
|
return <input type="text" value={value ? value.join(', ') : ''} onChange={this.handleChange} />;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,33 @@
|
|||||||
import React, { PropTypes } from 'react';
|
import React, { PropTypes, Component } from 'react';
|
||||||
|
import { resolveWidget } from '../Widgets';
|
||||||
|
|
||||||
export default function ListPreview({ value }) {
|
export default class ObjectPreview extends Component {
|
||||||
return (<ul>
|
widgetFor = (field, value) => {
|
||||||
{ value && value.map(item => <li key={item}>{item}</li>) }
|
const { getMedia } = this.props;
|
||||||
</ul>);
|
const widget = resolveWidget(field.get('widget'));
|
||||||
|
return (<div key={field.get('name')}>{React.createElement(widget.preview, {
|
||||||
|
key: field.get('name'),
|
||||||
|
value: value && value.get(field.get('name')),
|
||||||
|
field,
|
||||||
|
getMedia,
|
||||||
|
})}</div>);
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { field, value } = this.props;
|
||||||
|
const fields = field && field.get('fields');
|
||||||
|
if (fields) {
|
||||||
|
return value ? (<div>{value.map((val, index) => <div key={index}>
|
||||||
|
{fields && fields.map(f => this.widgetFor(f, val))}
|
||||||
|
</div>)}</div>) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value ? value.join(', ') : null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ListPreview.propTypes = {
|
ObjectPreview.propTypes = {
|
||||||
value: PropTypes.node,
|
value: PropTypes.node,
|
||||||
|
field: PropTypes.node,
|
||||||
|
getMedia: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
left: -18px;
|
left: -18px;
|
||||||
display: none;
|
display: none;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
z-index: 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.visible {
|
.visible {
|
||||||
|
@ -65,18 +65,17 @@ function getCleanPaste(e) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const buildtInPlugins = fromJS([{
|
const buildtInPlugins = [{
|
||||||
label: 'Image',
|
label: 'Image',
|
||||||
id: 'image',
|
id: 'image',
|
||||||
fromBlock: (data) => {
|
fromBlock: match => match && {
|
||||||
const m = data.match(/^!\[([^\]]+)\]\(([^\)]+)\)$/);
|
image: match[2],
|
||||||
return m && {
|
alt: match[1],
|
||||||
image: m[2],
|
|
||||||
alt: m[1],
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
toBlock: data => ``,
|
toBlock: data => ``,
|
||||||
toPreview: data => `<img src="${ data.image }" alt="${ data.alt }" />`,
|
toPreview: (data) => {
|
||||||
|
return <img src={data.image} alt={data.alt} />;
|
||||||
|
},
|
||||||
pattern: /^!\[([^\]]+)\]\(([^\)]+)\)$/,
|
pattern: /^!\[([^\]]+)\]\(([^\)]+)\)$/,
|
||||||
fields: [{
|
fields: [{
|
||||||
label: 'Image',
|
label: 'Image',
|
||||||
@ -86,18 +85,20 @@ const buildtInPlugins = fromJS([{
|
|||||||
label: 'Alt Text',
|
label: 'Alt Text',
|
||||||
name: 'alt',
|
name: 'alt',
|
||||||
}],
|
}],
|
||||||
}]);
|
}];
|
||||||
|
buildtInPlugins.forEach(plugin => registry.registerEditorComponent(plugin));
|
||||||
|
|
||||||
export default class RawEditor extends React.Component {
|
export default class RawEditor extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
const plugins = registry.getEditorComponents();
|
const plugins = registry.getEditorComponents();
|
||||||
this.state = {
|
this.state = {
|
||||||
plugins: buildtInPlugins.concat(plugins),
|
plugins: plugins,
|
||||||
};
|
};
|
||||||
this.shortcuts = {
|
this.shortcuts = {
|
||||||
meta: {
|
meta: {
|
||||||
b: this.handleBold,
|
b: this.handleBold,
|
||||||
|
i: this.handleItalic,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -160,7 +161,7 @@ export default class RawEditor extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
replaceSelection(chars) {
|
replaceSelection(chars) {
|
||||||
const { value } = this.props;
|
const value = this.props.value || '';
|
||||||
const selection = this.getSelection();
|
const selection = this.getSelection();
|
||||||
const newSelection = Object.assign({}, selection);
|
const newSelection = Object.assign({}, selection);
|
||||||
const beforeSelection = value.substr(0, selection.start);
|
const beforeSelection = value.substr(0, selection.start);
|
||||||
@ -171,7 +172,7 @@ export default class RawEditor extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toggleHeader(header) {
|
toggleHeader(header) {
|
||||||
const { value } = this.props;
|
const value = this.props.value || '';
|
||||||
const selection = this.getSelection();
|
const selection = this.getSelection();
|
||||||
const newSelection = Object.assign({}, selection);
|
const newSelection = Object.assign({}, selection);
|
||||||
const lastNewline = value.lastIndexOf('\n', selection.start);
|
const lastNewline = value.lastIndexOf('\n', selection.start);
|
||||||
@ -233,7 +234,7 @@ export default class RawEditor extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
handleSelection = () => {
|
handleSelection = () => {
|
||||||
const { value } = this.props;
|
const value = this.props.value || '';
|
||||||
const selection = this.getSelection();
|
const selection = this.getSelection();
|
||||||
if (selection.start !== selection.end && !HAS_LINE_BREAK.test(selection.selected)) {
|
if (selection.start !== selection.end && !HAS_LINE_BREAK.test(selection.selected)) {
|
||||||
try {
|
try {
|
||||||
|
16
src/components/Widgets/NumberControl.js
Normal file
16
src/components/Widgets/NumberControl.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import React, { PropTypes } from 'react';
|
||||||
|
|
||||||
|
export default class StringControl extends React.Component {
|
||||||
|
handleChange = e => {
|
||||||
|
this.props.onChange(e.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return <input type="number" value={this.props.value || ''} onChange={this.handleChange}/>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StringControl.propTypes = {
|
||||||
|
onChange: PropTypes.func.isRequired,
|
||||||
|
value: PropTypes.node,
|
||||||
|
};
|
9
src/components/Widgets/NumberPreview.js
Normal file
9
src/components/Widgets/NumberPreview.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import React, { PropTypes } from 'react';
|
||||||
|
|
||||||
|
export default function StringPreview({ value }) {
|
||||||
|
return <span>{value}</span>;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringPreview.propTypes = {
|
||||||
|
value: PropTypes.node,
|
||||||
|
};
|
6
src/components/Widgets/ObjectControl.css
Normal file
6
src/components/Widgets/ObjectControl.css
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
.root {
|
||||||
|
position: relative;
|
||||||
|
border: 1px solid #e8eae8;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
52
src/components/Widgets/ObjectControl.js
Normal file
52
src/components/Widgets/ObjectControl.js
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
import React, { Component, PropTypes } from 'react';
|
||||||
|
import { Map } from 'immutable';
|
||||||
|
import { resolveWidget } from '../Widgets';
|
||||||
|
import controlStyles from '../ControlPanel/ControlPane.css';
|
||||||
|
import styles from './ObjectControl.css';
|
||||||
|
|
||||||
|
export default class ObjectControl extends Component {
|
||||||
|
static propTypes = {
|
||||||
|
onChange: PropTypes.func.isRequired,
|
||||||
|
onAddMedia: PropTypes.func.isRequired,
|
||||||
|
getMedia: PropTypes.func.isRequired,
|
||||||
|
value: PropTypes.node,
|
||||||
|
field: PropTypes.node,
|
||||||
|
};
|
||||||
|
|
||||||
|
controlFor(field) {
|
||||||
|
const { onAddMedia, onRemoveMedia, getMedia, value, onChange } = this.props;
|
||||||
|
const widget = resolveWidget(field.get('widget') || 'string');
|
||||||
|
const fieldValue = value && value.get(field.get('name'));
|
||||||
|
|
||||||
|
return (<div className={controlStyles.widget} key={field.get('name')}>
|
||||||
|
<div className={controlStyles.control} key={field.get('name')}>
|
||||||
|
<label className={controlStyles.label}>{field.get('label')}</label>
|
||||||
|
{
|
||||||
|
React.createElement(widget.control, {
|
||||||
|
field,
|
||||||
|
value: fieldValue,
|
||||||
|
onChange: (val) => {
|
||||||
|
onChange((value || Map()).set(field.get('name'), val));
|
||||||
|
},
|
||||||
|
onAddMedia,
|
||||||
|
onRemoveMedia,
|
||||||
|
getMedia,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>);
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { field } = this.props;
|
||||||
|
const fields = field.get('fields');
|
||||||
|
|
||||||
|
if (!fields) {
|
||||||
|
return <h3>No fields defined for this widget</h3>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (<div className={styles.root}>
|
||||||
|
{field.get('fields').map(field => this.controlFor(field))}
|
||||||
|
</div>);
|
||||||
|
}
|
||||||
|
}
|
28
src/components/Widgets/ObjectPreview.js
Normal file
28
src/components/Widgets/ObjectPreview.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import React, { PropTypes, Component } from 'react';
|
||||||
|
import { resolveWidget } from '../Widgets';
|
||||||
|
|
||||||
|
export default class ObjectPreview extends Component {
|
||||||
|
widgetFor = (field) => {
|
||||||
|
const { value, getMedia } = this.props;
|
||||||
|
const widget = resolveWidget(field.get('widget'));
|
||||||
|
return (<div key={field.get('name')}>{React.createElement(widget.preview, {
|
||||||
|
key: field.get('name'),
|
||||||
|
value: value && value.get(field.get('name')),
|
||||||
|
field,
|
||||||
|
getMedia,
|
||||||
|
})}</div>);
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { field } = this.props;
|
||||||
|
const fields = field && field.get('fields');
|
||||||
|
|
||||||
|
return <div>{fields && fields.map(f => this.widgetFor(f))}</div>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectPreview.propTypes = {
|
||||||
|
value: PropTypes.node,
|
||||||
|
field: PropTypes.node,
|
||||||
|
getMedia: PropTypes.func.isRequired,
|
||||||
|
};
|
@ -12,7 +12,7 @@ import {
|
|||||||
import { cancelEdit } from '../actions/editor';
|
import { cancelEdit } from '../actions/editor';
|
||||||
import { addMedia, removeMedia } from '../actions/media';
|
import { addMedia, removeMedia } from '../actions/media';
|
||||||
import { selectEntry, getMedia } from '../reducers';
|
import { selectEntry, getMedia } from '../reducers';
|
||||||
import { FOLDER, FILES } from '../constants/collectionTypes';
|
import Collection from '../valueObjects/Collection';
|
||||||
import EntryEditor from '../components/EntryEditor/EntryEditor';
|
import EntryEditor from '../components/EntryEditor/EntryEditor';
|
||||||
import entryPageHOC from './editorialWorkflow/EntryPageHOC';
|
import entryPageHOC from './editorialWorkflow/EntryPageHOC';
|
||||||
import { Loader } from '../components/UI';
|
import { Loader } from '../components/UI';
|
||||||
@ -39,11 +39,10 @@ class EntryPage extends React.Component {
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { entry, newEntry, collection, slug, createEmptyDraft, loadEntry } = this.props;
|
const { entry, newEntry, collection, slug, createEmptyDraft, loadEntry } = this.props;
|
||||||
|
|
||||||
if (newEntry) {
|
if (newEntry) {
|
||||||
createEmptyDraft(collection);
|
createEmptyDraft(collection);
|
||||||
} else {
|
} else {
|
||||||
if (collection.get('type') === FOLDER) loadEntry(entry, collection, slug);
|
loadEntry(entry, collection, slug);
|
||||||
this.createDraft(entry);
|
this.createDraft(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,15 +107,7 @@ function mapStateToProps(state, ownProps) {
|
|||||||
const { collections, entryDraft } = state;
|
const { collections, entryDraft } = state;
|
||||||
const slug = ownProps.params.slug;
|
const slug = ownProps.params.slug;
|
||||||
const collection = collections.get(ownProps.params.name);
|
const collection = collections.get(ownProps.params.name);
|
||||||
|
const collectionModel = new Collection(collection);
|
||||||
let fields;
|
|
||||||
if (collection.get('type') === FOLDER) {
|
|
||||||
fields = collection.get('fields');
|
|
||||||
} else {
|
|
||||||
const files = collection.get('files');
|
|
||||||
const file = files.filter(f => f.get('name') === slug);
|
|
||||||
fields = file.getIn([0, 'fields']);
|
|
||||||
}
|
|
||||||
const newEntry = ownProps.route && ownProps.route.newRecord === true;
|
const newEntry = ownProps.route && ownProps.route.newRecord === true;
|
||||||
|
|
||||||
const entry = newEntry ? null : selectEntry(state, collection.get('name'), slug);
|
const entry = newEntry ? null : selectEntry(state, collection.get('name'), slug);
|
||||||
@ -127,7 +118,7 @@ function mapStateToProps(state, ownProps) {
|
|||||||
newEntry,
|
newEntry,
|
||||||
entryDraft,
|
entryDraft,
|
||||||
boundGetMedia,
|
boundGetMedia,
|
||||||
fields,
|
fields: collectionModel.entryFields(slug),
|
||||||
slug,
|
slug,
|
||||||
entry,
|
entry,
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import YAML from './yaml';
|
import YAML from './yaml';
|
||||||
|
import JSONFormatter from './json';
|
||||||
import YAMLFrontmatter from './yaml-frontmatter';
|
import YAMLFrontmatter from './yaml-frontmatter';
|
||||||
|
|
||||||
const yamlFormatter = new YAML();
|
const yamlFormatter = new YAML();
|
||||||
|
const jsonFormatter = new JSONFormatter();
|
||||||
const YamlFrontmatterFormatter = new YAMLFrontmatter();
|
const YamlFrontmatterFormatter = new YAMLFrontmatter();
|
||||||
|
|
||||||
function formatByType(type) {
|
function formatByType(type) {
|
||||||
@ -12,17 +14,18 @@ function formatByType(type) {
|
|||||||
|
|
||||||
function formatByExtension(extension) {
|
function formatByExtension(extension) {
|
||||||
return {
|
return {
|
||||||
'yml': yamlFormatter,
|
yml: yamlFormatter,
|
||||||
'md': YamlFrontmatterFormatter,
|
json: jsonFormatter,
|
||||||
'markdown': YamlFrontmatterFormatter,
|
md: YamlFrontmatterFormatter,
|
||||||
'html': YamlFrontmatterFormatter
|
markdown: YamlFrontmatterFormatter,
|
||||||
|
html: YamlFrontmatterFormatter,
|
||||||
}[extension] || YamlFrontmatterFormatter;
|
}[extension] || YamlFrontmatterFormatter;
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatByName(name) {
|
function formatByName(name) {
|
||||||
return {
|
return {
|
||||||
'yaml': yamlFormatter,
|
yaml: yamlFormatter,
|
||||||
'frontmatter': YamlFrontmatterFormatter
|
frontmatter: YamlFrontmatterFormatter,
|
||||||
}[name] || YamlFrontmatterFormatter;
|
}[name] || YamlFrontmatterFormatter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,8 +33,9 @@ export function resolveFormat(collectionOrEntity, entry) {
|
|||||||
if (typeof collectionOrEntity === 'string') {
|
if (typeof collectionOrEntity === 'string') {
|
||||||
return formatByType(collectionOrEntity);
|
return formatByType(collectionOrEntity);
|
||||||
}
|
}
|
||||||
if (entry && entry.path) {
|
const path = entry && entry.path;
|
||||||
return formatByExtension(entry.path.split('.').pop());
|
if (path) {
|
||||||
|
return formatByExtension(path.split('.').pop());
|
||||||
}
|
}
|
||||||
return formatByName(collectionOrEntity.get('format'));
|
return formatByName(collectionOrEntity.get('format'));
|
||||||
}
|
}
|
||||||
|
9
src/formats/json.js
Normal file
9
src/formats/json.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
export default class JSONFormatter {
|
||||||
|
fromFile(content) {
|
||||||
|
return JSON.parse(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
toFile(data) {
|
||||||
|
return JSON.stringify(data);
|
||||||
|
}
|
||||||
|
}
|
@ -34,7 +34,6 @@ if (process.env.NODE_ENV !== 'production' && module.hot) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.CMS = {};
|
window.CMS = {};
|
||||||
console.log('reg: ', registry);
|
|
||||||
for (const method in registry) {
|
for (const method in registry) {
|
||||||
window.CMS[method] = registry[method];
|
window.CMS[method] = registry[method];
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { createEntry } from '../../../valueObjects/Entry';
|
import { createEntry } from '../../../valueObjects/Entry';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import Collection from '../../../valueObjects/Collection';
|
||||||
|
|
||||||
function getSlug(path) {
|
function getSlug(path) {
|
||||||
const m = path.match(/([^\/]+?)(\.[^\/\.]+)?$/);
|
const m = path.match(/([^\/]+?)(\.[^\/\.]+)?$/);
|
||||||
@ -101,11 +102,12 @@ export default class Algolia {
|
|||||||
if (this.entriesCache.collection === collection && this.entriesCache.page === page) {
|
if (this.entriesCache.collection === collection && this.entriesCache.page === page) {
|
||||||
return Promise.resolve({ page: this.entriesCache.page, entries: this.entriesCache.entries });
|
return Promise.resolve({ page: this.entriesCache.page, entries: this.entriesCache.entries });
|
||||||
} else {
|
} else {
|
||||||
|
const collectionModel = new Collection(collection);
|
||||||
return this.request(`${ this.searchURL }/indexes/${ collection.get('name') }`, {
|
return this.request(`${ this.searchURL }/indexes/${ collection.get('name') }`, {
|
||||||
params: { page },
|
params: { page },
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
const entries = response.hits.map((hit) => {
|
const entries = response.hits.map((hit) => {
|
||||||
const slug = hit.slug || getSlug(hit.path);
|
const slug = collectionModel.entrySlug(hit.path);
|
||||||
return createEntry(collection.get('name'), slug, hit.path, { data: hit.data, partial: true });
|
return createEntry(collection.get('name'), slug, hit.path, { data: hit.data, partial: true });
|
||||||
});
|
});
|
||||||
this.entriesCache = { collection, pagination: response.page, entries };
|
this.entriesCache = { collection, pagination: response.page, entries };
|
||||||
|
@ -31,7 +31,6 @@ const entries = (state = Map({ entities: Map(), pages: Map() }), action) => {
|
|||||||
collection = action.payload.collection;
|
collection = action.payload.collection;
|
||||||
loadedEntries = action.payload.entries;
|
loadedEntries = action.payload.entries;
|
||||||
page = action.payload.page;
|
page = action.payload.page;
|
||||||
|
|
||||||
return state.withMutations((map) => {
|
return state.withMutations((map) => {
|
||||||
loadedEntries.forEach(entry => (
|
loadedEntries.forEach(entry => (
|
||||||
map.setIn(['entities', `${ collection }.${ entry.slug }`], fromJS(entry).set('isFetching', false))
|
map.setIn(['entities', `${ collection }.${ entry.slug }`], fromJS(entry).set('isFetching', false))
|
||||||
|
121
src/valueObjects/Collection.js
Normal file
121
src/valueObjects/Collection.js
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
import { FOLDER, FILES } from '../constants/collectionTypes';
|
||||||
|
|
||||||
|
function formatToExtension(format) {
|
||||||
|
return {
|
||||||
|
markdown: 'md',
|
||||||
|
yaml: 'yml',
|
||||||
|
json: 'json',
|
||||||
|
html: 'html',
|
||||||
|
}[format];
|
||||||
|
}
|
||||||
|
|
||||||
|
class FolderCollection {
|
||||||
|
constructor(collection) {
|
||||||
|
this.collection = collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
entryFields() {
|
||||||
|
return this.collection.get('fields');
|
||||||
|
}
|
||||||
|
|
||||||
|
entryPath(slug) {
|
||||||
|
return `${ this.collection.get('folder') }/${ slug }.${ this.entryExtension() }`;
|
||||||
|
}
|
||||||
|
|
||||||
|
entrySlug(path) {
|
||||||
|
return path.split('/').pop().replace(/\.[^\.]+$/, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
listMethod() {
|
||||||
|
return 'entriesByFolder';
|
||||||
|
}
|
||||||
|
|
||||||
|
entryExtension() {
|
||||||
|
return this.collection.get('extension') || formatToExtension(this.collection.get('format') || 'markdown');
|
||||||
|
}
|
||||||
|
|
||||||
|
allowNewEntries() {
|
||||||
|
return this.collection.get('create');
|
||||||
|
}
|
||||||
|
|
||||||
|
templateName() {
|
||||||
|
return this.collection.get('name');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FilesCollection {
|
||||||
|
constructor(collection) {
|
||||||
|
this.collection = collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
entryFields(slug) {
|
||||||
|
const file = this.fileForEntry(slug);
|
||||||
|
return file && file.get('fields');
|
||||||
|
}
|
||||||
|
|
||||||
|
entryPath(slug) {
|
||||||
|
const file = this.fileForEntry(slug);
|
||||||
|
return file && file.get('file');
|
||||||
|
}
|
||||||
|
|
||||||
|
entrySlug(path) {
|
||||||
|
const file = this.collection.get('files').filter(f => f.get('file') === path).get(0);
|
||||||
|
return file && file.get('name');
|
||||||
|
}
|
||||||
|
|
||||||
|
fileForEntry(slug) {
|
||||||
|
const files = this.collection.get('files');
|
||||||
|
return files.filter(f => f.get('name') === slug).get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
listMethod() {
|
||||||
|
return 'entriesByFiles';
|
||||||
|
}
|
||||||
|
|
||||||
|
allowNewEntries() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
templateName(slug) {
|
||||||
|
return slug;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Collection {
|
||||||
|
constructor(collection) {
|
||||||
|
switch (collection.get('type')) {
|
||||||
|
case FOLDER:
|
||||||
|
this.collection = new FolderCollection(collection);
|
||||||
|
break;
|
||||||
|
case FILES:
|
||||||
|
this.collection = new FilesCollection(collection);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw ('Unknown collection type: %o', collection.get('type'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
entryFields(slug) {
|
||||||
|
return this.collection.entryFields(slug);
|
||||||
|
}
|
||||||
|
|
||||||
|
entryPath(slug) {
|
||||||
|
return this.collection.entryPath(slug);
|
||||||
|
}
|
||||||
|
|
||||||
|
entrySlug(path) {
|
||||||
|
return this.collection.entrySlug(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
listMethod() {
|
||||||
|
return this.collection.listMethod();
|
||||||
|
}
|
||||||
|
|
||||||
|
allowNewEntries() {
|
||||||
|
return this.collection.allowNewEntries();
|
||||||
|
}
|
||||||
|
|
||||||
|
templateName(slug) {
|
||||||
|
return this.collection.templateName(slug);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user