octodmin 0.1.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.
Files changed (153) hide show
  1. checksums.yaml +7 -0
  2. data/.bowerrc +3 -0
  3. data/.gitignore +24 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +9 -0
  6. data/CHANGELOG.md +4 -0
  7. data/Gemfile +17 -0
  8. data/LICENSE.md +22 -0
  9. data/README.md +117 -0
  10. data/Rakefile +38 -0
  11. data/_config.yml +27 -0
  12. data/_deploy.yml +13 -0
  13. data/app/.DS_Store +0 -0
  14. data/app/assets/.DS_Store +0 -0
  15. data/app/assets/javascripts/.DS_Store +0 -0
  16. data/app/assets/javascripts/app.js.coffee +13 -0
  17. data/app/assets/javascripts/components/header.js.cjsx +69 -0
  18. data/app/assets/javascripts/components/posts.js.cjsx +309 -0
  19. data/app/assets/javascripts/components/router.js.cjsx +56 -0
  20. data/app/assets/stylesheets/.DS_Store +0 -0
  21. data/app/assets/stylesheets/app.scss +75 -0
  22. data/app/config/environment.rb +7 -0
  23. data/app/config/routes.rb +19 -0
  24. data/app/config/sprockets.rb +36 -0
  25. data/app/controllers/deploys/create.rb +20 -0
  26. data/app/controllers/frontend/index.rb +8 -0
  27. data/app/controllers/posts/create.rb +18 -0
  28. data/app/controllers/posts/destroy.rb +14 -0
  29. data/app/controllers/posts/index.rb +13 -0
  30. data/app/controllers/posts/restore.rb +14 -0
  31. data/app/controllers/posts/revert.rb +14 -0
  32. data/app/controllers/posts/show.rb +13 -0
  33. data/app/controllers/posts/update.rb +23 -0
  34. data/app/controllers/site/show.rb +12 -0
  35. data/app/controllers/syncs/create.rb +62 -0
  36. data/app/controllers/version/show.rb +12 -0
  37. data/app/octodmin.rb +56 -0
  38. data/app/public/.DS_Store +0 -0
  39. data/app/public/assets/app.css +7960 -0
  40. data/app/public/assets/app.css.gz +7960 -0
  41. data/app/public/assets/app.js +39181 -0
  42. data/app/public/assets/app.js.gz +39181 -0
  43. data/app/public/assets/bootstrap/dist/fonts/glyphicons-halflings-regular.eot +0 -0
  44. data/app/public/assets/bootstrap/dist/fonts/glyphicons-halflings-regular.eot.gz +0 -0
  45. data/app/public/assets/bootstrap/dist/fonts/glyphicons-halflings-regular.svg +288 -0
  46. data/app/public/assets/bootstrap/dist/fonts/glyphicons-halflings-regular.svg.gz +288 -0
  47. data/app/public/assets/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf +0 -0
  48. data/app/public/assets/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf.gz +0 -0
  49. data/app/public/assets/bootstrap/dist/fonts/glyphicons-halflings-regular.woff +0 -0
  50. data/app/public/assets/bootstrap/dist/fonts/glyphicons-halflings-regular.woff.gz +0 -0
  51. data/app/public/assets/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2 +0 -0
  52. data/app/public/assets/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2.gz +0 -0
  53. data/app/public/assets/bootstrap/fonts/glyphicons-halflings-regular.eot +0 -0
  54. data/app/public/assets/bootstrap/fonts/glyphicons-halflings-regular.eot.gz +0 -0
  55. data/app/public/assets/bootstrap/fonts/glyphicons-halflings-regular.svg +288 -0
  56. data/app/public/assets/bootstrap/fonts/glyphicons-halflings-regular.svg.gz +288 -0
  57. data/app/public/assets/bootstrap/fonts/glyphicons-halflings-regular.ttf +0 -0
  58. data/app/public/assets/bootstrap/fonts/glyphicons-halflings-regular.ttf.gz +0 -0
  59. data/app/public/assets/bootstrap/fonts/glyphicons-halflings-regular.woff +0 -0
  60. data/app/public/assets/bootstrap/fonts/glyphicons-halflings-regular.woff.gz +0 -0
  61. data/app/public/assets/bootstrap/fonts/glyphicons-halflings-regular.woff2 +0 -0
  62. data/app/public/assets/bootstrap/fonts/glyphicons-halflings-regular.woff2.gz +0 -0
  63. data/app/public/assets/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.eot +0 -0
  64. data/app/public/assets/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.eot.gz +0 -0
  65. data/app/public/assets/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.svg +288 -0
  66. data/app/public/assets/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.svg.gz +288 -0
  67. data/app/public/assets/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.ttf +0 -0
  68. data/app/public/assets/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.ttf.gz +0 -0
  69. data/app/public/assets/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.woff +0 -0
  70. data/app/public/assets/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.woff.gz +0 -0
  71. data/app/public/assets/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.woff2 +0 -0
  72. data/app/public/assets/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.woff2.gz +0 -0
  73. data/app/public/assets/bootswatch/fonts/glyphicons-halflings-regular.eot +0 -0
  74. data/app/public/assets/bootswatch/fonts/glyphicons-halflings-regular.eot.gz +0 -0
  75. data/app/public/assets/bootswatch/fonts/glyphicons-halflings-regular.svg +288 -0
  76. data/app/public/assets/bootswatch/fonts/glyphicons-halflings-regular.svg.gz +288 -0
  77. data/app/public/assets/bootswatch/fonts/glyphicons-halflings-regular.ttf +0 -0
  78. data/app/public/assets/bootswatch/fonts/glyphicons-halflings-regular.ttf.gz +0 -0
  79. data/app/public/assets/bootswatch/fonts/glyphicons-halflings-regular.woff +0 -0
  80. data/app/public/assets/bootswatch/fonts/glyphicons-halflings-regular.woff.gz +0 -0
  81. data/app/public/assets/bootswatch/fonts/glyphicons-halflings-regular.woff2 +0 -0
  82. data/app/public/assets/bootswatch/fonts/glyphicons-halflings-regular.woff2.gz +0 -0
  83. data/app/public/assets/bootswatch-dist/fonts/glyphicons-halflings-regular.eot +0 -0
  84. data/app/public/assets/bootswatch-dist/fonts/glyphicons-halflings-regular.eot.gz +0 -0
  85. data/app/public/assets/bootswatch-dist/fonts/glyphicons-halflings-regular.svg +229 -0
  86. data/app/public/assets/bootswatch-dist/fonts/glyphicons-halflings-regular.svg.gz +229 -0
  87. data/app/public/assets/bootswatch-dist/fonts/glyphicons-halflings-regular.ttf +0 -0
  88. data/app/public/assets/bootswatch-dist/fonts/glyphicons-halflings-regular.ttf.gz +0 -0
  89. data/app/public/assets/bootswatch-dist/fonts/glyphicons-halflings-regular.woff +0 -0
  90. data/app/public/assets/bootswatch-dist/fonts/glyphicons-halflings-regular.woff.gz +0 -0
  91. data/app/public/assets/fontawesome/fonts/fontawesome-webfont.eot +0 -0
  92. data/app/public/assets/fontawesome/fonts/fontawesome-webfont.eot.gz +0 -0
  93. data/app/public/assets/fontawesome/fonts/fontawesome-webfont.svg +565 -0
  94. data/app/public/assets/fontawesome/fonts/fontawesome-webfont.svg.gz +565 -0
  95. data/app/public/assets/fontawesome/fonts/fontawesome-webfont.ttf +0 -0
  96. data/app/public/assets/fontawesome/fonts/fontawesome-webfont.ttf.gz +0 -0
  97. data/app/public/assets/fontawesome/fonts/fontawesome-webfont.woff +0 -0
  98. data/app/public/assets/fontawesome/fonts/fontawesome-webfont.woff.gz +0 -0
  99. data/app/public/assets/fontawesome/fonts/fontawesome-webfont.woff2 +0 -0
  100. data/app/public/assets/fontawesome/fonts/fontawesome-webfont.woff2.gz +0 -0
  101. data/app/public/assets/manifest.json +1 -0
  102. data/app/templates/application.html.erb +13 -0
  103. data/app/templates/frontend/index.html.erb +1 -0
  104. data/app/views/application_layout.rb +5 -0
  105. data/app/views/deploys/create.rb +10 -0
  106. data/app/views/frontend/index.rb +5 -0
  107. data/app/views/posts/create.rb +10 -0
  108. data/app/views/posts/destroy.rb +10 -0
  109. data/app/views/posts/index.rb +10 -0
  110. data/app/views/posts/restore.rb +10 -0
  111. data/app/views/posts/revert.rb +10 -0
  112. data/app/views/posts/show.rb +10 -0
  113. data/app/views/posts/update.rb +10 -0
  114. data/app/views/site/show.rb +10 -0
  115. data/app/views/syncs/create.rb +10 -0
  116. data/app/views/version/show.rb +10 -0
  117. data/bower.json +16 -0
  118. data/config.ru +5 -0
  119. data/lib/octodmin/app.rb +2 -0
  120. data/lib/octodmin/post.rb +161 -0
  121. data/lib/octodmin/site.rb +61 -0
  122. data/lib/octodmin/version.rb +3 -0
  123. data/lib/octodmin.rb +7 -0
  124. data/octodmin.gemspec +24 -0
  125. data/sample/.gitignore +2 -0
  126. data/sample/_includes/footer.html +55 -0
  127. data/sample/_includes/head.html +12 -0
  128. data/sample/_includes/header.html +27 -0
  129. data/sample/_layouts/default.html +20 -0
  130. data/sample/_layouts/page.html +14 -0
  131. data/sample/_layouts/post.html +15 -0
  132. data/sample/_posts/2015-01-29-welcome-to-jekyll.markdown +25 -0
  133. data/sample/_posts/2015-01-30-test.markdown +10 -0
  134. data/sample/_sass/_base.scss +204 -0
  135. data/sample/_sass/_layout.scss +236 -0
  136. data/sample/_sass/_syntax-highlighting.scss +67 -0
  137. data/sample/_templates/draft +4 -0
  138. data/sample/_templates/page +4 -0
  139. data/sample/_templates/post +8 -0
  140. data/sample/about.md +11 -0
  141. data/sample/css/main.scss +52 -0
  142. data/sample/feed.xml +30 -0
  143. data/sample/index.html +23 -0
  144. data/spec/api/deploys_spec.rb +36 -0
  145. data/spec/api/posts_spec.rb +411 -0
  146. data/spec/api/site_spec.rb +18 -0
  147. data/spec/api/syncs_spec.rb +81 -0
  148. data/spec/api/version_spec.rb +14 -0
  149. data/spec/frontend/assets_spec.rb +23 -0
  150. data/spec/frontend/home_spec.rb +16 -0
  151. data/spec/spec_helper.rb +31 -0
  152. data/tmp/.keep +0 -0
  153. metadata +259 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 68161108fbd0f208b9fe379eaefc1638d8a07a40
4
+ data.tar.gz: 308e09d4fd3591b47d7a7621837aa12543e6f606
5
+ SHA512:
6
+ metadata.gz: a3c62874c57613363f2d4ae5e8bb8e63892ffd50a91e853d2012a19c9a2db48ced8388fc1d8cd8467904df0c89e7c1909048315046cb0b4719af5b7afd57d138
7
+ data.tar.gz: 11f6a5edc1cf7e8b057b45dbe9ab9581b00f2755c30e5c5cb5d60c679932d58e323c171bdeafd471dcf8a8b8e939a2508b81e9d206316cb82fa85caf69df7468
data/.bowerrc ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "directory" : "bower_components"
3
+ }
data/.gitignore ADDED
@@ -0,0 +1,24 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ tmp
16
+ .greenbar
17
+ .powrc
18
+ .ruby-gemset
19
+ .ruby-version
20
+ app/public
21
+ bower_components
22
+ _site
23
+ .sass-cache
24
+ .deploy
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format=documentation
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ sudo: false
2
+ language: ruby
3
+ before_script:
4
+ - npm install -g bower
5
+ - bower install
6
+ script: bundle exec rake spec:coverage
7
+ rvm:
8
+ - 2.1
9
+ - 2.2
data/CHANGELOG.md ADDED
@@ -0,0 +1,4 @@
1
+ v0.1.0
2
+ ------
3
+
4
+ * Initial version
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "https://rubygems.org"
2
+ gemspec
3
+
4
+ gem "rake", "~> 10.0"
5
+ gem "sprockets", "~> 3.0.0.beta"
6
+ gem "bower", "~> 0.0.2"
7
+ gem "sprockets-standalone", github: "krasnoukhov/sprockets-standalone"
8
+ gem "coffee-react", "~> 2.1.0"
9
+ gem "lotusrb", github: "lotus/lotus"
10
+
11
+ group :test do
12
+ gem "simplecov", "~> 0.9.0", require: false
13
+ gem "coveralls", "~> 0.7.0", require: false
14
+ gem "rspec", "~> 3.1.0"
15
+ gem "json_spec", "~> 1.1.0"
16
+ gem "rack-test", "~> 0.6.0"
17
+ end
data/LICENSE.md ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Dmitry Krasnoukhov
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,117 @@
1
+ # Octodmin
2
+
3
+ Content management for Jekyll blogs
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/octodmin.svg)](http://badge.fury.io/rb/octodmin)
6
+ [![Build Status](https://secure.travis-ci.org/krasnoukhov/octodmin.svg?branch=master)](http://travis-ci.org/krasnoukhov/octodmin?branch=master)
7
+ [![Coverage Status](https://img.shields.io/coveralls/krasnoukhov/octodmin.svg)](https://coveralls.io/r/krasnoukhov/octodmin?branch=master)
8
+ [![Code Climate](https://img.shields.io/codeclimate/github/krasnoukhov/octodmin.svg)](https://codeclimate.com/github/krasnoukhov/octodmin)
9
+
10
+ ![Screencast](http://i.imgur.com/SazYNe8.gif)
11
+
12
+ ## Installation
13
+
14
+ Add this line to your Jekyll project's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'octodmin', '~> 0.1.0'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ ```bash
23
+ $ bundle
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ Octodmin assumes that there is a `_config.yml` with Jekyll
29
+ configuration.
30
+
31
+ Add `config.ru` to your project:
32
+
33
+ ```ruby
34
+ require "octodmin/app"
35
+ run Octodmin::App.new(__dir__)
36
+ ```
37
+
38
+ Run it as a Rack application:
39
+
40
+ ```bash
41
+ $ rackup
42
+ ```
43
+
44
+ ## Configuration
45
+
46
+ Octodmin can be configured using `_config.yml`. For example:
47
+
48
+ ```yaml
49
+ # Octodmin settings
50
+ octodmin:
51
+ transliterate: ukrainian
52
+ deploys:
53
+ - config_file: _deploy.yml
54
+ front_matter:
55
+ custom:
56
+ type: "text"
57
+ ```
58
+
59
+ Valid options:
60
+
61
+ `transliterate`: use any of [babosa](https://github.com/norman/babosa#locale-sensitive-transliteration-with-support-for-many-languages)'s
62
+ languages for slug transliteration. Default is `latin`
63
+
64
+ `deploys`: if you use `octopress-deploy`, specify your deploy configuration
65
+ file to get a "Deploy" button in Octodmin.
66
+
67
+ `front_matter`: if you use custom front matter attributes, specify all
68
+ of them to extend the edit form with corresponding inputs.
69
+
70
+ Please note that Octodmin uses Octopress internally, so make sure you configure it
71
+ accordingly. For example:
72
+
73
+ ```yaml
74
+ # Octopress
75
+ post_ext: markdown
76
+ post_layout: post
77
+ ```
78
+
79
+ Please note that Octodmin uses Octopress internally, so make sure you
80
+ there is proper config, for example:
81
+
82
+ ```yaml
83
+ # Octopress
84
+ post_ext: markdown
85
+ post_layout: post
86
+ ```
87
+
88
+ ## Deployment
89
+
90
+ Since Octodmin is a simple Rack app, use your favorite Ruby application server.
91
+ For example, add `puma` to Gemfile, run `bundle`, and then `rackup`.
92
+ That's it.
93
+
94
+ When deploying Octodmin to a remote server, make sure you're able to run
95
+ `git pull`, `git push` and `octopress deploy` (if needed) successfully
96
+ in the shell of your remote user.
97
+
98
+ ## Development and testing
99
+
100
+ You would need `npm` and `bower`. Run `bower install` to install asset
101
+ dependencies.
102
+
103
+ Run `rackup` to start the development server.
104
+
105
+ Run `rspec` to run tests.
106
+
107
+ ## Contributing
108
+
109
+ 1. Fork it
110
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
111
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
112
+ 4. Push to the branch (`git push origin my-new-feature`)
113
+ 5. Create new Pull Request
114
+
115
+ ## LICENSE
116
+
117
+ The MIT License
data/Rakefile ADDED
@@ -0,0 +1,38 @@
1
+ require "bundler/setup"
2
+ require "fileutils"
3
+ require "rspec/core/rake_task"
4
+ require "bundler/gem_tasks"
5
+ require "sprockets/standalone"
6
+
7
+ # Test tasks
8
+ RSpec::Core::RakeTask.new(:spec)
9
+
10
+ namespace :spec do
11
+ task coverage: :"assets:remove" do
12
+ ENV["COVERAGE"] = "true"
13
+ Rake::Task["spec"].invoke
14
+ end
15
+ end
16
+
17
+ task default: :spec
18
+
19
+ # Release tasks
20
+ Sprockets::Standalone::RakeTask.new(:assets) do |task, sprockets|
21
+ require_relative "app/config/sprockets"
22
+
23
+ task.assets = %w(app.js app.css *.eot *.svg *.ttf *.woff *woff2)
24
+ task.sources = %w(app/assets)
25
+ task.output = "app/public/assets"
26
+ task.compress = true
27
+ task.digest = false
28
+ task.environment = Octodmin.sprockets
29
+ end
30
+
31
+ namespace :assets do
32
+ task :remove do
33
+ FileUtils.rm_r("./tmp/sprockets", force: true)
34
+ FileUtils.rm_r("./app/public/assets", force: true)
35
+ end
36
+ end
37
+
38
+ Rake::Task["build"].enhance([:"assets:remove", :"assets:compile"])
data/_config.yml ADDED
@@ -0,0 +1,27 @@
1
+ # Site settings
2
+ source: sample
3
+ title: Your awesome title
4
+ email: your-email@domain.com
5
+ description: > # this means to ignore newlines until "baseurl:"
6
+ Write an awesome description for your new site here. You can edit this
7
+ line in _config.yml. It will appear in your document head meta (for
8
+ Google search results) and in your feed.xml site description.
9
+ baseurl: "/octodmin" # the subpath of your site, e.g. /blog/
10
+ url: "http://krasnoukhov.github.io" # the base hostname & protocol for your site
11
+ twitter_username: jekyllrb
12
+ github_username: jekyll
13
+
14
+ # Build settings
15
+ markdown: kramdown
16
+
17
+ # Octopress settings
18
+ post_ext: markdown
19
+
20
+ # Octodmin settings
21
+ octodmin:
22
+ transliterate: ukrainian
23
+ deploys:
24
+ - config_file: _deploy.yml
25
+ front_matter:
26
+ custom:
27
+ type: "text"
data/_deploy.yml ADDED
@@ -0,0 +1,13 @@
1
+ method: git # How do you want to deploy? git, rsync or s3.
2
+ site_dir: _site # Location of your static site files.
3
+
4
+ git_url: git@github.com:krasnoukhov/octodmin.git # remote repository url, e.g. git@github.com:username/repo_name
5
+
6
+ # Note on git_branch:
7
+ # If using GitHub project pages, set the branch to 'gh-pages'.
8
+ # For GitHub user/organization pages or Heroku, set the branch to 'master'.
9
+ #
10
+ git_branch: gh-pages # Git branch where static site files are commited
11
+
12
+
13
+ # remote_path: # Destination directory
data/app/.DS_Store ADDED
Binary file
Binary file
Binary file
@@ -0,0 +1,13 @@
1
+ #= require jquery
2
+ #= require jquery-serialize-object
3
+ #= require bootstrap
4
+ #= require bootstrap-markdown
5
+ #= require spin.js/spin.js
6
+ #= require react
7
+ #= require react-loader
8
+ #= require react-router
9
+ #= require momentjs/moment
10
+
11
+ #= require components/header
12
+ #= require components/posts
13
+ #= require components/router
@@ -0,0 +1,69 @@
1
+ # @cjsx React.DOM
2
+
3
+ @Header = React.createClass(
4
+ propTypes:
5
+ site: React.PropTypes.object.isRequired
6
+
7
+ getInitialState: ->
8
+ { alert: null, success: null, loading: false }
9
+
10
+ handleSync: ->
11
+ return if @state.loading
12
+ @setState(loading: true)
13
+ $.post("/api/syncs").always(@handleResponse).done(@handleSyncSuccess).fail(@handleError)
14
+
15
+ handleDeploy: ->
16
+ return if @state.loading
17
+ @setState(loading: true)
18
+ $.post("/api/deploys").always(@handleResponse).done(@handleDeploySuccess).fail(@handleError)
19
+
20
+ handleResponse: ->
21
+ @setState(loading: false)
22
+
23
+ handleSyncSuccess: (response) ->
24
+ @setState(success: response.syncs.join("\n").replace(/\n/g, "<br>"))
25
+ setTimeout(@removeSuccess, 5000)
26
+ $(document).trigger("fetchPosts")
27
+
28
+ handleDeploySuccess: (response) ->
29
+ @setState(success: response.deploys.join("\n"))
30
+ setTimeout(@removeSuccess, 5000)
31
+ $(document).trigger("fetchPosts")
32
+
33
+ handleError: (error) ->
34
+ @setState(alert: error.responseJSON?.errors.join("\n").replace(/\n/g, "<br>"))
35
+
36
+ removeSuccess: ->
37
+ @setState(success: null) if @isMounted()
38
+
39
+ handleBlur: ->
40
+ @setState(alert: null, success: null) if @isMounted()
41
+
42
+ render: ->
43
+ <div>
44
+ <nav className="navbar navbar-default">
45
+ <div className="container-fluid">
46
+ <div className="navbar-header">
47
+ <Link to="app" className="navbar-brand"><i className="fa fa-fw fa-cog"></i> {@props.site.title}</Link>
48
+ </div>
49
+ <div className="navbar-right">
50
+ <button className="btn btn-primary navbar-btn #{'disabled' if @state.loading}" onClick={@handleSync} onBlur={@handleBlur}>
51
+ <i className="fa fa-fw fa-refresh"></i> Sync
52
+ </button>
53
+ {if @props.site.octodmin.deploys
54
+ deploy = @props.site.octodmin.deploys[0]
55
+
56
+ <button className="btn btn-primary navbar-btn #{'disabled' if @state.loading}" onClick={@handleDeploy} onBlur={@handleBlur}>
57
+ <i className="fa fa-fw fa-ship"></i> Deploy
58
+ </button>
59
+ }
60
+ <a href={@props.site.url} target="_blank" className="btn btn-primary navbar-btn">
61
+ <i className="fa fa-fw fa-external-link"></i> Site
62
+ </a>
63
+ </div>
64
+ </div>
65
+ </nav>
66
+ {<div className="alert alert-danger"><span dangerouslySetInnerHTML={{__html: @state.alert }}></span></div> if @state.alert}
67
+ {<div className="alert alert-success"><span dangerouslySetInnerHTML={{__html: @state.success }}></span></div> if @state.success}
68
+ </div>
69
+ )