octodmin 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.bowerrc +3 -0
- data/.gitignore +24 -0
- data/.rspec +2 -0
- data/.travis.yml +9 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +17 -0
- data/LICENSE.md +22 -0
- data/README.md +117 -0
- data/Rakefile +38 -0
- data/_config.yml +27 -0
- data/_deploy.yml +13 -0
- data/app/.DS_Store +0 -0
- data/app/assets/.DS_Store +0 -0
- data/app/assets/javascripts/.DS_Store +0 -0
- data/app/assets/javascripts/app.js.coffee +13 -0
- data/app/assets/javascripts/components/header.js.cjsx +69 -0
- data/app/assets/javascripts/components/posts.js.cjsx +309 -0
- data/app/assets/javascripts/components/router.js.cjsx +56 -0
- data/app/assets/stylesheets/.DS_Store +0 -0
- data/app/assets/stylesheets/app.scss +75 -0
- data/app/config/environment.rb +7 -0
- data/app/config/routes.rb +19 -0
- data/app/config/sprockets.rb +36 -0
- data/app/controllers/deploys/create.rb +20 -0
- data/app/controllers/frontend/index.rb +8 -0
- data/app/controllers/posts/create.rb +18 -0
- data/app/controllers/posts/destroy.rb +14 -0
- data/app/controllers/posts/index.rb +13 -0
- data/app/controllers/posts/restore.rb +14 -0
- data/app/controllers/posts/revert.rb +14 -0
- data/app/controllers/posts/show.rb +13 -0
- data/app/controllers/posts/update.rb +23 -0
- data/app/controllers/site/show.rb +12 -0
- data/app/controllers/syncs/create.rb +62 -0
- data/app/controllers/version/show.rb +12 -0
- data/app/octodmin.rb +56 -0
- data/app/public/.DS_Store +0 -0
- data/app/public/assets/app.css +7960 -0
- data/app/public/assets/app.css.gz +7960 -0
- data/app/public/assets/app.js +39181 -0
- data/app/public/assets/app.js.gz +39181 -0
- data/app/public/assets/bootstrap/dist/fonts/glyphicons-halflings-regular.eot +0 -0
- data/app/public/assets/bootstrap/dist/fonts/glyphicons-halflings-regular.eot.gz +0 -0
- data/app/public/assets/bootstrap/dist/fonts/glyphicons-halflings-regular.svg +288 -0
- data/app/public/assets/bootstrap/dist/fonts/glyphicons-halflings-regular.svg.gz +288 -0
- data/app/public/assets/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/app/public/assets/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf.gz +0 -0
- data/app/public/assets/bootstrap/dist/fonts/glyphicons-halflings-regular.woff +0 -0
- data/app/public/assets/bootstrap/dist/fonts/glyphicons-halflings-regular.woff.gz +0 -0
- data/app/public/assets/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2 +0 -0
- data/app/public/assets/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2.gz +0 -0
- data/app/public/assets/bootstrap/fonts/glyphicons-halflings-regular.eot +0 -0
- data/app/public/assets/bootstrap/fonts/glyphicons-halflings-regular.eot.gz +0 -0
- data/app/public/assets/bootstrap/fonts/glyphicons-halflings-regular.svg +288 -0
- data/app/public/assets/bootstrap/fonts/glyphicons-halflings-regular.svg.gz +288 -0
- data/app/public/assets/bootstrap/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/app/public/assets/bootstrap/fonts/glyphicons-halflings-regular.ttf.gz +0 -0
- data/app/public/assets/bootstrap/fonts/glyphicons-halflings-regular.woff +0 -0
- data/app/public/assets/bootstrap/fonts/glyphicons-halflings-regular.woff.gz +0 -0
- data/app/public/assets/bootstrap/fonts/glyphicons-halflings-regular.woff2 +0 -0
- data/app/public/assets/bootstrap/fonts/glyphicons-halflings-regular.woff2.gz +0 -0
- data/app/public/assets/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.eot +0 -0
- data/app/public/assets/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.eot.gz +0 -0
- data/app/public/assets/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.svg +288 -0
- data/app/public/assets/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.svg.gz +288 -0
- data/app/public/assets/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.ttf +0 -0
- data/app/public/assets/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.ttf.gz +0 -0
- data/app/public/assets/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.woff +0 -0
- data/app/public/assets/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.woff.gz +0 -0
- data/app/public/assets/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.woff2 +0 -0
- data/app/public/assets/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.woff2.gz +0 -0
- data/app/public/assets/bootswatch/fonts/glyphicons-halflings-regular.eot +0 -0
- data/app/public/assets/bootswatch/fonts/glyphicons-halflings-regular.eot.gz +0 -0
- data/app/public/assets/bootswatch/fonts/glyphicons-halflings-regular.svg +288 -0
- data/app/public/assets/bootswatch/fonts/glyphicons-halflings-regular.svg.gz +288 -0
- data/app/public/assets/bootswatch/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/app/public/assets/bootswatch/fonts/glyphicons-halflings-regular.ttf.gz +0 -0
- data/app/public/assets/bootswatch/fonts/glyphicons-halflings-regular.woff +0 -0
- data/app/public/assets/bootswatch/fonts/glyphicons-halflings-regular.woff.gz +0 -0
- data/app/public/assets/bootswatch/fonts/glyphicons-halflings-regular.woff2 +0 -0
- data/app/public/assets/bootswatch/fonts/glyphicons-halflings-regular.woff2.gz +0 -0
- data/app/public/assets/bootswatch-dist/fonts/glyphicons-halflings-regular.eot +0 -0
- data/app/public/assets/bootswatch-dist/fonts/glyphicons-halflings-regular.eot.gz +0 -0
- data/app/public/assets/bootswatch-dist/fonts/glyphicons-halflings-regular.svg +229 -0
- data/app/public/assets/bootswatch-dist/fonts/glyphicons-halflings-regular.svg.gz +229 -0
- data/app/public/assets/bootswatch-dist/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/app/public/assets/bootswatch-dist/fonts/glyphicons-halflings-regular.ttf.gz +0 -0
- data/app/public/assets/bootswatch-dist/fonts/glyphicons-halflings-regular.woff +0 -0
- data/app/public/assets/bootswatch-dist/fonts/glyphicons-halflings-regular.woff.gz +0 -0
- data/app/public/assets/fontawesome/fonts/fontawesome-webfont.eot +0 -0
- data/app/public/assets/fontawesome/fonts/fontawesome-webfont.eot.gz +0 -0
- data/app/public/assets/fontawesome/fonts/fontawesome-webfont.svg +565 -0
- data/app/public/assets/fontawesome/fonts/fontawesome-webfont.svg.gz +565 -0
- data/app/public/assets/fontawesome/fonts/fontawesome-webfont.ttf +0 -0
- data/app/public/assets/fontawesome/fonts/fontawesome-webfont.ttf.gz +0 -0
- data/app/public/assets/fontawesome/fonts/fontawesome-webfont.woff +0 -0
- data/app/public/assets/fontawesome/fonts/fontawesome-webfont.woff.gz +0 -0
- data/app/public/assets/fontawesome/fonts/fontawesome-webfont.woff2 +0 -0
- data/app/public/assets/fontawesome/fonts/fontawesome-webfont.woff2.gz +0 -0
- data/app/public/assets/manifest.json +1 -0
- data/app/templates/application.html.erb +13 -0
- data/app/templates/frontend/index.html.erb +1 -0
- data/app/views/application_layout.rb +5 -0
- data/app/views/deploys/create.rb +10 -0
- data/app/views/frontend/index.rb +5 -0
- data/app/views/posts/create.rb +10 -0
- data/app/views/posts/destroy.rb +10 -0
- data/app/views/posts/index.rb +10 -0
- data/app/views/posts/restore.rb +10 -0
- data/app/views/posts/revert.rb +10 -0
- data/app/views/posts/show.rb +10 -0
- data/app/views/posts/update.rb +10 -0
- data/app/views/site/show.rb +10 -0
- data/app/views/syncs/create.rb +10 -0
- data/app/views/version/show.rb +10 -0
- data/bower.json +16 -0
- data/config.ru +5 -0
- data/lib/octodmin/app.rb +2 -0
- data/lib/octodmin/post.rb +161 -0
- data/lib/octodmin/site.rb +61 -0
- data/lib/octodmin/version.rb +3 -0
- data/lib/octodmin.rb +7 -0
- data/octodmin.gemspec +24 -0
- data/sample/.gitignore +2 -0
- data/sample/_includes/footer.html +55 -0
- data/sample/_includes/head.html +12 -0
- data/sample/_includes/header.html +27 -0
- data/sample/_layouts/default.html +20 -0
- data/sample/_layouts/page.html +14 -0
- data/sample/_layouts/post.html +15 -0
- data/sample/_posts/2015-01-29-welcome-to-jekyll.markdown +25 -0
- data/sample/_posts/2015-01-30-test.markdown +10 -0
- data/sample/_sass/_base.scss +204 -0
- data/sample/_sass/_layout.scss +236 -0
- data/sample/_sass/_syntax-highlighting.scss +67 -0
- data/sample/_templates/draft +4 -0
- data/sample/_templates/page +4 -0
- data/sample/_templates/post +8 -0
- data/sample/about.md +11 -0
- data/sample/css/main.scss +52 -0
- data/sample/feed.xml +30 -0
- data/sample/index.html +23 -0
- data/spec/api/deploys_spec.rb +36 -0
- data/spec/api/posts_spec.rb +411 -0
- data/spec/api/site_spec.rb +18 -0
- data/spec/api/syncs_spec.rb +81 -0
- data/spec/api/version_spec.rb +14 -0
- data/spec/frontend/assets_spec.rb +23 -0
- data/spec/frontend/home_spec.rb +16 -0
- data/spec/spec_helper.rb +31 -0
- data/tmp/.keep +0 -0
- metadata +259 -0
@@ -0,0 +1,62 @@
|
|
1
|
+
module Octodmin::Controllers::Syncs
|
2
|
+
class Create
|
3
|
+
include Octodmin::Action
|
4
|
+
expose :message
|
5
|
+
|
6
|
+
def call(params)
|
7
|
+
self.format = :json
|
8
|
+
|
9
|
+
site = Octodmin::Site.new
|
10
|
+
git = Git.open(Octodmin::App.dir)
|
11
|
+
|
12
|
+
# Add posts only to commit stage
|
13
|
+
stage(site, git)
|
14
|
+
|
15
|
+
# Compute staged paths
|
16
|
+
staged = paths(site, git)
|
17
|
+
|
18
|
+
# Pull changes
|
19
|
+
git.pull
|
20
|
+
|
21
|
+
# Commit and push changes if any
|
22
|
+
if staged.any?
|
23
|
+
@message = "Octodmin sync for #{staged.count} file#{"s" if staged.count > 1}"
|
24
|
+
@message += "\n\n#{staged.join("\n")}"
|
25
|
+
|
26
|
+
git.commit(@message)
|
27
|
+
git.push
|
28
|
+
else
|
29
|
+
@message = "Everything is up-to-date"
|
30
|
+
end
|
31
|
+
rescue Git::GitExecuteError => e
|
32
|
+
halt 400, JSON.dump(errors: [e.message])
|
33
|
+
ensure
|
34
|
+
git.reset(".")
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def stage(site, git)
|
40
|
+
deleted = site.status.deleted.keys.map { |path| File.join(Octodmin::App.dir, path) }
|
41
|
+
|
42
|
+
site.posts.each do |post|
|
43
|
+
path = File.join(site.source, post.path)
|
44
|
+
git.add(path) unless deleted.include?(path)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def paths(site, git)
|
49
|
+
status = site.reset.status
|
50
|
+
|
51
|
+
paths = (
|
52
|
+
status.changed.keys +
|
53
|
+
status.added.keys +
|
54
|
+
status.deleted.keys
|
55
|
+
).map { |path| File.join(Octodmin::App.dir, path) }
|
56
|
+
|
57
|
+
site.posts.select do |post|
|
58
|
+
paths.any? { |path| path.end_with?(post.path) }
|
59
|
+
end.map(&:path)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/app/octodmin.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
ENV["RACK_ENV"] = ENV["LOTUS_ENV"] ||= "production"
|
2
|
+
|
3
|
+
require "octodmin"
|
4
|
+
require "lotus"
|
5
|
+
require "git"
|
6
|
+
require "json"
|
7
|
+
require "octopress-deploy"
|
8
|
+
|
9
|
+
begin
|
10
|
+
require_relative "./config/sprockets"
|
11
|
+
rescue LoadError
|
12
|
+
end
|
13
|
+
|
14
|
+
module Octodmin
|
15
|
+
class App < Lotus::Application
|
16
|
+
class << self
|
17
|
+
attr_accessor :dir
|
18
|
+
end
|
19
|
+
|
20
|
+
configure do
|
21
|
+
root __dir__
|
22
|
+
|
23
|
+
routes "config/routes"
|
24
|
+
load_paths << [
|
25
|
+
"controllers",
|
26
|
+
"views",
|
27
|
+
]
|
28
|
+
|
29
|
+
layout :application
|
30
|
+
end
|
31
|
+
|
32
|
+
# :nocov:
|
33
|
+
configure :production do
|
34
|
+
assets << ["public"]
|
35
|
+
serve_assets true
|
36
|
+
handle_exceptions false
|
37
|
+
end
|
38
|
+
|
39
|
+
configure :development do
|
40
|
+
handle_exceptions false
|
41
|
+
end
|
42
|
+
# :nocov:
|
43
|
+
|
44
|
+
configure :test do
|
45
|
+
handle_exceptions false
|
46
|
+
end
|
47
|
+
|
48
|
+
def initialize(dir = nil)
|
49
|
+
raise "Please specify root dir" unless dir
|
50
|
+
raise "Attempt to change root dir" if !self.class.dir.nil? && self.class.dir != dir
|
51
|
+
|
52
|
+
self.class.dir = dir
|
53
|
+
super()
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
Binary file
|