fullstack-cms 0.1.7 → 0.1.8

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.7
1
+ 0.1.8
@@ -0,0 +1,43 @@
1
+ class Admin::PhotosController < Admin::BaseController
2
+ respond_to :html, :js
3
+ layout false
4
+
5
+ def create
6
+ photographable_id = params[:photographable_id]
7
+ photographable_class = params[:photographable_type].constantize
8
+ @photographable = photographable_class.find(photographable_id)
9
+
10
+ if @photographable.respond_to?(:photos) # <- has_many :photos
11
+ @photo = @photographable.photos.build({:image => params[:file]})
12
+ else # <- has_one :photo
13
+ @photo = @photographable.build_photo({:image => params[:file]})
14
+ end
15
+
16
+ if @photo.save
17
+ respond_with(@photo)
18
+ else
19
+ render :status => 500
20
+ end
21
+
22
+ end
23
+
24
+ def search
25
+ @photos = Photo.tagged_with(params[:q]).page(params[:page])
26
+ respond_with(@photos)
27
+ end
28
+
29
+ def edit
30
+ end
31
+
32
+ def update
33
+ @photo.attributes = params[:photo]
34
+ @photo.save
35
+ respond_with(@photo)
36
+ end
37
+
38
+ def destroy
39
+ @photo.destroy
40
+ respond_with(@photo)
41
+ end
42
+
43
+ end
@@ -0,0 +1,7 @@
1
+ module PhotosHelper
2
+
3
+ def photo_uploader(photographable)
4
+ render :partial => "admin/photos/photo_uploader", :locals => {:photographable => photographable}
5
+ end
6
+
7
+ end
data/app/models/page.rb CHANGED
@@ -24,6 +24,6 @@ class Page < ActiveRecord::Base
24
24
  end
25
25
 
26
26
  has_many :page_parts
27
- accepts_nested_attributes_for :page_parts
27
+ accepts_nested_attributes_for :page_parts, :allow_destroy => true
28
28
 
29
29
  end
data/app/models/photo.rb CHANGED
@@ -7,6 +7,8 @@ class Photo < ActiveRecord::Base
7
7
  :large => ["800x600", :jpeg],
8
8
  :thumb => ["100x100", :jpeg]
9
9
  }
10
+
11
+ acts_as_taggable
10
12
 
11
13
  validates_presence_of :photographable
12
14
  belongs_to :photographable, :polymorphic => :true
