jekyll-admin 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e3a603092f343692bb2fcd0c1dab8a04da0603daba3eb86ed4a10f44b29c28b
4
- data.tar.gz: 173733135b068e422b498a52a5ba70a6fe7070a07584ead7d9985d01f9aca73a
3
+ metadata.gz: 23d2ff89a0eaf62c63c8b52e919ae8a347ec623c4f0db5a2810ca387d5aa92f0
4
+ data.tar.gz: 5ac8a35dfa123e685c61a75488e19c0106dd55b3984e60b6fd8ed083d87b67a7
5
5
  SHA512:
6
- metadata.gz: 75d237355890639a3003b2f7397ed3c4c3386e1a02592eedd0ea89e6066d226bc92c91a27a18c6ebebb491e6a588546f82e3de72860f528c3a57a7771c7c741d
7
- data.tar.gz: 4ed0303b0055911ae268634a3559a38cbe988959dc9405f1be91150065e519e1ea61d6e175b07dd550e496544247e618662a3f263920b2df5533514042ea617a
6
+ metadata.gz: 4527e5b2b8c03417a198784c2949f47f596e3d004982a6a603a0f007f16094559eab7815b2b916e3e93c4f62dd6289401a33eea218c60e3f6a303ee257a96ff1
7
+ data.tar.gz: d6770f35c386dfd341731e6ea27ba403d53c6b8d1afd9acbe8b2ce97917bb178598e32f21e8232ef566e3337126e23534ce755ebf8f78cfc2f532322e22ef2a3
data/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright 2016-present Mert Kahyaoğlu and the Jekyll Admin contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright 2016-present Mert Kahyaoğlu and the Jekyll Admin contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,50 +1,50 @@
1
- [![Gem Version](https://img.shields.io/gem/v/jekyll-admin.svg)](https://rubygems.org/gems/jekyll-admin)
2
- [![Build Status](https://travis-ci.org/jekyll/jekyll-admin.svg?branch=master)](https://travis-ci.org/jekyll/jekyll-admin)
3
- [![Build status](https://ci.appveyor.com/api/projects/status/biop1r6ae524xlm2/branch/master?svg=true)](https://ci.appveyor.com/project/benbalter/jekyll-admin/branch/master)
4
- [![Coverage Status](https://coveralls.io/repos/github/jekyll/jekyll-admin/badge.svg?branch=master)](https://coveralls.io/github/jekyll/jekyll-admin?branch=master)
5
- [![NPM Dependencies](https://david-dm.org/jekyll/jekyll-admin.svg)](https://david-dm.org/jekyll/jekyll-admin)
6
-
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.
8
-
9
- ![screenshot of Jekyll Admin](/screenshot.png)
10
-
11
- ## Installation
12
-
13
- 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:
14
-
15
- 1. Add the following to your site's Gemfile:
16
-
17
- ```ruby
18
- gem 'jekyll-admin', group: :jekyll_plugins
19
- ```
20
-
21
- 2. Run `bundle install`
22
-
23
- ## Usage
24
-
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
27
-
28
- ## Options
29
-
30
- Jekyll Admin related options can be specified in `_config.yml`
31
- under a key called `jekyll_admin`. Currently it has only one option `hidden_links`
32
- which is for hiding unwanted links on the sidebar. The following keys under `hidden_links` can be used in order to hide default links;
33
-
34
- ```yaml
35
- jekyll_admin:
36
- hidden_links:
37
- - posts
38
- - pages
39
- - staticfiles
40
- - datafiles
41
- - configuration
42
- ```
43
-
44
- ## Contributing
45
-
46
- 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.
47
-
48
- ## License
49
-
50
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
1
+ [![Gem Version](https://img.shields.io/gem/v/jekyll-admin.svg)](https://rubygems.org/gems/jekyll-admin)
2
+ [![Build Status](https://travis-ci.org/jekyll/jekyll-admin.svg?branch=master)](https://travis-ci.org/jekyll/jekyll-admin)
3
+ [![Build status](https://ci.appveyor.com/api/projects/status/biop1r6ae524xlm2/branch/master?svg=true)](https://ci.appveyor.com/project/benbalter/jekyll-admin/branch/master)
4
+ [![Coverage Status](https://coveralls.io/repos/github/jekyll/jekyll-admin/badge.svg?branch=master)](https://coveralls.io/github/jekyll/jekyll-admin?branch=master)
5
+ [![NPM Dependencies](https://david-dm.org/jekyll/jekyll-admin.svg)](https://david-dm.org/jekyll/jekyll-admin)
6
+
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.
8
+
9
+ ![screenshot of Jekyll Admin](/screenshot.png)
10
+
11
+ ## Installation
12
+
13
+ Refer to the [installing plugins](https://jekyllrb.com/docs/plugins/installation/) section of Jekyll's documentation and install the `jekyll-admin` plugin as you would any other plugin. Here's the short version:
14
+
15
+ 1. Add the following to your site's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'jekyll-admin', group: :jekyll_plugins
19
+ ```
20
+
21
+ 2. Run `bundle install`
22
+
23
+ ## Usage
24
+
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
27
+
28
+ ## Options
29
+
30
+ Jekyll Admin related options can be specified in `_config.yml`
31
+ under a key called `jekyll_admin`. Currently it has only one option `hidden_links`
32
+ which is for hiding unwanted links on the sidebar. The following keys under `hidden_links` can be used in order to hide default links;
33
+
34
+ ```yaml
35
+ jekyll_admin:
36
+ hidden_links:
37
+ - posts
38
+ - pages
39
+ - staticfiles
40
+ - datafiles
41
+ - configuration
42
+ ```
43
+
44
+ ## Contributing
45
+
46
+ 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](https://jekyll.github.io/jekyll-admin/development/) for more information.
47
+
48
+ ## License
49
+
50
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -1,46 +1,46 @@
1
- # Default Sinatra to "production" mode (surpress errors) unless
2
- # otherwise specified by the `RACK_ENV` environmental variable.
3
- # Must be done prior to requiring Sinatra, or we'll get a LoadError
4
- # as it looks for sinatra/cross-origin, which is development only
5
- ENV["RACK_ENV"] = "production" if ENV["RACK_ENV"].to_s.empty?
6
-
7
- require "json"
8
- require "jekyll"
9
- require "base64"
10
- require "webrick"
11
- require "sinatra"
12
- require "fileutils"
13
- require "sinatra/base"
14
- require "sinatra/json"
15
- require "addressable/uri"
16
- require "sinatra/reloader"
17
- require "sinatra/namespace"
18
-
19
- module JekyllAdmin
20
- autoload :APIable, "jekyll-admin/apiable"
21
- autoload :DataFile, "jekyll-admin/data_file"
22
- autoload :Directory, "jekyll-admin/directory"
23
- autoload :FileHelper, "jekyll-admin/file_helper"
24
- autoload :PageWithoutAFile, "jekyll-admin/page_without_a_file"
25
- autoload :PathHelper, "jekyll-admin/path_helper"
26
- autoload :Server, "jekyll-admin/server"
27
- autoload :StaticServer, "jekyll-admin/static_server"
28
- autoload :URLable, "jekyll-admin/urlable"
29
- autoload :Version, "jekyll-admin/version"
30
-
31
- def self.site
32
- @site ||= begin
33
- site = Jekyll.sites.first
34
- site.future = true
35
- site
36
- end
37
- end
38
- end
39
-
40
- # Monkey Patches
41
- require_relative "./jekyll/commands/serve"
42
-
43
- [Jekyll::Page, Jekyll::Document, Jekyll::StaticFile, Jekyll::Collection].each do |klass|
44
- klass.include JekyllAdmin::APIable
45
- klass.include JekyllAdmin::URLable
46
- end
1
+ # Default Sinatra to "production" mode (surpress errors) unless
2
+ # otherwise specified by the `RACK_ENV` environmental variable.
3
+ # Must be done prior to requiring Sinatra, or we'll get a LoadError
4
+ # as it looks for sinatra/cross-origin, which is development only
5
+ ENV["RACK_ENV"] = "production" if ENV["RACK_ENV"].to_s.empty?
6
+
7
+ require "json"
8
+ require "jekyll"
9
+ require "base64"
10
+ require "webrick"
11
+ require "sinatra"
12
+ require "fileutils"
13
+ require "sinatra/base"
14
+ require "sinatra/json"
15
+ require "addressable/uri"
16
+ require "sinatra/reloader"
17
+ require "sinatra/namespace"
18
+
19
+ module JekyllAdmin
20
+ autoload :APIable, "jekyll-admin/apiable"
21
+ autoload :DataFile, "jekyll-admin/data_file"
22
+ autoload :Directory, "jekyll-admin/directory"
23
+ autoload :FileHelper, "jekyll-admin/file_helper"
24
+ autoload :PageWithoutAFile, "jekyll-admin/page_without_a_file"
25
+ autoload :PathHelper, "jekyll-admin/path_helper"
26
+ autoload :Server, "jekyll-admin/server"
27
+ autoload :StaticServer, "jekyll-admin/static_server"
28
+ autoload :URLable, "jekyll-admin/urlable"
29
+ autoload :Version, "jekyll-admin/version"
30
+
31
+ def self.site
32
+ @site ||= begin
33
+ site = Jekyll.sites.first
34
+ site.future = true
35
+ site
36
+ end
37
+ end
38
+ end
39
+
40
+ # Monkey Patches
41
+ require_relative "./jekyll/commands/serve"
42
+
43
+ [Jekyll::Page, Jekyll::Document, Jekyll::StaticFile, Jekyll::Collection].each do |klass|
44
+ klass.include JekyllAdmin::APIable
45
+ klass.include JekyllAdmin::URLable
46
+ end
@@ -1,162 +1,163 @@
1
- module JekyllAdmin
2
- # Abstract module to be included in Convertible and Document to provide
3
- # additional, API-specific functionality without duplicating logic
4
- module APIable
5
-
6
- CONTENT_FIELDS = %w(next previous content excerpt).freeze
7
-
8
- # Returns a hash suitable for use as an API response.
9
- #
10
- # For Documents and Pages:
11
- #
12
- # 1. Adds the file's raw content to the `raw_content` field
13
- # 2. Adds the file's raw YAML front matter to the `front_matter` field
14
- #
15
- # For Static Files it addes the Base64 `encoded_content` field
16
- #
17
- # Options:
18
- #
19
- # include_content - if true, includes the content in the respond, false by default
20
- # to support mapping on indexes where we only want metadata
21
- #
22
- #
23
- # Returns a hash (which can then be to_json'd)
24
- def to_api(include_content: false)
25
- output = hash_for_api
26
- output = output.merge(url_fields)
27
-
28
- # Include content, if requested, otherwise remove it
29
- if include_content
30
- output = output.merge(content_fields)
31
- else
32
- CONTENT_FIELDS.each { |field| output.delete(field) }
33
- end
34
-
35
- # Documents have duplicate output and content fields, Pages do not
36
- # Since it's an API, use `content` in both for consistency
37
- output.delete("output")
38
-
39
- # By default, calling to_liquid on a collection will return a docs
40
- # array with each rendered document, which we don't want.
41
- if is_a?(Jekyll::Collection)
42
- output.delete("docs")
43
- output["entries_url"] = entries_url
44
- end
45
-
46
- if is_a?(Jekyll::Document)
47
- output["relative_path"] = relative_path.sub("_drafts/", "") if draft?
48
- output["name"] = basename
49
- end
50
-
51
- if is_a?(Jekyll::StaticFile)
52
- output["from_theme"] = from_theme_gem?
53
- end
54
-
55
- output
56
- end
57
-
58
- private
59
-
60
- # Pages don't have a hash method, but Documents do
61
- def file_path
62
- if is_a?(Jekyll::Document)
63
- path
64
- else
65
- File.join(@base, @dir, name)
66
- end
67
- end
68
-
69
- def from_theme_gem?
70
- @base == site.in_theme_dir
71
- end
72
-
73
- # StaticFiles don't have `attr_accesor` set for @site or @name
74
- def site
75
- @site
76
- end
77
-
78
- def name
79
- @name
80
- end
81
-
82
- def file_contents
83
- @file_contents ||= File.read(file_path, file_read_options) if file_exists?
84
- end
85
-
86
- def file_read_options
87
- Jekyll::Utils.merged_file_read_opts(site, {})
88
- end
89
-
90
- def front_matter
91
- return unless file_exists?
92
- @front_matter ||= if file_contents =~ Jekyll::Document::YAML_FRONT_MATTER_REGEXP
93
- SafeYAML.load(Regexp.last_match(1))
94
- else
95
- {}
96
- end
97
- end
98
-
99
- def raw_content
100
- return unless file_exists?
101
- @raw_content ||= if file_contents =~ Jekyll::Document::YAML_FRONT_MATTER_REGEXP
102
- $POSTMATCH
103
- else
104
- file_contents
105
- end
106
- end
107
-
108
- def encoded_content
109
- @encoded_content ||= Base64.encode64(file_contents) if file_exists?
110
- end
111
-
112
- def file_exists?
113
- return @file_exists if defined? @file_exists
114
- @file_exists = File.exist?(file_path)
115
- end
116
-
117
- # Base hash from which to generate the API output
118
- def hash_for_api
119
- output = to_liquid
120
- if output.respond_to?(:hash_for_json)
121
- output.hash_for_json
122
- else
123
- output.to_h
124
- end
125
- end
126
-
127
- # Returns a hash of content fields for inclusion in the API output
128
- def content_fields
129
- output = {}
130
-
131
- # Include file content-related fields
132
- if is_a?(Jekyll::StaticFile)
133
- output["encoded_content"] = encoded_content
134
- elsif is_a?(JekyllAdmin::DataFile)
135
- output["content"] = content
136
- output["raw_content"] = raw_content
137
- else
138
- output["raw_content"] = raw_content
139
- output["front_matter"] = front_matter
140
- end
141
-
142
- # Include next and previous documents non-recursively
143
- if is_a?(Jekyll::Document)
144
- %w(next previous).each do |direction|
145
- method = "#{direction}_doc".to_sym
146
- doc = public_send(method)
147
- output[direction] = doc.to_api if doc
148
- end
149
- end
150
-
151
- output
152
- end
153
-
154
- def url_fields
155
- return {} unless respond_to?(:http_url) && respond_to?(:api_url)
156
- {
157
- "http_url" => http_url,
158
- "api_url" => api_url,
159
- }
160
- end
161
- end
162
- end
1
+ module JekyllAdmin
2
+ # Abstract module to be included in Convertible and Document to provide
3
+ # additional, API-specific functionality without duplicating logic
4
+ module APIable
5
+ CONTENT_FIELDS = %w(next previous content excerpt).freeze
6
+
7
+ # Returns a hash suitable for use as an API response.
8
+ #
9
+ # For Documents and Pages:
10
+ #
11
+ # 1. Adds the file's raw content to the `raw_content` field
12
+ # 2. Adds the file's raw YAML front matter to the `front_matter` field
13
+ #
14
+ # For Static Files it addes the Base64 `encoded_content` field
15
+ #
16
+ # Options:
17
+ #
18
+ # include_content - if true, includes the content in the respond, false by default
19
+ # to support mapping on indexes where we only want metadata
20
+ #
21
+ #
22
+ # Returns a hash (which can then be to_json'd)
23
+ def to_api(include_content: false)
24
+ output = hash_for_api
25
+ output = output.merge(url_fields)
26
+
27
+ # Include content, if requested, otherwise remove it
28
+ if include_content
29
+ output = output.merge(content_fields)
30
+ else
31
+ CONTENT_FIELDS.each { |field| output.delete(field) }
32
+ end
33
+
34
+ # Documents have duplicate output and content fields, Pages do not
35
+ # Since it's an API, use `content` in both for consistency
36
+ output.delete("output")
37
+
38
+ # By default, calling to_liquid on a collection will return a docs
39
+ # array with each rendered document, which we don't want.
40
+ if is_a?(Jekyll::Collection)
41
+ output.delete("docs")
42
+ output["entries_url"] = entries_url
43
+ end
44
+
45
+ if is_a?(Jekyll::Document)
46
+ output["relative_path"] = relative_path.sub("_drafts/", "") if draft?
47
+ output["name"] = basename
48
+ end
49
+
50
+ output["from_theme"] = from_theme_gem? if is_a?(Jekyll::StaticFile)
51
+
52
+ output
53
+ end
54
+
55
+ private
56
+
57
+ # Pages don't have a hash method, but Documents do
58
+ def file_path
59
+ if is_a?(Jekyll::Document)
60
+ path
61
+ else
62
+ File.join(@base, @dir, name)
63
+ end
64
+ end
65
+
66
+ def from_theme_gem?
67
+ @base == site.in_theme_dir
68
+ end
69
+
70
+ # StaticFiles don't have `attr_accesor` set for @site or @name
71
+ def site
72
+ @site
73
+ end
74
+
75
+ def name
76
+ @name
77
+ end
78
+
79
+ def file_contents
80
+ @file_contents ||= File.read(file_path, file_read_options) if file_exists?
81
+ end
82
+
83
+ def file_read_options
84
+ Jekyll::Utils.merged_file_read_opts(site, {})
85
+ end
86
+
87
+ def front_matter
88
+ return unless file_exists?
89
+
90
+ @front_matter ||= if file_contents =~ Jekyll::Document::YAML_FRONT_MATTER_REGEXP
91
+ SafeYAML.load(Regexp.last_match(1))
92
+ else
93
+ {}
94
+ end
95
+ end
96
+
97
+ def raw_content
98
+ return unless file_exists?
99
+
100
+ @raw_content ||= if file_contents =~ Jekyll::Document::YAML_FRONT_MATTER_REGEXP
101
+ $POSTMATCH
102
+ else
103
+ file_contents
104
+ end
105
+ end
106
+
107
+ def encoded_content
108
+ @encoded_content ||= Base64.encode64(file_contents) if file_exists?
109
+ end
110
+
111
+ def file_exists?
112
+ return @file_exists if defined? @file_exists
113
+
114
+ @file_exists = File.exist?(file_path)
115
+ end
116
+
117
+ # Base hash from which to generate the API output
118
+ def hash_for_api
119
+ output = to_liquid
120
+ if output.respond_to?(:hash_for_json)
121
+ output.hash_for_json
122
+ else
123
+ output.to_h
124
+ end
125
+ end
126
+
127
+ # Returns a hash of content fields for inclusion in the API output
128
+ def content_fields
129
+ output = {}
130
+
131
+ # Include file content-related fields
132
+ if is_a?(Jekyll::StaticFile)
133
+ output["encoded_content"] = encoded_content
134
+ elsif is_a?(JekyllAdmin::DataFile)
135
+ output["content"] = content
136
+ output["raw_content"] = raw_content
137
+ else
138
+ output["raw_content"] = raw_content
139
+ output["front_matter"] = front_matter
140
+ end
141
+
142
+ # Include next and previous documents non-recursively
143
+ if is_a?(Jekyll::Document)
144
+ %w(next previous).each do |direction|
145
+ method = "#{direction}_doc".to_sym
146
+ doc = public_send(method)
147
+ output[direction] = doc.to_api if doc
148
+ end
149
+ end
150
+
151
+ output
152
+ end
153
+
154
+ def url_fields
155
+ return {} unless respond_to?(:http_url) && respond_to?(:api_url)
156
+
157
+ {
158
+ "http_url" => http_url,
159
+ "api_url" => api_url,
160
+ }
161
+ end
162
+ end
163
+ end