miniblog 1.0.1 → 1.0.2

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: d54d3bc5bcfd7b4145d2e708b9847ece63426654
4
- data.tar.gz: a1b14b97178255676bf2d367685df76e9ce84250
3
+ metadata.gz: 2a466ec7b35b784155fc9b222f59833f3435726d
4
+ data.tar.gz: 70463600dd0dc16bd441e3a33e6dd47e3b2ee0e3
5
5
  SHA512:
6
- metadata.gz: d3ea5d7eb7cbf8a66855bda19092bebf72c7eff496f05cd2fb61df5b7c208a50885558b27c7bf13c68544a046ad60dd5bb9deb6c1980062fe76590889961a278
7
- data.tar.gz: 5ed5e9c46e50bf392287a0d8fe7a234ce4bb09410d036122dbc91be913ca4be73a3d4599cb4928e58224a25e080964228dc87257f38c215760c0fa1d68d7b736
6
+ metadata.gz: 20958471fc1859dc838b7caba3a71deac578ca7f5aedc25b4a4bc52a51f8f04ebac3b30779e327a2836a38a3472d3009c019a8c79e9f10e920d86b703a1e3242
7
+ data.tar.gz: 8f312e08948ab1e3b46fbed1d4fab53205880c3079766f2912e4b547e437dbd9e7b4f78670ef5e77c8d0c8a03cef2390aad6d2648e1d85636759e07dfc57052f
@@ -41,6 +41,8 @@ module Miniblog
41
41
  end
42
42
 
43
43
  def update
44
+ handle_asset
45
+
44
46
  if @post.update_attributes(post_params)
45
47
  if @post.allowed_to_update_permalink?
46
48
  @post.regenerate_permalink
@@ -58,7 +60,16 @@ module Miniblog
58
60
  end
59
61
 
60
62
  def post_params
61
- params.require(:post).permit(:title, :body, :updated_by, :ready_for_review, :transition)
63
+ @params ||= params.require(:post).
64
+ permit(:title, :body, :updated_by, :ready_for_review, :transition,
65
+ { asset: [ :attachment ]})
66
+ end
67
+
68
+ def handle_asset
69
+ if asset_params = post_params.delete(:asset)
70
+ @asset = @post.assets.build(asset)
71
+ @asset.attachment = asset_params[:attachment]
72
+ end
62
73
  end
63
74
  end
64
75
  end
@@ -1,4 +1,4 @@
1
- module Miniblog
1
+ module Miniblog
2
2
  class Asset < ActiveRecord::Base
3
3
  belongs_to :post
4
4
 
@@ -3,6 +3,7 @@ module Miniblog
3
3
  belongs_to :author, :class_name => Miniblog.author_user_class_name
4
4
  belongs_to :publisher, :class_name => Miniblog.publisher_user_class_name
5
5
  has_many :assets
6
+ accepts_nested_attributes_for :assets
6
7
 
7
8
  delegate :name, to: :author, prefix: true, allow_nil: true
8
9
  delegate :email, to: :author, prefix: true, allow_nil: true
@@ -7,4 +7,16 @@
7
7
  <%= f.label :body %>
8
8
  <%= f.text_area :body, class: "form-control", rows: 20 %>
9
9
  </div>
10
+ <%- if f.object.persisted? %>
11
+ <ul>
12
+ <%- f.object.assets.each do |asset| %>
13
+ <li>![](<%= asset.attachment.url %>)</li>
14
+ <% end %>
15
+ </ul>
16
+ <%= f.fields_for f.object.assets.build do |ff| %>
17
+ <div class="form-group">
18
+ <%= ff.file_field :attachment, class: "form-control" %>
19
+ </div>
20
+ <% end %>
21
+ <% end %>
10
22
  </div>
@@ -1,3 +1,3 @@
1
1
  module Miniblog
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: miniblog
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Padilla
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-30 00:00:00.000000000 Z
11
+ date: 2015-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -294,7 +294,6 @@ files:
294
294
  - app/uploaders/attachment_uploader.rb
295
295
  - app/views/layouts/miniblog/admin/base.html.erb
296
296
  - app/views/miniblog/admin/posts/_form.html.erb
297
- - app/views/miniblog/admin/posts/_form.html.slim
298
297
  - app/views/miniblog/admin/posts/_post.html.erb
299
298
  - app/views/miniblog/admin/posts/_post.html.slim
300
299
  - app/views/miniblog/admin/posts/edit.html.erb
@@ -1,27 +0,0 @@
1
- .row
2
- .span12
3
- .control-group.title
4
- = f.label :title, :class => 'control-label'
5
- .controls
6
- = f.text_field :title, :class => "input-xlarge span5"
7
- span.help-inline.title
8
-
9
- .row
10
- .control-group.body
11
- .span12
12
- = label_tag 'post_body', 'Body', class: 'control-label'
13
- .controls.span5
14
- = f.text_area :body, :class => "span5", :rows => 20
15
- span.help-inline= link_to 'Markdown syntax', 'http://daringfireball.net/projects/markdown/syntax', target: '_BLANK'
16
-
17
- #post-preview.span7
18
- .inner
19
-
20
- .row.form-box
21
- .span5
22
- #uploader
23
- .inner Drop images...
24
-
25
- .span7#assets
26
- - f.object.assets.each do |asset|
27
- .asset= "![image alt](#{asset.attachment_url})"