fullstack-cms 0.3.8 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.8
1
+ 0.3.9
@@ -29,6 +29,15 @@ class Admin::PhotosController < Admin::BaseController
29
29
  def edit
30
30
  end
31
31
 
32
+ def rotate
33
+ @photo ||= Photo.find(params[:id])
34
+ rotation = params[:deg].to_f
35
+ rotation ||= 90
36
+ @photo.rotate!(rotation)
37
+ # flash[:notice] = "The image has been rotated"
38
+ end
39
+
40
+
32
41
  def update
33
42
  @photo.attributes = params[:photo]
34
43
  @photo.save
data/app/models/photo.rb CHANGED
@@ -5,7 +5,7 @@ class Photo < ActiveRecord::Base
5
5
  validates_attachment :image, :presence => true,
6
6
  :size => { :in => 0..2.megabytes }
7
7
 
8
- has_attached :image
8
+ has_attached :image, :processors => [:auto_orient, :rotator]
9
9
 
10
10
  acts_as_taggable
11
11
 
@@ -24,5 +24,22 @@ class Photo < ActiveRecord::Base
24
24
  def to_label
25
25
  image_file_name
26
26
  end
27
+
28
+ # ============
29
+ # = Rotation =
30
+ # ============
31
+
32
+ attr_accessor :rotation_degrees, :rotate
33
+
34
+ def rotate!(degrees = 90)
35
+ self.rotation_degrees ||= degrees
36
+ self.rotate = true
37
+ self.image.reprocess!
38
+ self.save
39
+ end
40
+
41
+ def rotating?
42
+ !self.rotation_degrees.nil? and self.rotate
43
+ end
27
44
 
28
45
  end
@@ -1,7 +1,8 @@
1
- <li class="span2" data-id="<%= photo.id %>">
1
+ <li class="span2" data-id="<%= photo.id %>" data-photo-id='<%= photo.id %>'>
2
2
  <div class="thumbnail">
3
3
  <%= image_tag photo.url(:thumb), :style => "height: 141px" %>
4
4
  <div class="thumbnail-toolbar">
5
+ <%= btn '<i class="icon-repeat"></i>'.html_safe, rotate_admin_photo_path(photo, :deg => 90), :remote => true, :method => :post %>
5
6
  <%= btn '<i class="icon-zoom-in"></i>'.html_safe, photo.url, :rel => "facebox", :'data-tip' => t('fullstack.admin.preview', :default => "Preview") %>
6
7
 
7
8
  <%= btn '<i class="icon-edit"></i>'.html_safe, edit_admin_photo_path(photo), :'data-target' => '#edit-photo-modal', :'data-toggle' => 'modal', :"data-tip" => t('fullstack.admin.edit', :default => "Edit") %>
@@ -0,0 +1,2 @@
1
+ $.notify.success('<%=j t("fullstack.admin.flash.success.update") %>')
2
+ $("[data-photo-id='<%= @photo.id %>'] > .thumbnail > img").attr("src", '<%= @photo.url(:thumb) %>')
data/config/routes.rb CHANGED
@@ -12,6 +12,7 @@ Rails.application.routes.draw do
12
12
  resources :photos, :except => [:new, :index, :show, :create] do
13
13
  get "search", :on => :collection
14
14
  post "create", :format => :js, :on => :collection
15
+ post "rotate", :format => :js, :on => :member
15
16
  end
16
17
 
17
18
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "fullstack-cms"
8
- s.version = "0.3.8"
8
+ s.version = "0.3.9"
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-11-16"
12
+ s.date = "2012-11-22"
13
13
  s.description = "CMS system built on fullstack"
14
14
  s.email = "maurizio.cas@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -68,6 +68,7 @@ Gem::Specification.new do |s|
68
68
  "app/views/admin/photos/create.js.coffee",
69
69
  "app/views/admin/photos/destroy.js.coffee",
