Skip to content
This repository has been archived by the owner on Jun 1, 2019. It is now read-only.

Commit

Permalink
relocate docs content to cms-www repo
Browse files Browse the repository at this point in the history
  • Loading branch information
erquhart committed Nov 27, 2017
1 parent ef8cf9f commit 8f7e9f2
Show file tree
Hide file tree
Showing 20 changed files with 998 additions and 302 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ dist/
.DS_Store
node_modules
npm-debug.log
yarn-error.log
7 changes: 2 additions & 5 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,15 @@ import BrowserSync from "browser-sync";
import webpack from "webpack";
import webpackConfig from "./webpack.conf";

import markWithMagic from './markdown.config.js';

const browserSync = BrowserSync.create();
const hugoBin = "hugo";
const defaultArgs = ["-d", "../dist", "-s", "site", "-v"];

gulp.task("hugo", (cb) => buildSite(cb));
gulp.task("hugo-preview", (cb) => buildSite(cb, ["--buildDrafts", "--buildFuture"]));
gulp.task("docs", (cb) => markWithMagic())

gulp.task("build", ["css", "docs", "js", "fonts", "images", "hugo"]);
gulp.task("build-preview", ["css", "docs", "js", "fonts", "images", "hugo-preview"]);
gulp.task("build", ["css", "js", "fonts", "images", "hugo"]);
gulp.task("build-preview", ["css", "js", "fonts", "images", "hugo-preview"]);

gulp.task("css", () => (
gulp.src("./src/css/**/*.css")
Expand Down
33 changes: 0 additions & 33 deletions markdown.config.js

This file was deleted.

7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"build": "gulp build",
"build-preview": "gulp build-preview",
"start": "gulp server",
"lint": "eslint src",
"docs": "node markdown.config.js"
"lint": "eslint src"
},
"author": "",
"license": "MIT",
Expand Down Expand Up @@ -49,7 +48,5 @@
"whatwg-fetch": "^1.0.0",
"yamljs": "^0.2.8"
},
"devDependencies": {
"markdown-magic": "^0.1.13"
}
"devDependencies": {}
}
62 changes: 60 additions & 2 deletions site/content/docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,64 @@
title: Architecture
position: 9
---
<!-- AUTO-GENERATED-CONTENT:START (REMOTE:url=https://raw.githubusercontent.com/netlify/netlify-cms/master/docs/architecture.md) -->

<!-- AUTO-GENERATED-CONTENT:END -->
# Technical Architecture

Netlify CMS is a React application, using Redux for state management with immutable data structures (immutable.js).

The core abstractions for content editing are `collections`, `entries` and `widgets`.

Each `collection` represents a collection of entries. This can either be a collection of similar entries with the same structure, or a set of entries where each has its own structure.

The structure of an entry is defined as a series of fields, each with a `name`, a `label`, and a `widget` .

The `widget` determines the UI widget that the content editor will use when editing this field of an entry, as well as how the content of the field is presented in the editing preview.

Entries are loaded and persisted through a `backend` that will typically represent a `git` repository.

## State shape / reducers
**Auth:** Keeps track of the logged state and the current user.

**Config:** Holds the environment configuration (backend type, available collections and fields).

**Collections** List of available collections, their fields and metadata information.

**Entries:** Entries for each field.

**EntryDraft:** Reused for each entry that is edited or created. It holds the entry's temporary data until it's persisted on the backend.

**Medias:** Keeps references to all media files uploaded by the user during the current session.

## Selectors
Selectors are functions defined within reducers used to compute derived data from the Redux store. The available selectors are:

**selectEntry:** Selects a single entry, given the collection and a slug.

**selectEntries:** Selects all entries for a given collection.

**getAsset:** Selects a single AssetProxy object for the given URI.

## Value Objects
**AssetProxy:** AssetProxy is a Value Object that holds information regarding an asset file (such as an image, for example), whether it's persisted online or held locally in cache.

For a file persisted online, the AssetProxy only keeps information about its URI. For local files, the AssetProxy will keep a reference to the actual File object while generating the expected final URIs and on-demand blobs for local preview.

The AssetProxy object can be used directly inside a media tag (such as `<img>`), as it will always return something that can be used by the media tag to render correctly (either the URI for the online file or a single-use blob).

## Components structure and Workflows
Components are separated into two main categories: Container components and Presentational components.

### Entry Editing
For either updating an existing entry or creating a new one, the `EntryEditor` is used and the flow is the same:
* When mounted, the `EntryPage` container component dispatches the `createDraft` action, setting the `entryDraft` state to a blank state (in case of a new entry) or to a copy of the selected entry (in case of an edit).
* The `EntryPage` will also render widgets for each field type in the given entry.
* Widgets are used for editing entry fields. There are different widgets for different field types, and they are always defined in a pair containing a `control` and a `preview` component. The control component is responsible for presenting the user with the appropriate interface for manipulating the current field value, while the preview component is responsible for displaying the value with the appropriate styling.

#### Widget components implementation
The control component receives three (3) callbacks as props: `onChange`, `onAddAsset`, and `onRemoveAsset`.
* onChange (required): Should be called when the users changes the current value. It will ultimately end up updating the EntryDraft object in the Redux Store, thus updating the preview component.
* onAddAsset & onRemoveAsset (optionals): If the field accepts file uploads for media (images, for example), these callbacks should be invoked with a `AssetProxy` value object. `onAddAsset` will get the current media stored in the Redux state tree while `onRemoveAsset` will remove it. AssetProxy objects are stored in the `Medias` object and referenced in the `EntryDraft` object on the state tree.

Both control and preview widgets receive a `getAsset` selector via props. Displaying the media (or its URI) for the user should always be done via `getAsset`, as it returns an AssetProxy that can return the correct value for both medias already persisted on the server and cached media not yet uploaded.

The actual persistence of the content and medias inserted into the control component is delegated to the backend implementation. The backend will be called with the updated values and a list of assetProxy objects for each field of the entry, and should return a promise that can resolve into the persisted entry object and the list of the persisted media URIs.
11 changes: 9 additions & 2 deletions site/content/docs/contributor-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
title: Contributing
position: 10
---
<!-- AUTO-GENERATED-CONTENT:START (REMOTE:url=https://raw.githubusercontent.com/netlify/netlify-cms/master/docs/contributor-guide.md) -->

<!-- AUTO-GENERATED-CONTENT:END -->
# Welcome, contributors!

We're hoping that Netlify CMS will do for the [JAMstack](https://www.jamstack.org) what WordPress did for dynamic sites back in the day. We know we can't do that without building a thriving community of contributors and users, and we'd love to have you join us.

While we work on building this page (and you can help!), here are some links with more information about getting involved:

* [Project Milestones](https://github.com/netlify/netlify-cms/milestones)
* [Code of Conduct](https://github.com/netlify/netlify-cms/blob/master/CODE_OF_CONDUCT.md)
* [Setup instructions and Contribution Guidelines](https://github.com/netlify/netlify-cms/blob/master/CONTRIBUTING.md)
35 changes: 33 additions & 2 deletions site/content/docs/custom-authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,37 @@
title: Custom Authentication
position: 8
---
<!-- AUTO-GENERATED-CONTENT:START (REMOTE:url=https://raw.githubusercontent.com/netlify/netlify-cms/master/docs/custom-authentication.md) -->

<!-- AUTO-GENERATED-CONTENT:END -->
# Custom Authentication

Netlify CMS is meant to be platform agnostic, so we're always looking to expand the ecosystem and find new ways to use it. Below is a list of currently submitted OAuth providers - feel free to [submit a pull request](https://github.com/netlify/netlify-cms/blob/master/CONTRIBUTING.md) if you'd like to add yours!

## External OAuth Clients:
| Author | Supported Git hosts | Languages | Link |
|------------|---------------------------|-----------|---------------------------------------------------------------------|
| @vencax | GitHub, GitHub Enterprise | Node.js | [Repo](https://github.com/vencax/netlify-cms-github-oauth-provider) |

Check each project's readme for instructions on how to configure it.

## Configuration
CMS configuration properties that affect authentication, including some optional properties that aren't mentioned elsewhere in the docs, are explained below:

```yaml
backend:

# REQUIRED CONFIG
name: github
repo: user/repository

# OPTIONAL CONFIG
# Note: no trailing slashes on URLs
api_root: https://github.some.domain.com/api/v3
site_domain: static.site.url.com
base_url: https://auth.server.url.com
```
* **name:** name of the auth provider, varies by implementation. `github` when using GitHub auth, even with a third party auth client.
* **repo:** repo where content is to be stored.
* **api_root (optional):** the API endpoint. Defaults to `https://api.github.com` when used with the `github` provider. Only necessary in certain cases, e.g., when using with GitHub Enterprise.
* **site_domain (optional):** sets `site_id` query param sent to API endpoint. Defaults to `location.hostname`, minus any port, or `cms.netlify.com` on localhost so that auth "just works" during local development. Sites with custom authentication will often need to set this for local development to work properly.
* **base_url (optional):** OAuth client URL, defaults to `https://api.netlify.com` as a convenience. This is **required** when using an external OAuth server.
Loading

0 comments on commit 8f7e9f2

Please sign in to comment.