@@ -0,0 +1,5 @@
1
+ <%= f.resource_inputs %>
2
+
3
+ <% if partial?("other_fields") %>
4
+ <%= render :partial => "other_fields" %>
5
+ <% end %>
@@ -0,0 +1,18 @@
1
+ <% if current_resource && current_resource.respond_to?(:photos) %>
2
+
3
+ <%= tabs do |t| %>
4
+ <%= t.pane t('fullstack.admin.info', :default => "Info") do %>
5
+
6
+ <%= render :partial => "simple_form" %>
7
+
8
+ <% end %>
9
+ <%= t.pane t('fullstack.admin.resources.photos', :default => "Photos") do %>
10
+
11
+ <%= photo_uploader(current_resource) %>
12
+
13
+ <% end %>
14
+ <% end %>
15
+
16
+ <% else %>
17
+ <%= render :partial => "simple_form" %>
18
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <%= admin_form_for [:"admin", current_resource], :html => {:multipart => true} do |f| -%>
2
+
3
+ <%= f.errors %>
4
+ <%= render :partial => "fields", :locals => {:f => f} %>
5
+
6
+ <%= f.actions do %>
7
+ <%= f.resource_submit %>
8
+ <% end %>
9
+
10
+ <% end -%>
@@ -0,0 +1,10 @@
1
+ <li class="span3">
2
+ <div class="thumbnail">
3
+ <%= image_tag photo.url(:thumb), :style => "height: 140px", :'data-zoom-url' => photo.url %>
4
+ <div class="thumbnail-toolbar">
5
+ <%= btn t('fullstack.admin.edit', :default => "Edit"), edit_admin_photo_path(photo), :'data-target' => '#edit-photo-modal', :'data-toggle' => 'modal' %>
6
+ <%= btn '', admin_photo_path(photo), :remote => true, :method => :delete, :confirm => t('fullstack.admin.are_you_sure', :default => "Are you sure?"), :icon => :trash, :type => :danger, :icon_color => :white, :'data-tip' => t('fullstack.admin.delete', :default => "Delete") %>
7
+ </div>
8
+ </div>
9
+ </li>
10
+
@@ -0,0 +1,33 @@
1
+ <% if photographable.new_record? %>
2
+ <div class="alert">
3
+ <%= t('fullstack.admin.save_this_document_before', :default => "You should save this document before") %>
4
+ </div>
5
+ <% else %>
6
+
7
+ <div class="gallery mb1" id="photos">
8
+
9
+ <%= btn t('fullstack.admin.upload', :default => "Upload"),
10
+ :icon => :upload,
11
+ :"icon_color" => :white,
12
+ :"data-toggle" => "collapse",
13
+ :"data-target" => "#photo-uploader", :type => :success %>
14
+
15
+ <div id="photo-uploader" class="photo-uploader collapse"
16
+ data-session-key="<%= request.session_options[:key] %>"
17
+ data-session-id="<%= request.session_options[:id] %>"
18
+ data-url="<%= admin_photos_path(:photographable_id => photographable.id, :photographable_type => photographable.class.name) %>">
19
+ </div>
20
+
21
+
22
+ <h4 class="page-header"><%= t('fullstack.admin.resources.photos', :default => "Photos") %> <span class="badge counter"><%= photographable.photos.size %></span></h4>
23
+
24
+ <ul class="thumbnails">
25
+ <% photographable.photos.order('created_at DESC').each do |photo| %>
26
+ <%= render :partial => "admin/photos/photo", :locals => {:photo => photo} %>
27
+ <% end %>
28
+ </ul>
29
+
30
+ </div>
31
+
32
+ <div class="modal fade" id="edit-photo-modal"></div>
33
+ <% end %>
@@ -0,0 +1,9 @@
1
+ <div>
2
+ <% @photos.each do |photo| %>
3
+ <div class="thumbnail">
4
+ <%= image_tag photo.url(:thumb) %>
5
+ </div>
6
+ <% end %>
7
+ </div>
8
+
9
+ <%= paginate(@photos) %>
@@ -0,0 +1,8 @@
1
+ <% if @photo.errors.empty? %>
2
+ new_elem = $('<%=j render(@photo) %>')
3
+ new_elem.hide()
4
+ $("#photos .thumbnails").prepend(new_elem)
5
+ $("#photos .counter").text('<%= @photo.photographable.photos.count %>').effect("highlight", {}, 1000)
6
+ new_elem.fadeIn('slow')
7
+ <% end %>
8
+
@@ -0,0 +1,8 @@
1
+ <% if @photo.destroyed? %>
2
+ $("a[data-method='delete']").filter("[href='<%=j request.path %>']").closest(".thumbnail_span").fadeOut 'slow', -> $(this).remove()
3
+
4
+ console.log("'<%=j request.path %>']")
5
+ $("#photos .counter").text('<%= @photo.photographable.photos.count %>').effect("highlight", {}, 1000)
6
+ <% else %>
7
+ $.notify.error('<%=j t("flash.error.delete") %>')
8
+ <% end %>
@@ -0,0 +1,41 @@
1
+ <%= semantic_form_for @photo, :url => admin_photo_path(@photo), :remote => true do |f| -%>
2
+ <div class="modal-header">
3
+ <a href="#" class="close" data-dismiss="modal" data-target="#photo-edit-modal">×</a>
4
+ <h3><%= t('fullstack.admin.edit', :default => "Edit") %> <%= t('fullstack.admin.resources.photo', :default => "Photo") %></h3>
5
+ </div>
6
+ <div class="modal-body">
7
+ <%= f.inputs do %>
8
+ <% if @photo.respond_to?(:tags) %>
9
+ <%= f.input :tag_list, :as => :tags, :autocomplete => admin_tags_path, :input_html => {:id => "edit_tags_for_photo"} %>
10
+
11
+ <script type="text/javascript" charset="utf-8">
12
+
13
+ $("#edit_tags_for_photo").each(function() {
14
+ var autocomplete_url, defaultText, taglist;
15
+ taglist = $(this);
16
+ autocomplete_url = taglist.data("autocomplete");
17
+ defaultText = taglist.data("text") || '<%= t('fullstack.admin.add', :default => "Add") %>';
18
+ return taglist.tagsInput({
19
+ autocomplete_url: autocomplete_url,
20
+ autocomplete: {
21
+ minLength: 3
22
+ },
23
+ defaultText: defaultText,
24
+ minChars: 3
25
+ });
26
+ });
27
+
28
+ </script>
29
+
30
+
31
+ <% end %>
32
+ <%= f.input :caption %>
33
+ <% end -%>
34
+
35
+ </div>
36
+ <div class="modal-footer">
37
+ <span class="alert alert-inline hide"></span>
38
+ <a href="#" class="btn" data-dismiss="modal" data-target="#photo-edit-modal"><%= t('fullstack.admin.cancel', :default => "Cancel") %></a>
39
+ <button class="btn btn-primary"><%= t('fullstack.admin.update', :default => "Update") %></button>
40
+ </div>
41
+ <% end -%>
@@ -0,0 +1 @@
1
+ $("#photo-search-results").empty().append('<%=j render(:partial => "support/photos/search_results") %>')
@@ -0,0 +1,7 @@
1
+ <% if @photo.errors.empty? %>
2
+ $('#edit-photo-modal .alert').fadeIn('slow').addClass('alert-success').text('<%=j t("fullstack.admin.flash.success.update") %>')
3
+ <% else %>
4
+ $('#edit-photo-modal .alert').fadeIn('slow').addClass('alert-error').text('<%=j t("fullstack.admin.flash.error.update") %>')
5
+ <% end %>
6
+ setTimeout ( -> $('#edit-photo-modal .notifies').fadeOut('slow') ), 3000
7
+
@@ -2,10 +2,4 @@ it:
2
2
  fullstack:
3
3
  cms:
4
4
  advanced_settings: "Impostazioni avanzate"
5
- # links:
6
- # links: "Link"
7
- # choose_a_page_by_title: "Scegli una pagina"
8
- # insert_by_hand: "Inserimento manuale"
9
- # add_link: "Aggiungi link"
10
- # link_a_page: "Collega una pagina"
11
- #
5
+
data/config/routes.rb CHANGED
@@ -1,11 +1,15 @@
1
1
  Rails.application.routes.draw do
2
2
  namespace :admin do
3
3
 
4
- resources :pages, :only => [ :index, :edit, :update, :destroy ] do
5
- resources :page_parts, :only => [ :update, :destroy ]
6
- end
4
+ resources :pages, :only => [ :index, :edit, :update, :destroy ]
7
5
 
8
6
  resources :tags, :only => :index, :format => :json
9
7
  resources :users, :except => [:show]
8
+
9
+ resources :photos, :except => [:new, :index, :show, :create] do
10
+ get "search", :on => :collection
11
+ post "create", :format => :js, :on => :collection
12
+ end
13
+
10
14
  end
11
15
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "fullstack-cms"
8
- s.version = "0.1.7"
8
+ s.version = "0.1.8"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["mcasimir"]
12
- s.date = "2012-08-19"
12
+ s.date = "2012-08-20"
13
13
  s.description = "CMS system built on fullstack"
14
14
  s.email = "maurizio.cas@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -25,12 +25,14 @@ Gem::Specification.new do |s|
25
25
  "app/controllers/admin/menus_controller.rb",
26
26
  "app/controllers/admin/page_parts_controller.rb",
27
27
  "app/controllers/admin/pages_controller.rb",
28
+ "app/controllers/admin/photos_controller.rb",
28
29
  "app/controllers/admin/settings_controller.rb",
29
30
  "app/controllers/admin/tags_controller.rb",
