cloudpress 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c22e0072d4c6bae605aa3e27c48a9994cc6ce39
4
- data.tar.gz: 1f483e90de1e54f6664222d909fdd680755a8f9c
3
+ metadata.gz: 9090814d1f194ce72382bdc7cd3bb284201ef2d4
4
+ data.tar.gz: 8a4efa8c62ffe354cd15f13da2df2b0760e39501
5
5
  SHA512:
6
- metadata.gz: 8706d4f58e18cc70fb805f3ed87a49a0c5ad8e5e562af96ddb08e72f978c8c629255dac20df20450eade0af13b114d5505fb6f7e16d448c1045895b30cd047e7
7
- data.tar.gz: e505dde59f4e7c38f8bab3c9b02b3da6de535188f84f276a19eafe9f11d171913adbc0bc56dca25204a8721d300fed3dce6c2cff41527936cf5cf0dc963c8dc1
6
+ metadata.gz: 31e42a7d004d973397f93affb9aec5d8361b2fd768b3e1efa0a7d27bb8c35d6bed78cfabb6e0184da01d63f511f06190d0a419195dc12e117d2bb447ae53b360
7
+ data.tar.gz: 4345a2bbafe13ad8719ca8a4ecc1d76302f45bb71872950cac86289c9315f66f5f2f3bcb312c61ea5b4bc3e8d1270a060444a32b9c3ff40c507ba2b543c84f5c
data/README.md CHANGED
@@ -1,8 +1,18 @@
1
1
  # Cloudpress
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/cloudpress`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Who needs Wordpress when you can use CLOUDPRESS!
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ ## What?
6
+
7
+ Cloudpress is a blogging engine that publishes metadown files from Dropbox. It's designed as a fire and forget blogging solution, if you can write a metadown/markdown file then you can publish it without doing anything more than just placing it in a directory on Dropbox.
8
+
9
+ It's designed to be included within a Rails 3.1+ application, and provides a multitude of hooks for you to build your own templates around it.
10
+
11
+ ## Requirements
12
+
13
+ - Rails 3.1+
14
+ - PostgreSQL database
15
+ - Dropbox Account
6
16
 
7
17
  ## Installation
8
18
 
@@ -20,9 +30,65 @@ Or install it yourself as:
20
30
 
21
31
  $ gem install cloudpress
22
32
 
33
+ After that, you will want to copy the migrations into the application
34
+
35
+ $ rake cloudpress:install:migrations
36
+
37
+ And then run the initializer generator, which will ask you to fill in the application ID, log in to dropbox and authorize the application, and then enter the token you're provided with and then write them all in to `config/initializers/cloudpress.rb` you may want to replace them with ENV variables instead of hardcoding them.
38
+
39
+ $ rails g cloudpress:initializer
40
+
41
+ The application ID is `7i1ku4x291czftv` which points to a dropbox application that I've made. If you'd like to create your own, just go ahead and replace that ID with your own applications.
42
+
43
+ After you've done that you can run your initial import.
44
+
45
+ $ rake cloudpress:update
46
+
47
+
48
+ ## Configuration
49
+
50
+ ```ruby
51
+ config.app_key # The application ID, as explained above
52
+ config.app_secret # The app secret, populated by the installer
53
+ config.app_token # The token you pasted in from the installtion
54
+ config.base_path # The path in your dropbox that's considered root
55
+ config.live_path # Where your live files will live under the base_path
56
+ config.draft_path # Draft file location, under the base_path
57
+ config.draft_user # Username for draft HTTP auth, leave as nil for no auth
58
+ config.draft_password # Password for draft HTTP auth, leave as nil for no auth
59
+ ```
60
+
23
61
  ## Usage
24
62
 
25
- TODO: Write usage instructions here
63
+ Cloudpress provides the majority of it's functionality through view helper renderers that you can move around and change to fit with your HTML structure.
64
+
65
+ You can see examples of these within the `views/cloudpress/*` folder, again all of these partial templates can be overriden within your application by adding a `views/cloudpress/*` directory.
66
+
67
+ ## Adding Posts
68
+
69
+ Cloudpress, by default will look in a `cloudpress` directory in the root of your Dropbox. Inside it will create two folders on the first update, `live` and `draft` folders. Cloudpress will search these directories recursivly, so you can use whatever organisational structure suits. I tend just to stick with years, since I don't write enough blog posts!
70
+
71
+ You then just create a `metadown` file with a `md` extension, that reads like this:
72
+
73
+ ```
74
+ ---
75
+ title: The Rails renderer pattern
76
+ publish_date: 24/04/2015 10:30AM
77
+ tags:
78
+ - Ruby
79
+ - Ruby on rails
80
+ - Renderers
81
+ - Views
82
+ ---
83
+ ## Development
84
+ So this is the content...
85
+ ```
86
+
87
+ The first part of the file contains metadata about the post, the second the actual content, all markdown is supported, and uses pygments for code block highighting
88
+
89
+ ## Updating
90
+
91
+ I've got this deployed on Heroku, with a scheduled job to run every 10 mins using the provided rake task, or you can do it programatically by booting a console and typing `Cloudpress.update!`
26
92
 
27
93
  ## Development
28
94
 
@@ -0,0 +1,30 @@
1
+ module Cloudpress
2
+ module Drafts
3
+ class PostsController < ::Cloudpress::PostsController
4
+ http_basic_authenticate_with(Cloudpress.draft_auth_credentials) if Cloudpress.protect_drafts?
5
+
6
+ def index
7
+ super
8
+ flash[:notice] = "Currently viewing draft index, move to the live folder to publish"
9
+ end
10
+
11
+ def show
12
+ super
13
+ flash[:notice] = "This post is currently a draft, move to the live folder to publish"
14
+ end
15
+
16
+ protected
17
+
18
+ def posts
19
+ @posts ||= Cloudpress::Post.draft.page(params[:page])
20
+ end
21
+ helper_method :posts
22
+
23
+ def post
24
+ @post ||= Cloudpress::Post.draft.find_by(slug: params[:slug])
25
+ end
26
+ helper_method :post
27
+
28
+ end
29
+ end
30
+ end
@@ -19,5 +19,17 @@ module Cloudpress
19
19
  Cloudpress::Renderers::Archives.new(self, archives).render
20
20
  end
21
21
 
22
+ def render_flashes
23
+ content_tag(:div, id: 'flashes') do
24
+ flash.map {|k, v| render_flash(k.to_sym) { content_tag(:p, v) } }.join("\n").html_safe
25
+ end
26
+ end
27
+
28
+ def render_flash type, options={}, &block
29
+ renderer = Cloudpress::Renderers::Flash.new(self, type, options)
30
+ renderer.content = capture(&block) if block_given?
31
+ renderer.render
32
+ end
33
+
22
34
  end
23
35
  end
@@ -0,0 +1,3 @@
1
+ div *renderer.flash_html_attributes
2
+ = renderer.icon
3
+ = yield
@@ -18,17 +18,17 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "dropbox-sdk"
22
- spec.add_dependency "metadown"
23
- spec.add_dependency "pygments.rb"
24
- spec.add_dependency "nokogiri"
25
- spec.add_dependency "kaminari"
26
- spec.add_dependency "builder"
27
- spec.add_dependency "groupdate"
28
- spec.add_dependency "slim"
29
- spec.add_dependency "acts-as-taggable-on"
30
- spec.add_dependency "friendly_id"
31
- spec.add_dependency "rails", "~> 4.2.0"
21
+ spec.add_dependency "dropbox-sdk", "~> 1.6.0"
22
+ spec.add_dependency "metadown", "1.1.0.beta"
23
+ spec.add_dependency "pygments.rb", "~> 0.6.0"
24
+ spec.add_dependency "nokogiri", "~> 1.6.6.0"
25
+ spec.add_dependency "kaminari", "~> 0.16.0"
26
+ spec.add_dependency "groupdate", "~> 2.4.0"
27
+ spec.add_dependency "slim", "~> 3.0.0"
28
+ spec.add_dependency "builder", "~> 3.2.0"
29
+ spec.add_dependency "acts-as-taggable-on", "~> 3.5.0"
30
+ spec.add_dependency "friendly_id", "~> 5.1.0"
31
+ spec.add_dependency "rails", "~> 4.2.0"
32
32
 
33
33
  spec.add_development_dependency "bundler", "~> 1.8"
34
34
  spec.add_development_dependency "rake", "~> 10.0"
@@ -1,9 +1,15 @@
1
1
  Cloudpress::Engine.routes.draw do
2
2
 
3
+ namespace :drafts do
4
+ get '/', to: 'posts#index'
5
+ get "*slug", to: 'posts#show'
6
+ end
7
+
3
8
  resources :tags, only: :show
4
9
  resource :archives, path: '/:year(/:month)', only: :show
5
10
 
6
11
  root to: 'posts#index'
12
+
7
13
  get '*slug', to: 'posts#show', as: :post
8
14
 
9
15
  end
@@ -6,6 +6,7 @@ require "kaminari"
6
6
  require "groupdate"
7
7
  require "slim"
8
8
  require "friendly_id"
9
+ require "builder"
9
10
  require "acts-as-taggable-on"
10
11
  require "cloudpress/version"
11
12
  require "cloudpress/engine"
@@ -23,6 +24,7 @@ require "cloudpress/renderers/post"
23
24
  require "cloudpress/renderers/posts"
24
25
  require "cloudpress/renderers/tag"
25
26
  require "cloudpress/renderers/tags"
27
+ require "cloudpress/renderers/flash"
26
28
 
27
29
  module Cloudpress
28
30
 
@@ -34,12 +36,14 @@ module Cloudpress
34
36
 
35
37
  def configure &block
36
38
  @config = ActiveSupport::OrderedOptions.new
37
- @config.app_key = nil
38
- @config.app_secret = nil
39
- @config.app_token = nil
40
- @config.base_path = 'cloudpress'
41
- @config.live_path = 'live'
42
- @config.draft_path = 'draft'
39
+ @config.app_key = nil
40
+ @config.app_secret = nil
41
+ @config.app_token = nil
42
+ @config.base_path = 'cloudpress'
43
+ @config.live_path = 'live'
44
+ @config.draft_path = 'draft'
45
+ @config.draft_user = nil
46
+ @config.draft_password = nil
43
47
  @config.markdown_renderer = Redcarpet::Markdown.new(Formatters::HTMLWithPygments, fenced_code_blocks: true)
44
48
  yield(@config) if block_given?
45
49
  @config
@@ -82,6 +86,17 @@ module Cloudpress
82
86
  }
83
87
  end
84
88
 
89
+ def protect_drafts?
90
+ draft_auth_credentials.keys.compact.any?
91
+ end
92
+
93
+ def draft_auth_credentials
94
+ @draft_auth_credentials ||= {
95
+ name: config.draft_user,
96
+ password: config.draft_password
97
+ }
98
+ end
99
+
85
100
  def client
86
101
  @client ||= Cloudpress::Dropbox::Client.new(config.app_token)
87
102
  end
@@ -0,0 +1,68 @@
1
+ module Cloudpress
2
+ module Renderers
3
+ class Flash
4
+
5
+ attr_accessor :options, :type
6
+ attr_writer :content
7
+ def initialize(context, type, options={})
8
+ @context = context
9
+ @type = type
10
+ @options = options.reverse_merge(default_options)
11
+ end
12
+
13
+ def content
14
+ @content ? @content : @context.content_tag(:p, @context.flash[type])
15
+ end
16
+
17
+ def content?
18
+ !!content
19
+ end
20
+
21
+ def icon
22
+ @context.icon(options[:icon]) if icon?
23
+ end
24
+
25
+ def render
26
+ return nil unless content?
27
+ @context.render(layout: 'cloudpress/flashes/flash', locals: {renderer: self}) do
28
+ content
29
+ end
30
+ end
31
+
32
+ def flash_html_attributes
33
+ {
34
+ id: options[:id],
35
+ class: css_classes
36
+ }.reject { |k, v| v.blank? }
37
+ end
38
+
39
+ private
40
+
41
+ def icon?
42
+ options[:icon].present?
43
+ end
44
+
45
+ def css_classes
46
+ out = []
47
+ out << 'flash'
48
+ out << options[:class]
49
+ out << type.to_s.parameterize
50
+ out.compact.join(' ')
51
+ end
52
+
53
+ def default_options
54
+ {
55
+ icon: icon_map[type]
56
+ }
57
+ end
58
+
59
+ def icon_map
60
+ {
61
+ notice: 'info-circle',
62
+ alert: 'exclamation-triangle'
63
+ }
64
+ end
65
+
66
+ end
67
+ end
68
+ end
@@ -1,3 +1,3 @@
1
1
  module Cloudpress
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -21,9 +21,11 @@ module Cloudpress
21
21
  initializer 'cloudpress.rb' do
22
22
  <<-EOF
23
23
  Cloudpress.configure do |config|
24
- config.app_id = "#{app_key}"
25
- config.app_secret = "#{app_secret}"
26
- config.app_token = "#{token}"
24
+ config.app_key = "#{app_key}"
25
+ config.app_secret = "#{app_secret}"
26
+ config.app_token = "#{token}"
27
+ config.draft_user = nil
28
+ config.draft_password = nil
27
29
  end
28
30
  EOF
29
31
  end
metadata CHANGED
@@ -1,155 +1,155 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudpress
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Carlile
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-24 00:00:00.000000000 Z
11
+ date: 2015-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dropbox-sdk
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 1.6.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 1.6.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: metadown
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 1.1.0.beta
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 1.1.0.beta
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pygments.rb
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 0.6.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 0.6.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: nokogiri
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 1.6.6.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 1.6.6.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: kaminari
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: 0.16.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: 0.16.0
83
83
  - !ruby/object:Gem::Dependency
84
- name: builder
84
+ name: groupdate
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: 2.4.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: 2.4.0
97
97
  - !ruby/object:Gem::Dependency
98
- name: groupdate
98
+ name: slim
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: 3.0.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: 3.0.0
111
111
  - !ruby/object:Gem::Dependency
112
- name: slim
112
+ name: builder
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: 3.2.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: 3.2.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: acts-as-taggable-on
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ">="
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '0'
131
+ version: 3.5.0
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ">="
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '0'
138
+ version: 3.5.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: friendly_id
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ">="
143
+ - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '0'
145
+ version: 5.1.0
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ">="
150
+ - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '0'
152
+ version: 5.1.0
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: rails
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -210,6 +210,7 @@ files:
210
210
  - app/assets/cloudpress/code/railscasts.scss
211
211
  - app/controllers/cloudpress/application_controller.rb
212
212
  - app/controllers/cloudpress/archives_controller.rb
213
+ - app/controllers/cloudpress/drafts/posts_controller.rb
213
214
  - app/controllers/cloudpress/posts_controller.rb
214
215
  - app/controllers/cloudpress/tags_controller.rb
215
216
  - app/helpers/cloudpress/renderer_helper.rb
@@ -220,6 +221,7 @@ files:
220
221
  - app/views/cloudpress/archives/_archives.html.slim
221
222
  - app/views/cloudpress/archives/_month.html.slim
222
223
  - app/views/cloudpress/archives/show.html.slim
224
+ - app/views/cloudpress/flashes/_flash.html.slim
223
225
  - app/views/cloudpress/posts/_intro.html.slim
224
226
  - app/views/cloudpress/posts/_post.html.slim
225
227
  - app/views/cloudpress/posts/index.html.slim
@@ -248,6 +250,7 @@ files:
248
250
  - lib/cloudpress/formatters/html_with_pygments.rb
249
251
  - lib/cloudpress/renderers/archive.rb
250
252
  - lib/cloudpress/renderers/archives.rb
253
+ - lib/cloudpress/renderers/flash.rb
251
254
  - lib/cloudpress/renderers/post.rb
252
255
  - lib/cloudpress/renderers/posts.rb
253
256
  - lib/cloudpress/renderers/tag.rb