tkh_illustrations 0.9.3 → 0.9.4
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/app/controllers/downloads_controller.rb +52 -0
- data/app/models/download.rb +14 -0
- data/app/models/header.rb +0 -2
- data/app/models/illustration.rb +0 -2
- data/app/uploaders/image_uploader.rb +2 -1
- data/app/uploaders/thing_uploader.rb +68 -0
- data/app/views/downloads/_form.html.erb +8 -0
- data/app/views/downloads/_section_header.html.erb +2 -0
- data/app/views/downloads/_tab_admin_menu.html.erb +5 -0
- data/app/views/downloads/edit.html.erb +4 -0
- data/app/views/downloads/index.html.erb +31 -0
- data/app/views/downloads/new.html.erb +4 -0
- data/app/views/illustrations/index.html.erb +2 -1
- data/app/views/illustrations/show.html.erb +2 -1
- data/config/routes.rb +1 -0
- data/lib/generators/tkh_illustrations/create_or_update_migrations/create_or_update_migrations_generator.rb +6 -4
- data/lib/generators/tkh_illustrations/create_or_update_migrations/templates/create_downloads.rb +15 -0
- data/lib/tkh_illustrations/version.rb +1 -1
- metadata +13 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9c784f4e79e12e75ab93035079b68cc3cb88140e
|
|
4
|
+
data.tar.gz: 1f943c41f92685c3f05b6a2ded82cf9858fb1d00
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d5382ff5352759cd67e73365185da7f1216e9797010127eef69c6a6ce6598194d795ce273fb036a471f9d99b8d3e427f8134089a7f38bb7b90e536511f6d99f5
|
|
7
|
+
data.tar.gz: ac7a004da61c65e2f81aeb0eeddb762dc7a3913948dbabd2a3063e0fe24b9be91e01164bac9a517ed868cb596e700891eb710362513e6e071fd472f724750e93
|
data/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
class DownloadsController < ApplicationController
|
|
2
|
+
|
|
3
|
+
before_filter :authenticate
|
|
4
|
+
before_filter :authenticate_with_admin
|
|
5
|
+
|
|
6
|
+
def index
|
|
7
|
+
@downloads = Download.by_recent.paginate(:page => params[:page], :per_page => 50)
|
|
8
|
+
switch_to_admin_layout
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def new
|
|
12
|
+
@download = Download.new
|
|
13
|
+
switch_to_admin_layout
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def edit
|
|
17
|
+
@download = Download.find(params[:id])
|
|
18
|
+
switch_to_admin_layout
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def create
|
|
22
|
+
@download = Download.new(download_params)
|
|
23
|
+
if @download.save
|
|
24
|
+
redirect_to downloads_path, notice: 'Your asset has been saved.'
|
|
25
|
+
else
|
|
26
|
+
render action: "new", layout: 'admin'
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def update
|
|
31
|
+
@download = Download.find(params[:id])
|
|
32
|
+
if @download.update_attributes(download_params)
|
|
33
|
+
redirect_to downloads_path, notice: 'Your asset has been saved.'
|
|
34
|
+
else
|
|
35
|
+
render action: "edit", layout: 'admin'
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def destroy
|
|
40
|
+
@download = Download.find(params[:id])
|
|
41
|
+
@download.destroy
|
|
42
|
+
redirect_to downloads_url
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
# Never trust parameters from the scary internet, only allow the white list through.
|
|
48
|
+
def download_params
|
|
49
|
+
params.require(:download).permit(:name, :thing)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class Download < ActiveRecord::Base
|
|
2
|
+
|
|
3
|
+
validates_presence_of :name
|
|
4
|
+
translates :name
|
|
5
|
+
|
|
6
|
+
mount_uploader :thing, ThingUploader
|
|
7
|
+
|
|
8
|
+
def to_param
|
|
9
|
+
name ? "#{id}-#{name.to_url}" : id
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
scope :by_recent, -> { order('updated_at desc') }
|
|
13
|
+
scope :alphabetically, -> { order('name') }
|
|
14
|
+
end
|
data/app/models/header.rb
CHANGED
data/app/models/illustration.rb
CHANGED
|
@@ -48,6 +48,7 @@ class ImageUploader < CarrierWave::Uploader::Base
|
|
|
48
48
|
version(:medium) { process :resize_to_limit => [350, 350] }
|
|
49
49
|
version(:large) { process :resize_to_limit => [450, 450] }
|
|
50
50
|
version(:xl) { process :resize_to_limit => [550, 550] }
|
|
51
|
+
version(:xxl) { process :resize_to_limit => [900, 900] }
|
|
51
52
|
|
|
52
53
|
# Add a white list of extensions which are allowed to be uploaded.
|
|
53
54
|
# For images you might use something like this:
|
|
@@ -60,7 +61,7 @@ class ImageUploader < CarrierWave::Uploader::Base
|
|
|
60
61
|
# def filename
|
|
61
62
|
# "something.jpg" if original_filename
|
|
62
63
|
# end
|
|
63
|
-
|
|
64
|
+
|
|
64
65
|
# got this from http://stackoverflow.com/questions/9561641/carrierwave-temp-directory-set-to-uploads-tmp-folder
|
|
65
66
|
# without this all tmp files would go to /public/uploads/tmp which is not cool at all.
|
|
66
67
|
def cache_dir
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
class ThingUploader < CarrierWave::Uploader::Base
|
|
2
|
+
|
|
3
|
+
# Include RMagick or MiniMagick support:
|
|
4
|
+
include CarrierWave::RMagick
|
|
5
|
+
# include CarrierWave::MiniMagick
|
|
6
|
+
|
|
7
|
+
# Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
|
|
8
|
+
# include Sprockets::Helpers::RailsHelper
|
|
9
|
+
# include Sprockets::Helpers::IsolatedHelper
|
|
10
|
+
|
|
11
|
+
# Choose what kind of storage to use for this uploader:
|
|
12
|
+
storage :file
|
|
13
|
+
# storage :fog
|
|
14
|
+
|
|
15
|
+
# Override the directory where uploaded files will be stored.
|
|
16
|
+
# This is a sensible default for uploaders that are meant to be mounted:
|
|
17
|
+
def store_dir
|
|
18
|
+
# "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" --- that was the suggested one
|
|
19
|
+
"system/things/#{model.class.to_s.underscore}/#{model.id}"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Provide a default URL as a default if there hasn't been a file uploaded:
|
|
23
|
+
# def default_url
|
|
24
|
+
# # For Rails 3.1+ asset pipeline compatibility:
|
|
25
|
+
# # asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
|
|
26
|
+
#
|
|
27
|
+
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
|
|
28
|
+
# end
|
|
29
|
+
|
|
30
|
+
# Process files as they are uploaded:
|
|
31
|
+
# process :scale => [200, 300]
|
|
32
|
+
#
|
|
33
|
+
# def scale(width, height)
|
|
34
|
+
# # do something
|
|
35
|
+
# end
|
|
36
|
+
|
|
37
|
+
# Create different versions of your uploaded files:
|
|
38
|
+
# version :thumb do
|
|
39
|
+
# process :scale => [50, 50]
|
|
40
|
+
# end
|
|
41
|
+
# version :thumbnail do
|
|
42
|
+
# process :resize_to_limit => [125, 125]
|
|
43
|
+
# end
|
|
44
|
+
# version(:thumbnail) { process :resize_to_limit => [125, 125] }
|
|
45
|
+
# version(:small) { process :resize_to_limit => [225, 225] }
|
|
46
|
+
# version(:medium) { process :resize_to_limit => [350, 350] }
|
|
47
|
+
# version(:large) { process :resize_to_limit => [450, 450] }
|
|
48
|
+
# version(:xl) { process :resize_to_limit => [550, 550] }
|
|
49
|
+
|
|
50
|
+
# Add a white list of extensions which are allowed to be uploaded.
|
|
51
|
+
def extension_white_list
|
|
52
|
+
%w(mp3 pdf)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Override the filename of the uploaded files:
|
|
56
|
+
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
|
57
|
+
# def filename
|
|
58
|
+
# "something.jpg" if original_filename
|
|
59
|
+
# end
|
|
60
|
+
|
|
61
|
+
# got this from http://stackoverflow.com/questions/9561641/carrierwave-temp-directory-set-to-uploads-tmp-folder
|
|
62
|
+
# without this all tmp files would go to /public/uploads/tmp which is not cool at all.
|
|
63
|
+
def cache_dir
|
|
64
|
+
# should return path to cache dir
|
|
65
|
+
Rails.root.join 'tmp/uploads'
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<%= simple_form_for @download, :html => { multipart: true, class: 'form-horizontal' } do |f| %>
|
|
2
|
+
<%= f.error_notification %>
|
|
3
|
+
|
|
4
|
+
<%= f.input :thing, label: 'select document or asset' %><br />
|
|
5
|
+
<%= f.input :name, label: 'name' %><br />
|
|
6
|
+
<%= f.button :submit, :class => 'btn btn-primary' %>
|
|
7
|
+
|
|
8
|
+
<% end %>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<ul class="nav nav-tabs" id="admin-menu-tab">
|
|
2
|
+
<%= content_tag :li, link_to(t('new'), new_download_path), ({ class: 'active' } if controller.action_name.to_s == 'new' ) %>
|
|
3
|
+
<%= content_tag :li, link_to(t('list'), downloads_path), ({ class: 'active' } if controller.action_name.to_s == 'index' ) %>
|
|
4
|
+
<%= content_tag :li, link_to(t('edit'), downloads_path), ({ class: 'active' }) if controller.action_name.to_s == 'edit' %>
|
|
5
|
+
</ul>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<%= render 'section_header' %>
|
|
2
|
+
|
|
3
|
+
<%= will_paginate @downloads, inner_window: 2 %>
|
|
4
|
+
|
|
5
|
+
<table class='table table-striped'>
|
|
6
|
+
<thead>
|
|
7
|
+
<tr>
|
|
8
|
+
<th>name</th>
|
|
9
|
+
<th>path</th>
|
|
10
|
+
</tr>
|
|
11
|
+
</thead>
|
|
12
|
+
|
|
13
|
+
<tbody>
|
|
14
|
+
<% @downloads.each do |download| %>
|
|
15
|
+
<tr>
|
|
16
|
+
<td><%= download.name %></td>
|
|
17
|
+
<td><%= link_to download.thing.url, download.thing.url %></td>
|
|
18
|
+
<td>
|
|
19
|
+
<%= link_to t('edit'), edit_download_path(download), class: 'btn btn-xs btn-default' %>
|
|
20
|
+
<%= link_to t('delete'), download, method: :delete, data: { confirm: t('are_you_sure') }, class: 'btn btn-xs btn-danger' %>
|
|
21
|
+
</td>
|
|
22
|
+
</tr>
|
|
23
|
+
<% end %>
|
|
24
|
+
</tbody>
|
|
25
|
+
</table>
|
|
26
|
+
|
|
27
|
+
<%= will_paginate @downloads, inner_window: 2 %>
|
|
28
|
+
|
|
29
|
+
<%= link_to 'upload new asset', new_download_path, class: 'btn btn-default' %>
|
|
30
|
+
|
|
31
|
+
<%= render 'shared/admin_sidebar' %>
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
<b>Small</b> path: <%= illustration.image.small %><br />
|
|
22
22
|
<b>Medium</b> path: <%= illustration.image.medium %><br />
|
|
23
23
|
<b>Large</b> path: <%= illustration.image.large %><br />
|
|
24
|
-
<b>XL</b> path: <%= illustration.image.xl
|
|
24
|
+
<b>XL</b> path: <%= illustration.image.xl %><br />
|
|
25
|
+
<b>XXL</b> path: <%= illustration.image.xxl %>
|
|
25
26
|
</td>
|
|
26
27
|
<td><%= link_to t('edit'), edit_illustration_path(illustration), class: 'btn btn-xs btn-default' %>
|
|
27
28
|
<%= link_to t('delete'), illustration, method: :delete, data: { confirm: t('are_you_sure') }, class: 'btn btn-xs btn-danger' %></td>
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
<%= image_tag @illustration.image.small %><br /><%= @illustration.image.small %><br /><br />
|
|
10
10
|
<%= image_tag @illustration.image.medium %><br /><%= @illustration.image.medium %><br /><br />
|
|
11
11
|
<%= image_tag @illustration.image.large %><br /><%= @illustration.image.large %><br /><br />
|
|
12
|
-
<%= image_tag @illustration.image.xl %><br /><%= @illustration.image.xl
|
|
12
|
+
<%= image_tag @illustration.image.xl %><br /><%= @illustration.image.xl %><br /><br />
|
|
13
|
+
<%= image_tag @illustration.image.xxl %><br /><%= @illustration.image.xxl %>
|
|
13
14
|
</p>
|
|
14
15
|
<br />
|
|
15
16
|
<%= link_to t('edit'), edit_illustration_path(@illustration), :class => 'btn btn-primary' %><%= link_to t('illustrations.all'), illustrations_path, class: 'btn btn-default' %>
|
data/config/routes.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require 'rails/generators/migration'
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
module TkhIllustrations
|
|
4
4
|
module Generators
|
|
5
5
|
class CreateOrUpdateMigrationsGenerator < ::Rails::Generators::Base
|
|
@@ -14,7 +14,7 @@ module TkhIllustrations
|
|
|
14
14
|
end
|
|
15
15
|
@prev_migration_nr.to_s
|
|
16
16
|
end
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
def create_or_update_migrations
|
|
19
19
|
puts 'Creating the illustrations table'
|
|
20
20
|
migration_template "create_illustrations.rb", "db/migrate/create_illustrations.rb"
|
|
@@ -22,8 +22,10 @@ module TkhIllustrations
|
|
|
22
22
|
migration_template "add_translation_of_name_to_illustrations.rb", "db/migrate/add_translation_of_name_to_illustrations.rb"
|
|
23
23
|
puts 'Creating the headers table'
|
|
24
24
|
migration_template "create_headers.rb", "db/migrate/create_headers.rb"
|
|
25
|
+
puts 'Creating the downloads table'
|
|
26
|
+
migration_template "create_downloads.rb", "db/migrate/create_downloads.rb"
|
|
25
27
|
end
|
|
26
|
-
|
|
28
|
+
|
|
27
29
|
end
|
|
28
30
|
end
|
|
29
|
-
end
|
|
31
|
+
end
|
data/lib/generators/tkh_illustrations/create_or_update_migrations/templates/create_downloads.rb
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
class CreateDownloads < ActiveRecord::Migration
|
|
2
|
+
def up
|
|
3
|
+
create_table :downloads do |t|
|
|
4
|
+
t.string :name
|
|
5
|
+
t.string :thing
|
|
6
|
+
t.timestamps
|
|
7
|
+
end
|
|
8
|
+
Download.create_translation_table!({ name: :string })
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def down
|
|
12
|
+
drop_table :downnloads
|
|
13
|
+
Download.drop_translation_table!
|
|
14
|
+
end
|
|
15
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tkh_illustrations
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Swami Atma
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-
|
|
11
|
+
date: 2014-06-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -119,12 +119,21 @@ files:
|
|
|
119
119
|
- MIT-LICENSE
|
|
120
120
|
- README.md
|
|
121
121
|
- Rakefile
|
|
122
|
+
- app/controllers/downloads_controller.rb
|
|
122
123
|
- app/controllers/headers_controller.rb
|
|
123
124
|
- app/controllers/illustrations_controller.rb
|
|
125
|
+
- app/models/download.rb
|
|
124
126
|
- app/models/header.rb
|
|
125
127
|
- app/models/illustration.rb
|
|
126
128
|
- app/uploaders/image_uploader.rb
|
|
127
129
|
- app/uploaders/photo_uploader.rb
|
|
130
|
+
- app/uploaders/thing_uploader.rb
|
|
131
|
+
- app/views/downloads/_form.html.erb
|
|
132
|
+
- app/views/downloads/_section_header.html.erb
|
|
133
|
+
- app/views/downloads/_tab_admin_menu.html.erb
|
|
134
|
+
- app/views/downloads/edit.html.erb
|
|
135
|
+
- app/views/downloads/index.html.erb
|
|
136
|
+
- app/views/downloads/new.html.erb
|
|
128
137
|
- app/views/headers/_form.html.erb
|
|
129
138
|
- app/views/headers/_tab_admin_menu.html.erb
|
|
130
139
|
- app/views/headers/edit.html.erb
|
|
@@ -148,6 +157,7 @@ files:
|
|
|
148
157
|
- lib/generators/tkh_illustrations/create_or_update_locales/templates/it.yml
|
|
149
158
|
- lib/generators/tkh_illustrations/create_or_update_migrations/create_or_update_migrations_generator.rb
|
|
150
159
|
- lib/generators/tkh_illustrations/create_or_update_migrations/templates/add_translation_of_name_to_illustrations.rb
|
|
160
|
+
- lib/generators/tkh_illustrations/create_or_update_migrations/templates/create_downloads.rb
|
|
151
161
|
- lib/generators/tkh_illustrations/create_or_update_migrations/templates/create_headers.rb
|
|
152
162
|
- lib/generators/tkh_illustrations/create_or_update_migrations/templates/create_illustrations.rb
|
|
153
163
|
- lib/tasks/tkh_illustrations_tasks.rake
|
|
@@ -203,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
203
213
|
version: '0'
|
|
204
214
|
requirements: []
|
|
205
215
|
rubyforge_project:
|
|
206
|
-
rubygems_version: 2.2.
|
|
216
|
+
rubygems_version: 2.2.2
|
|
207
217
|
signing_key:
|
|
208
218
|
specification_version: 4
|
|
209
219
|
summary: Rails engine for carrierwave illustrations.
|