30
31
  "app/controllers/admin/users_controller.rb",
31
32
  "app/helpers/menus_helper.rb",
32
33
  "app/helpers/mobile_helper.rb",
33
34
  "app/helpers/pages_helper.rb",
35
+ "app/helpers/photos_helper.rb",
34
36
  "app/helpers/settings_helper.rb",
35
37
  "app/models/.gitkeep",
36
38
  "app/models/attachment.rb",
@@ -46,8 +48,19 @@ Gem::Specification.new do |s|
46
48
  "app/models/text.rb",
47
49
  "app/models/text_page_part.rb",
48
50
  "app/models/text_with_title_page_part.rb",
51
+ "app/views/admin/base/_fields.html.erb",
52
+ "app/views/admin/base/_form.html.erb",
53
+ "app/views/admin/base/_simple_form.html.erb",
49
54
  "app/views/admin/pages/_collection.html.erb",
50
55
  "app/views/admin/pages/_form.html.erb",
56
+ "app/views/admin/photos/_photo.html.erb",
57
+ "app/views/admin/photos/_photo_uploader.html.erb",
58
+ "app/views/admin/photos/_search_results.html.erb",
59
+ "app/views/admin/photos/create.js.coffee",
60
+ "app/views/admin/photos/destroy.js.coffee",
61
+ "app/views/admin/photos/edit.html.erb",
62
+ "app/views/admin/photos/search.js.coffee",
63
+ "app/views/admin/photos/update.js.coffee",
51
64
  "app/views/admin/settings/_collection.html.erb",
52
65
  "app/views/admin/settings/_form.html.erb",
53
66
  "app/views/admin/users/_form.html.erb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fullstack-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-19 00:00:00.000000000 Z
12
+ date: 2012-08-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fullstack
@@ -203,12 +203,14 @@ files:
203
203
  - app/controllers/admin/menus_controller.rb
204
204
  - app/controllers/admin/page_parts_controller.rb
205
205
  - app/controllers/admin/pages_controller.rb
206
+ - app/controllers/admin/photos_controller.rb
206
207
  - app/controllers/admin/settings_controller.rb
207
208
  - app/controllers/admin/tags_controller.rb
208
209
  - app/controllers/admin/users_controller.rb
209
210
  - app/helpers/menus_helper.rb
210
211
  - app/helpers/mobile_helper.rb
211
212
  - app/helpers/pages_helper.rb
213
+ - app/helpers/photos_helper.rb
212
214
  - app/helpers/settings_helper.rb
213
215
  - app/models/.gitkeep
214
216
  - app/models/attachment.rb
@@ -224,8 +226,19 @@ files:
224
226
  - app/models/text.rb
225
227
  - app/models/text_page_part.rb
226
228
  - app/models/text_with_title_page_part.rb
229
+ - app/views/admin/base/_fields.html.erb
230
+ - app/views/admin/base/_form.html.erb
231
+ - app/views/admin/base/_simple_form.html.erb
227
232
  - app/views/admin/pages/_collection.html.erb
228
233
  - app/views/admin/pages/_form.html.erb
234
+ - app/views/admin/photos/_photo.html.erb
235
+ - app/views/admin/photos/_photo_uploader.html.erb
236
+ - app/views/admin/photos/_search_results.html.erb
237
+ - app/views/admin/photos/create.js.coffee
238
+ - app/views/admin/photos/destroy.js.coffee
239
+ - app/views/admin/photos/edit.html.erb
240
+ - app/views/admin/photos/search.js.coffee
241
+ - app/views/admin/photos/update.js.coffee
229
242
  - app/views/admin/settings/_collection.html.erb
230
243
  - app/views/admin/settings/_form.html.erb
231
244
  - app/views/admin/users/_form.html.erb
@@ -293,7 +306,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
293
306
  version: '0'
294
307
  segments:
295
308
  - 0
296
- hash: -4076333191029679299
309
+ hash: -35735827444127195
297
310
  required_rubygems_version: !ruby/object:Gem::Requirement
298
311
  none: false
299
312
  requirements: