jekyll-admin-josercc-josercc 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +54 -0
- data/lib/jekyll-admin-josercc.rb +47 -0
- data/lib/jekyll-admin-josercc/apiable.rb +153 -0
- data/lib/jekyll-admin-josercc/data_file.rb +106 -0
- data/lib/jekyll-admin-josercc/directory.rb +70 -0
- data/lib/jekyll-admin-josercc/file_helper.rb +64 -0
- data/lib/jekyll-admin-josercc/page_without_a_file.rb +7 -0
- data/lib/jekyll-admin-josercc/path_helper.rb +74 -0
- data/lib/jekyll-admin-josercc/public/03945ac4fc7fdefc44bc110bf1ba2393.svg +18 -0
- data/lib/jekyll-admin-josercc/public/059514c92565e4045da1a69525dd9ec0.ttf +0 -0
- data/lib/jekyll-admin-josercc/public/1dc35d25e61d819a9c357074014867ab.ttf +0 -0
- data/lib/jekyll-admin-josercc/public/25a32416abee198dd821b0b17a198a8f.eot +0 -0
- data/lib/jekyll-admin-josercc/public/33a752211d05af6684e26ec63c2ed965.gif +0 -0
- data/lib/jekyll-admin-josercc/public/55131026930a0cd4539d1e2fdb92722d.ttf +0 -0
- data/lib/jekyll-admin-josercc/public/847c038a8202754b465604459e16715d.png +0 -0
- data/lib/jekyll-admin-josercc/public/99adb54b0f30c0758bb4cb9ed5b80aa8.woff +0 -0
- data/lib/jekyll-admin-josercc/public/a770b6797b68e3f8920e473eb824bac0.gif +0 -0
- data/lib/jekyll-admin-josercc/public/bfc14ac982326f7d0b1340e20d3e0c37.ttf +0 -0
- data/lib/jekyll-admin-josercc/public/bundle.js +53 -0
- data/lib/jekyll-admin-josercc/public/bundle.js.map +1 -0
- data/lib/jekyll-admin-josercc/public/c4c172d28f17a61e4476715c58640841.png +0 -0
- data/lib/jekyll-admin-josercc/public/c8ddf1e5e5bf3682bc7bebf30f394148.woff +0 -0
- data/lib/jekyll-admin-josercc/public/d7c639084f684d66a1bc66855d193ed8.svg +685 -0
- data/lib/jekyll-admin-josercc/public/e44520ab9079ea7633bfa874bed5d21d.eot +0 -0
- data/lib/jekyll-admin-josercc/public/e6cf7c6ec7c2d6f670ae9d762604cb0b.woff2 +0 -0
- data/lib/jekyll-admin-josercc/public/favicon.ico +0 -0
- data/lib/jekyll-admin-josercc/public/index.html +12 -0
- data/lib/jekyll-admin-josercc/public/styles.css +5 -0
- data/lib/jekyll-admin-josercc/public/styles.css.map +1 -0
- data/lib/jekyll-admin-josercc/server.rb +100 -0
- data/lib/jekyll-admin-josercc/server/collection.rb +82 -0
- data/lib/jekyll-admin-josercc/server/configuration.rb +57 -0
- data/lib/jekyll-admin-josercc/server/data.rb +82 -0
- data/lib/jekyll-admin-josercc/server/page.rb +90 -0
- data/lib/jekyll-admin-josercc/server/static_file.rb +61 -0
- data/lib/jekyll-admin-josercc/static_server.rb +24 -0
- data/lib/jekyll-admin-josercc/urlable.rb +65 -0
- data/lib/jekyll-admin-josercc/version.rb +3 -0
- data/lib/jekyll/commands/build.rb +14 -0
- data/lib/jekyll/commands/serve.rb +26 -0
- metadata +228 -0
@@ -0,0 +1,61 @@
|
|
1
|
+
module JekyllAdmin
|
2
|
+
class Server < Sinatra::Base
|
3
|
+
namespace "/static_files" do
|
4
|
+
get do
|
5
|
+
json static_files.map(&:to_api)
|
6
|
+
end
|
7
|
+
|
8
|
+
get "/*" do
|
9
|
+
if requested_file
|
10
|
+
json requested_file.to_api(:include_content => true)
|
11
|
+
elsif !static_files_for_path.empty?
|
12
|
+
json static_files_for_path.map(&:to_api)
|
13
|
+
else
|
14
|
+
render_404
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
put "/*" do
|
19
|
+
if renamed?
|
20
|
+
ensure_requested_file
|
21
|
+
delete_file path
|
22
|
+
end
|
23
|
+
|
24
|
+
write_file(write_path, static_file_body)
|
25
|
+
json written_file.to_api(:include_content => true)
|
26
|
+
end
|
27
|
+
|
28
|
+
delete "/*" do
|
29
|
+
ensure_requested_file
|
30
|
+
delete_file path
|
31
|
+
content_type :json
|
32
|
+
status 200
|
33
|
+
halt
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def static_file_body
|
39
|
+
if !request_payload["raw_content"].to_s.empty?
|
40
|
+
request_payload["raw_content"].to_s
|
41
|
+
else
|
42
|
+
Base64.decode64 request_payload["encoded_content"].to_s
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def static_files
|
47
|
+
site.static_files
|
48
|
+
end
|
49
|
+
|
50
|
+
def file_list_dir(path) end
|
51
|
+
|
52
|
+
def static_files_for_path
|
53
|
+
# Joined with / to ensure user can't do partial paths
|
54
|
+
base_path = File.join(path, "/")
|
55
|
+
static_files.select do |f|
|
56
|
+
f.path.start_with? base_path
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module JekyllAdmin
|
2
|
+
class StaticServer < Sinatra::Base
|
3
|
+
set :public_dir, File.expand_path("./public", File.dirname(__FILE__))
|
4
|
+
|
5
|
+
MUST_BUILD_MESSAGE = "Front end not yet built. Run `script/build` to build.".freeze
|
6
|
+
|
7
|
+
# Allow `/admin` and `/admin/`, and `/admin/*` to serve `/public/dist/index.html`
|
8
|
+
get "/*" do
|
9
|
+
send_file index_path
|
10
|
+
end
|
11
|
+
|
12
|
+
# Provide a descriptive error message in dev. if frontend is not build
|
13
|
+
not_found do
|
14
|
+
status 404
|
15
|
+
MUST_BUILD_MESSAGE if settings.development? || settings.test?
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def index_path
|
21
|
+
@index_path ||= File.join(settings.public_folder, "index.html")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module JekyllAdmin
|
2
|
+
# Abstract module to be included in Convertible and Document to provide
|
3
|
+
# additional, URL-specific functionality without duplicating logic
|
4
|
+
module URLable
|
5
|
+
|
6
|
+
# Absolute URL to the HTTP(S) rendered/served representation of this resource
|
7
|
+
def http_url
|
8
|
+
return if is_a?(Jekyll::Collection) || is_a?(JekyllAdmin::DataFile)
|
9
|
+
return if is_a?(Jekyll::Document) && !collection.write?
|
10
|
+
@http_url ||= Addressable::URI.new(
|
11
|
+
:scheme => scheme, :host => host, :port => port,
|
12
|
+
:path => path_with_base(JekyllAdmin.site.config["baseurl"], url)
|
13
|
+
).normalize.to_s
|
14
|
+
end
|
15
|
+
|
16
|
+
# Absolute URL to the API representation of this resource
|
17
|
+
def api_url
|
18
|
+
@api_url ||= Addressable::URI.new(
|
19
|
+
:scheme => scheme, :host => host, :port => port,
|
20
|
+
:path => path_with_base("/_api", resource_path)
|
21
|
+
).normalize.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
def entries_url
|
25
|
+
return unless is_a?(Jekyll::Collection)
|
26
|
+
"#{api_url}/entries"
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
# URL path relative to `_api/` to retreive the given resource via the API
|
32
|
+
# Note: we can't use a case statement here, because === doesn't like includes
|
33
|
+
def resource_path
|
34
|
+
if is_a?(Jekyll::Document)
|
35
|
+
"/collections/#{relative_path.sub(%r!\A_!, "")}"
|
36
|
+
elsif is_a?(Jekyll::Collection)
|
37
|
+
"/collections/#{label}"
|
38
|
+
elsif is_a?(JekyllAdmin::DataFile)
|
39
|
+
"/data/#{relative_path}"
|
40
|
+
elsif is_a?(Jekyll::StaticFile)
|
41
|
+
"/static_files/#{relative_path}"
|
42
|
+
elsif is_a?(Jekyll::Page)
|
43
|
+
"/pages/#{relative_path}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# URI.join doesn't like joining two relative paths, and File.join may join
|
48
|
+
# with `\` rather than with `/` on windows
|
49
|
+
def path_with_base(base, path)
|
50
|
+
[base, path].join("/").squeeze("/")
|
51
|
+
end
|
52
|
+
|
53
|
+
def scheme
|
54
|
+
JekyllAdmin.site.config["scheme"] || "http"
|
55
|
+
end
|
56
|
+
|
57
|
+
def host
|
58
|
+
JekyllAdmin.site.config["host"].sub("127.0.0.1", "localhost")
|
59
|
+
end
|
60
|
+
|
61
|
+
def port
|
62
|
+
JekyllAdmin.site.config["port"]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module Commands
|
3
|
+
class Serve < Command
|
4
|
+
class << self
|
5
|
+
def start_up_webrick(opts, destination)
|
6
|
+
server = WEBrick::HTTPServer.new(webrick_opts(opts)).tap { |o| o.unmount("") }
|
7
|
+
server.mount(opts["baseurl"], Servlet, destination, file_handler_opts)
|
8
|
+
|
9
|
+
jekyll_admin_monkey_patch(server)
|
10
|
+
|
11
|
+
Jekyll.logger.info "Server address:", server_address(server, opts)
|
12
|
+
launch_browser server, opts if opts["open_url"]
|
13
|
+
boot_or_detach server, opts
|
14
|
+
end
|
15
|
+
|
16
|
+
def jekyll_admin_monkey_patch(server)
|
17
|
+
server.mount "/admin", Rack::Handler::WEBrick, JekyllAdmin::StaticServer
|
18
|
+
server.mount "/_api", Rack::Handler::WEBrick, JekyllAdmin::Server
|
19
|
+
Jekyll.logger.warn "Auto-regeneration:", "disabled by JekyllAdmin."
|
20
|
+
Jekyll.logger.warn "", "The site will regenerate only via the Admin interface."
|
21
|
+
Jekyll.logger.info "JekyllAdmin mode:", ENV["RACK_ENV"] || "production"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,228 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-admin-josercc-josercc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- josercc
|
8
|
+
- GitHub Open Source
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2017-06-06 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: jekyll
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '3.3'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '3.3'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: sinatra
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.4'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.4'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: sinatra-contrib
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.4'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1.4'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: addressable
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '2.4'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '2.4'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: bundler
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '1.7'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '1.7'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rake
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '10.0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '10.0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: rspec
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '3.4'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '3.4'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: rubocop
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 0.48.1
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 0.48.1
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: sinatra-cross_origin
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - "~>"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0.3'
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0.3'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: gem-release
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0.7'
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0.7'
|
154
|
+
description: Jekyll::Admin is a drop in administrative framework for Jekyll sites.
|
155
|
+
email:
|
156
|
+
- josercc@163.com
|
157
|
+
- opensource@github.com
|
158
|
+
executables: []
|
159
|
+
extensions: []
|
160
|
+
extra_rdoc_files: []
|
161
|
+
files:
|
162
|
+
- LICENSE
|
163
|
+
- README.md
|
164
|
+
- lib/jekyll-admin-josercc.rb
|
165
|
+
- lib/jekyll-admin-josercc/apiable.rb
|
166
|
+
- lib/jekyll-admin-josercc/data_file.rb
|
167
|
+
- lib/jekyll-admin-josercc/directory.rb
|
168
|
+
- lib/jekyll-admin-josercc/file_helper.rb
|
169
|
+
- lib/jekyll-admin-josercc/page_without_a_file.rb
|
170
|
+
- lib/jekyll-admin-josercc/path_helper.rb
|
171
|
+
- lib/jekyll-admin-josercc/public/03945ac4fc7fdefc44bc110bf1ba2393.svg
|
172
|
+
- lib/jekyll-admin-josercc/public/059514c92565e4045da1a69525dd9ec0.ttf
|
173
|
+
- lib/jekyll-admin-josercc/public/1dc35d25e61d819a9c357074014867ab.ttf
|
174
|
+
- lib/jekyll-admin-josercc/public/25a32416abee198dd821b0b17a198a8f.eot
|
175
|
+
- lib/jekyll-admin-josercc/public/33a752211d05af6684e26ec63c2ed965.gif
|
176
|
+
- lib/jekyll-admin-josercc/public/55131026930a0cd4539d1e2fdb92722d.ttf
|
177
|
+
- lib/jekyll-admin-josercc/public/847c038a8202754b465604459e16715d.png
|
178
|
+
- lib/jekyll-admin-josercc/public/99adb54b0f30c0758bb4cb9ed5b80aa8.woff
|
179
|
+
- lib/jekyll-admin-josercc/public/a770b6797b68e3f8920e473eb824bac0.gif
|
180
|
+
- lib/jekyll-admin-josercc/public/bfc14ac982326f7d0b1340e20d3e0c37.ttf
|
181
|
+
- lib/jekyll-admin-josercc/public/bundle.js
|
182
|
+
- lib/jekyll-admin-josercc/public/bundle.js.map
|
183
|
+
- lib/jekyll-admin-josercc/public/c4c172d28f17a61e4476715c58640841.png
|
184
|
+
- lib/jekyll-admin-josercc/public/c8ddf1e5e5bf3682bc7bebf30f394148.woff
|
185
|
+
- lib/jekyll-admin-josercc/public/d7c639084f684d66a1bc66855d193ed8.svg
|
186
|
+
- lib/jekyll-admin-josercc/public/e44520ab9079ea7633bfa874bed5d21d.eot
|
187
|
+
- lib/jekyll-admin-josercc/public/e6cf7c6ec7c2d6f670ae9d762604cb0b.woff2
|
188
|
+
- lib/jekyll-admin-josercc/public/favicon.ico
|
189
|
+
- lib/jekyll-admin-josercc/public/index.html
|
190
|
+
- lib/jekyll-admin-josercc/public/styles.css
|
191
|
+
- lib/jekyll-admin-josercc/public/styles.css.map
|
192
|
+
- lib/jekyll-admin-josercc/server.rb
|
193
|
+
- lib/jekyll-admin-josercc/server/collection.rb
|
194
|
+
- lib/jekyll-admin-josercc/server/configuration.rb
|
195
|
+
- lib/jekyll-admin-josercc/server/data.rb
|
196
|
+
- lib/jekyll-admin-josercc/server/page.rb
|
197
|
+
- lib/jekyll-admin-josercc/server/static_file.rb
|
198
|
+
- lib/jekyll-admin-josercc/static_server.rb
|
199
|
+
- lib/jekyll-admin-josercc/urlable.rb
|
200
|
+
- lib/jekyll-admin-josercc/version.rb
|
201
|
+
- lib/jekyll/commands/build.rb
|
202
|
+
- lib/jekyll/commands/serve.rb
|
203
|
+
homepage: https://github.com/joserccblog/jekyll-admin-josercc
|
204
|
+
licenses:
|
205
|
+
- MIT
|
206
|
+
metadata:
|
207
|
+
allowed_push_host: https://rubygems.org
|
208
|
+
post_install_message:
|
209
|
+
rdoc_options: []
|
210
|
+
require_paths:
|
211
|
+
- lib
|
212
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
213
|
+
requirements:
|
214
|
+
- - ">="
|
215
|
+
- !ruby/object:Gem::Version
|
216
|
+
version: '0'
|
217
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
218
|
+
requirements:
|
219
|
+
- - ">="
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: '0'
|
222
|
+
requirements: []
|
223
|
+
rubyforge_project:
|
224
|
+
rubygems_version: 2.6.12
|
225
|
+
signing_key:
|
226
|
+
specification_version: 4
|
227
|
+
summary: wp-admin for Jekyll, but better
|
228
|
+
test_files: []
|