70
70
  "app/views/admin/photos/edit.html.erb",
71
+ "app/views/admin/photos/rotate.js.coffee",
71
72
  "app/views/admin/photos/search.js.coffee",
72
73
  "app/views/admin/photos/update.js.coffee",
73
74
  "app/views/admin/settings/_collection.html.erb",
@@ -83,6 +84,8 @@ Gem::Specification.new do |s|
83
84
  "lib/fullstack/cms.rb",
84
85
  "lib/fullstack/cms/configuration.rb",
85
86
  "lib/fullstack/cms/engine.rb",
87
+ "lib/fullstack/paperclip/auto_orient.rb",
88
+ "lib/fullstack/paperclip/rotator.rb",
86
89
  "lib/generators/fullstack/cms/install_generator.rb",
87
90
  "lib/generators/fullstack/cms/locale_generator.rb",
88
91
  "lib/generators/fullstack/cms/templates/rails/app/assets/javascripts/site/lib/jquery.fitvids.js",
data/lib/fullstack/cms.rb CHANGED
@@ -34,6 +34,8 @@ require "whenever"
34
34
  require 'fullstack/cms/engine'
35
35
  require 'fullstack/cms/configuration'
36
36
  require 'bluecloth'
37
+ require 'fullstack/paperclip/rotator'
38
+ require 'fullstack/paperclip/auto_orient'
37
39
 
38
40
  module Fullstack
39
41
  module Cms
@@ -0,0 +1,16 @@
1
+ module Paperclip
2
+ class AutoOrient < Paperclip::Processor
3
+ def initialize(file, options = {}, *args)
4
+ @file = file
5
+ end
6
+
7
+ def make( *args )
8
+ dst = Tempfile.new([@basename, @format].compact.join("."))
9
+ dst.binmode
10
+
11
+ Paperclip.run('convert',"#{File.expand_path(@file.path)} -auto-orient #{File.expand_path(dst.path)}")
12
+
13
+ return dst
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ module Paperclip
2
+ class Rotator < Thumbnail
3
+
4
+ def transformation_command
5
+ rotate = @attachment.instance.rotating? ? @attachment.instance.rotation_degrees : false
6
+ if rotate
7
+ super << "-rotate #{rotate}"
8
+ else
9
+ super
10
+ end
11
+ end
12
+
13
+ end
14
+ end
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.3.8
4
+ version: 0.3.9
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-11-16 00:00:00.000000000 Z
12
+ date: 2012-11-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fullstack-admin
@@ -230,6 +230,7 @@ files:
230
230
  - app/views/admin/photos/create.js.coffee
231
231
  - app/views/admin/photos/destroy.js.coffee
232
232
  - app/views/admin/photos/edit.html.erb
233
+ - app/views/admin/photos/rotate.js.coffee
233
234
  - app/views/admin/photos/search.js.coffee
234
235
  - app/views/admin/photos/update.js.coffee
235
236
  - app/views/admin/settings/_collection.html.erb
@@ -245,6 +246,8 @@ files:
245
246
  - lib/fullstack/cms.rb
246
247
  - lib/fullstack/cms/configuration.rb
247
248
  - lib/fullstack/cms/engine.rb
249
+ - lib/fullstack/paperclip/auto_orient.rb
250
+ - lib/fullstack/paperclip/rotator.rb
248
251
  - lib/generators/fullstack/cms/install_generator.rb
249
252
  - lib/generators/fullstack/cms/locale_generator.rb
250
253
  - lib/generators/fullstack/cms/templates/rails/app/assets/javascripts/site/lib/jquery.fitvids.js
@@ -313,7 +316,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
313
316
  version: '0'
314
317
  segments:
315
318
  - 0
316
- hash: -606859902536209203
319
+ hash: 1349456030531159545
317
320
  required_rubygems_version: !ruby/object:Gem::Requirement
318
321
  none: false
319
322
  requirements: