Skip to content

Commit ddbe66b

Browse files
committed
Merge branch 'master' of https://github.com/jekyll/jekyll-admin into jekyll-master
2 parents 5c94ae5 + d6cc68a commit ddbe66b

File tree

186 files changed

+8669
-5253
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

186 files changed

+8669
-5253
lines changed

.rubocop.yml

+11
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,16 @@ AllCops:
1212
Metrics/BlockLength:
1313
Enabled: false
1414

15+
Metrics/PerceivedComplexity:
16+
Max: 9
17+
1518
Style/FrozenStringLiteralComment:
1619
Enabled: false
20+
21+
Naming/MemoizedInstanceVariableName:
22+
Exclude:
23+
- lib/jekyll-admin/page_without_a_file.rb
24+
25+
Naming/UncommunicativeMethodParamName:
26+
Exclude:
27+
- lib/jekyll-admin/data_file.rb

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright 2017 Mert Kahyaoğlu and the Jekyll Admin contributors
3+
Copyright 2016-present Mert Kahyaoğlu and the Jekyll Admin contributors
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+5-9
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@
44
[![Coverage Status](https://coveralls.io/repos/github/jekyll/jekyll-admin/badge.svg?branch=master)](https://coveralls.io/github/jekyll/jekyll-admin?branch=master)
55
[![NPM Dependencies](https://david-dm.org/jekyll/jekyll-admin.svg)](https://david-dm.org/jekyll/jekyll-admin)
66

7-
A Jekyll plugin that provides users with a traditional CMS-style graphical interface to author content and administer Jekyll sites. The project is divided into two parts. A Ruby-based HTTP API that handles Jekyll and filesystem operations, and a Javascript-based front end, built on that API.
7+
A Jekyll plugin that provides users with a traditional CMS-style graphical interface to author content and administer Jekyll sites. The project is divided into two parts. A Ruby-based HTTP API that handles Jekyll and filesystem operations, and a JavaScript-based front end, built on that API.
88

99
![screenshot of Jekyll Admin](/screenshot.png)
1010

1111
## Installation
1212

1313
Refer to the [installing plugins](https://jekyllrb.com/docs/plugins/#installing-a-plugin) section of Jekyll's documentation and install the `jekyll-admin` plugin as you would any other plugin. Here's the short version:
1414

15-
1. Add the following to your site's Gemfile:
15+
1. Add the following to your site's Gemfile:
1616

1717
```ruby
1818
gem 'jekyll-admin', group: :jekyll_plugins
1919
```
2020

21-
2. Run `bundle install`
21+
2. Run `bundle install`
2222

2323
## Usage
2424

25-
1. Start Jekyll as you would normally (`bundle exec jekyll serve`)
26-
2. Navigate to `http://localhost:4000/admin` to access the administrative interface
25+
1. Start Jekyll as you would normally (`bundle exec jekyll serve`)
26+
2. Navigate to `http://localhost:4000/admin` to access the administrative interface
2727

2828
## Options
2929

@@ -45,10 +45,6 @@ jekyll_admin:
4545

4646
Interested in contributing to Jekyll Admin? We’d love your help. Jekyll Admin is an open source project, built one contribution at a time by users like you. See [the contributing instructions](.github/CONTRIBUTING.md), and [the development docs](http://jekyll.github.io/jekyll-admin/development/) for more information.
4747

48-
## Looking for a hosted version?
49-
50-
Jekyll Admin is intended to be run on your computer alongside your local Jekyll installation. If you're looking for a hosted version, we'd recommend checking out [Siteleaf](https://www.siteleaf.com/) a hosted Jekyll editor with deep GitHub integration (whom we'd also like to thank for inspiring parts of Jekyll Admin itself!).
51-
5248
## License
5349

5450
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).

docs/_config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ collections:
66
permalink: /frontend/:path/
77
output: true
88

9-
gems:
9+
plugins:
1010
- jekyll-seo-tag
1111
- jekyll-sitemap
1212

docs/_frontend/actions.md

+21
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,27 @@ The response includes the document body.
7777

7878
Async action for deleting the document in a directory from disk. After deletion, collection documents are requested.
7979

80+
## Drafts
81+
82+
### `fetchDrafts(directory)`
83+
84+
Async action for fetching an array of drafts in a sub-directory.
85+
86+
### `fetchDraft(directory, filename)`
87+
88+
Async action for fetching the requested draft in a sub-directory.
89+
90+
### `putDraft(mode, directory, filename = '')`
91+
92+
Async action for creating or updating the requested draft. The content comes
93+
from `state.metadata`.
94+
If the path is not provided when `mode` equals `'create'`, it is auto-generated from the `title` metadata.
95+
96+
### `deleteDraft(directory, filename)`
97+
98+
Async action for deleting the requested draft in a sub-directory.
99+
After deletion, draft list is requested.
100+
80101
## Metadata
81102

82103
### `storeContentFields(meta)`

docs/_frontend/containers.md

+64
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,70 @@ Container for creating a new document.
228228
}
229229
```
230230

231+
## Drafts
232+
233+
Container for Drafts view. Lists all drafts and sub-directories at given path.
234+
235+
### PropTypes
236+
237+
```javascript
238+
{
239+
drafts: Array,
240+
fetchDrafts: Function,
241+
deleteDraft: Function,
242+
search: Function,
243+
isFetching: Boolean,
244+
params: Object
245+
}
246+
```
247+
248+
## DraftNew
249+
250+
Container for creating a new draft.
251+
252+
```javascript
253+
{
254+
putDraft: Function,
255+
updateTitle: Function,
256+
updateBody: Function,
257+
updatePath: Function,
258+
updateDraft: Function,
259+
clearErrors: Function,
260+
errors: Array,
261+
fieldChanged: Boolean,
262+
updated: Boolean,
263+
router: Object,
264+
route: Object,
265+
params: Object,
266+
config: Object
267+
}
268+
```
269+
270+
## DraftEdit
271+
272+
Container for editing a draft.
273+
274+
```javascript
275+
{
276+
draft: Object,
277+
fetchDraft: Function,
278+
deleteDraft: Function,
279+
putDraft: Function,
280+
updateTitle: Function,
281+
updateBody: Function,
282+
updatePath: Function,
283+
clearErrors: Function,
284+
isFetching: Boolean,
285+
fieldChanged: Boolean,
286+
updated: Boolean,
287+
errors: Array,
288+
params: Object,
289+
router: Object,
290+
route: Object,
291+
config: Object
292+
}
293+
```
294+
231295
## DataFiles
232296

233297
Container for DataFiles view. Lists data files.

docs/_frontend/reducers.md

+13
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,19 @@ description: Specifies how the application’s state changes in response to acti
4343
}
4444
```
4545

46+
## Drafts
47+
48+
### State
49+
50+
```javascript
51+
{
52+
drafts: Array,
53+
draft: Object, // currently visited draft
54+
isFetching: Boolean, // set to true when the draft is being fetched
55+
updated: Boolean // set to true when the draft is updated
56+
}
57+
```
58+
4659
## Metadata
4760

4861
### State

docs/_includes/sidebar.html

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
<ul class="routes">
1616
<li><a href="{{ "/" | relative_url }}" {% if page.url == '/' %}class="active"{% endif %}>Index</a></li>
17+
<li><a href="{{ "/configs" | relative_url }}" {% if active[1] == 'configs' %}class="active"{% endif %}>Configs</a></li>
1718
<li><a href="{{ "/api" | relative_url }}" {% if active[1] == 'api' %}class="active"{% endif %}>API</a></li>
1819
<li><a href="{{ "/frontend" | relative_url }}" {% if active[1] == 'frontend' %}class="active"{% endif %}>Front End</a>
1920
<ul>

docs/api.md

+145
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,151 @@ Create or update the requested page, writing its contents to disk.
186186

187187
Delete the requested page from disk.
188188

189+
### Drafts
190+
191+
The end-points for drafts are modelled similar to `Pages` even though the resource inherently belongs to a `Posts` collection.
192+
193+
#### Parameters
194+
195+
* `directory` - the *optional* sub-directory for a draft, relative to `_drafts` at the site root (e.g., `draft-dir`) (`String`).
196+
* `filename` - the draft's filename.
197+
* `raw_content` - the drafts's body (`String`)
198+
* `front_matter` - the drafts's YAML front matter (`Object`)
199+
200+
While `path` for a sub-directory, is the same as the parameter `directory` itself, for a draft-file, it is the entire path relative to the site's root
201+
202+
#### `GET /drafts/:directory`
203+
204+
Returns an array of drafts and directories for the requested directory path. If `directory`
205+
is not provided, entries at the root level (`./_drafts/*`) are returned.
206+
207+
The response does not include drafts' body.
208+
209+
##### Example response
210+
211+
```
212+
GET /drafts
213+
```
214+
215+
```json
216+
[
217+
{
218+
"name": "draft-dir",
219+
"modified_time": "2017-09-24 19:08:41 -0400",
220+
"path": "draft-dir",
221+
"type": "directory",
222+
"http_url": null,
223+
"api_url": "http://localhost:4000/_api/drafts/draft-dir"
224+
},
225+
{
226+
"path": "_drafts/draft-post.md",
227+
"id": "/2017/09/24/draft-post",
228+
"url": "/2017/09/24/draft-post.html",
229+
"relative_path": "draft-post.md",
230+
"collection": "posts",
231+
"draft": true,
232+
"categories": [
233+
234+
],
235+
"all": true,
236+
"foo": "bar",
237+
"title": "Draft Post",
238+
"slug": "draft-post",
239+
"ext": ".md",
240+
"tags": [
241+
242+
],
243+
"date": "2017-09-24 18:03:49 -0400",
244+
"http_url": "http://localhost:4000/2017/09/24/draft-post.html",
245+
"api_url": "http://localhost:4000/_api/drafts/draft-post.md",
246+
"name": "draft-post.md"
247+
}
248+
]
249+
```
250+
251+
#### `GET /drafts/:directory/:filename`
252+
253+
Returns the requested draft. The response includes the draft body.
254+
255+
##### Example response
256+
257+
```
258+
GET /drafts/draft-dir/another-draft-post.md
259+
```
260+
261+
```json
262+
{
263+
"next": {
264+
"path": "_drafts/draft-post.md",
265+
"id": "/2017/09/24/draft-post",
266+
"url": "/2017/09/24/draft-post.html",
267+
"relative_path": "draft-post.md",
268+
"collection": "posts",
269+
"draft": true,
270+
"categories": [],
271+
"all": true,
272+
"foo": "bar",
273+
"title": "Draft Post",
274+
"slug": "draft-post",
275+
"ext": ".md",
276+
"tags": [],
277+
"date": "2017-09-24 18:03:49 -0400",
278+
"http_url": "http://localhost:4000/2017/09/24/draft-post.html",
279+
"api_url": "http://localhost:4000/_api/drafts/draft-post.md",
280+
"name": "draft-post.md"
281+
},
282+
"path": "_drafts/draft-dir/another-draft-post.md",
283+
"previous": {
284+
"path": "_drafts/draft-dir/WIP/yet-another-draft-post.md",
285+
"id": "/2017/09/24/yet-another-draft-post",
286+
"url": "/2017/09/24/yet-another-draft-post.html",
287+
"relative_path": "draft-dir/WIP/yet-another-draft-post.md",
288+
"collection": "posts",
289+
"draft": true,
290+
"categories": [],
291+
"all": true,
292+
"foo": "bar",
293+
"title": "Yet Another Draft Post",
294+
"slug": "yet-another-draft-post",
295+
"ext": ".md",
296+
"tags": [],
297+
"date": "2017-09-24 18:03:49 -0400",
298+
"http_url": "http://localhost:4000/2017/09/24/yet-another-draft-post.html",
299+
"api_url": "http://localhost:4000/_api/drafts/draft-dir/WIP/yet-another-draft-post.md",
300+
"name": "yet-another-draft-post.md"
301+
},
302+
"content": "<h1 id=\"another-draft-post\">Another Draft Post</h1>\n",
303+
"id": "/2017/09/24/another-draft-post",
304+
"url": "/2017/09/24/another-draft-post.html",
305+
"relative_path": "draft-dir/another-draft-post.md",
306+
"collection": "posts",
307+
"excerpt": "<h1 id=\"another-draft-post\">Another Draft Post</h1>\n",
308+
"draft": true,
309+
"categories": [],
310+
"all": true,
311+
"foo": "bar",
312+
"title": "Another Draft Post",
313+
"slug": "another-draft-post",
314+
"ext": ".md",
315+
"tags": [],
316+
"date": "2017-09-24 18:03:49 -0400",
317+
"http_url": "http://localhost:4000/2017/09/24/another-draft-post.html",
318+
"api_url": "http://localhost:4000/_api/drafts/draft-dir/another-draft-post.md",
319+
"raw_content": "# Another Draft Post\n",
320+
"front_matter": {
321+
"foo": "bar"
322+
},
323+
"name": "another-draft-post.md"
324+
}
325+
```
326+
#### `PUT /drafts/:directory/:filename`
327+
328+
Create or update the requested page, writing its contents to disk.
329+
330+
#### `DELETE /drafts/:directory/:filename`
331+
332+
Delete the requested page from disk.
333+
189334
### Configuration
190335

191336
#### `GET /configuration`

docs/assets/images/logo.png

-1.6 KB
Loading

docs/configs.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
title: Configuration Options
3+
permalink: /configs/
4+
---
5+
6+
Jekyll Admin related options can be specified in `_config.yml`
7+
under a key called `jekyll_admin`.
8+
9+
### Config Options
10+
11+
#### `hidden_links`
12+
13+
For hiding unwanted links on the sidebar.
14+
15+
The following keys under `hidden_links` can be used in order to hide default links:
16+
17+
```yaml
18+
jekyll_admin:
19+
hidden_links:
20+
- posts
21+
- pages
22+
- staticfiles
23+
- datafiles
24+
- configuration
25+
```

jekyll-admin.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
3636
spec.add_development_dependency "bundler", "~> 1.7"
3737
spec.add_development_dependency "rake", "~> 10.0"
3838
spec.add_development_dependency "rspec", "~> 3.4"
39-
spec.add_development_dependency "rubocop", "~> 0.48.1"
39+
spec.add_development_dependency "rubocop", "~> 0.57.2"
4040
spec.add_development_dependency "sinatra-cross_origin", "~> 0.3"
4141
spec.add_development_dependency "gem-release", "~> 0.7"
4242
end

lib/jekyll-admin/apiable.rb

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def to_api(include_content: false)
4444
end
4545

4646
if is_a?(Jekyll::Document)
47+
output["relative_path"] = relative_path.sub("_drafts/", "") if draft?
4748
output["name"] = basename
4849
end
4950

0 commit comments

Comments
 (0)