redde 0.1.9 → 0.1.10

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: 415d13d5581f203913ddbe74ba59d6fed19125a8
4
- data.tar.gz: 00b8a99f56c2ad97b1d91bb1684529e389237126
3
+ metadata.gz: 4e9c5fd3d5b0a6b212e42d958015be835b3ca326
4
+ data.tar.gz: 211e8ec998cd34478082efba8e8418bc7dad1859
5
5
  SHA512:
6
- metadata.gz: 11ad3b74c37115cd4af58828c23e65fd9c395aedb5e8b2eafaaf719e42193a3da26464dac95ce2d8660fe803eff53fe7d853d97b2da5cdbaeb2506da6984a9f4
7
- data.tar.gz: 3555c40b264141d970ff35cdff80ec0e06ff095ff8891912f3ee23de7ad920bdca83769bdc60354af9d9d2354e365abb85ef60739b42b864ea21671687485a6f
6
+ metadata.gz: 28c5c14c47501b64b6bc181f2e85e8f35ca249acc37e0abaf7cc64236d52eb55ff2b71444c4880cd247b00ef347d15029bb65aaeb5393210ed235a88a6ad86f2
7
+ data.tar.gz: aede49ea623edd9c5d1ea02425500cc238d9f15a6839a8b86335e3a86c53feb2e907e08752a155c33c894221b06edf13f5817bc476946728caac62b55cc05dd0
data/README.md CHANGED
@@ -16,45 +16,66 @@ And then execute:
16
16
 
17
17
  ## Requirements
18
18
 
19
+ ### Gems
20
+
19
21
  Layout requires 'devise' gem with generated user model. If You use another auth solution, feel free to modify partial with user info and logout link.
20
22
 
23
+ ### Assets
24
+
25
+ Add this line to assets precompilation in `config/production.rb`:
26
+
27
+ config.assets.precompile += %w( admin.js admin.css redactor/wym.css )
28
+
21
29
  ## Usage
22
30
 
31
+ ### Layout
32
+
23
33
  To generate admin layout type:
24
34
 
25
35
  rails g redde:layout
26
36
 
27
- To set admin login layout you need to modify application controller:
37
+ To set admin login layout you need to include `Redde::Layout` concern:
38
+
39
+ class ApplicationController < ActionController::Base
40
+ include Redde::Layout
41
+ # Prevent CSRF attacks by raising an exception.
42
+ # For APIs, you may want to use :null_session instead.
43
+ protect_from_forgery with: :exception
44
+ end
45
+
46
+ This concern adds layout switch with:
28
47
 
29
48
  layout :layout_by_resource
30
49
 
50
+ with method `layout_by_resource`:
51
+
31
52
  def layout_by_resource
32
- if devise_controller? && controller_name == "sessions"
53
+ if devise_controller? && controller_name == 'sessions'
33
54
  'login'
34
55
  else
35
- "application"
56
+ 'application'
36
57
  end
37
58
  end
38
59
 
39
- To generate admin views and controller for a model, enter:
60
+ Feel free to change this methos as you need.
40
61
 
41
- rails g redde:scaffold ModelNames
62
+ ### Scaffold
42
63
 
43
- Add `admin.scss` and `admin.js` to assets precompilation in config/production.rb:
64
+ To generate admin views and controller for a model, enter:
44
65
 
45
- config.assets.precompile += %w( admin.js admin.css )
66
+ rails g redde:scaffold ModelNames
46
67
 
47
- ## UrlGenerator
68
+ ### UrlGenerator
48
69
 
49
70
  `Redde::UrlGenerator` - is a small lib to convert title and id to combine url, used in `to_param` method.
50
71
 
51
72
  Usage example:
52
73
 
53
- generator = Redde::UrlGenerator.new(1, 'тестовый заголовок $%##@$@#$')
54
- generator.url
55
- => '1-testovyy-zagolovok'
74
+ generator = Redde::UrlGenerator.new(1, 'тестовый заголовок $%##@$@#$')
75
+ generator.url
76
+ => '1-testovyy-zagolovok'
56
77
 
57
- ## Sluggable
78
+ ### Sluggable
58
79
 
59
80
  `Sluggable` is used to include into model with permanent slugs (similar to permalink).
60
81
 
@@ -67,13 +88,13 @@ Usage example:
67
88
 
68
89
  Book should have title and slug fields.
69
90
 
70
- class Book < ActiveRecord::Base
71
- TITLE_SYMBOL = :name
72
- include Redde::Sluggable
73
- validates :name, presence: true
74
- end
91
+ class Book < ActiveRecord::Base
92
+ TITLE_SYMBOL = :name
93
+ include Redde::Sluggable
94
+ validates :name, presence: true
95
+ end
75
96
 
76
- b = Book.new(name: 'Тестовая книга')
97
+ b = Book.new(name: 'Тестовая книга')
77
98
  b.save
78
99
  b.slug
79
100
  => 'testovaya-kniga'
@@ -83,13 +104,13 @@ Book should have title and slug fields.
83
104
 
84
105
  ## Добавление фотографий
85
106
 
86
- rails g redde:photo
107
+ rails g redde:photo
87
108
 
88
109
  Добавьте в routes.rb единожды
89
110
 
90
111
  concern :imageable do
91
112
  resources :photos, only: [:show, :create, :destroy] do
92
- post 'sort', :on => :collection
113
+ post 'sort', on: :collection
93
114
  end
94
115
  end
95
116
 
@@ -139,18 +160,12 @@ Its neccessary to have joined asset files, change assets debug to false in `conf
139
160
  name: Название
140
161
  descr: Описание
141
162
 
142
- ## WYSIWYG editor note
143
-
144
- To use styles for the WYSIWYG editor, add its styles to precompile in `config/production.rb`:
145
-
146
- config.assets.precompile += %w( redactor/wym.css )
147
-
148
163
  ## Sortable
149
164
 
150
165
  If you have field `position` of integer type in your model, generator will add special column as a hook for sort.
151
166
  You should add POST `sort` action to you routes:
152
167
 
153
- resources :article_categories do
168
+ resources :article_categories do
154
169
  post 'sort', on: :collection
155
170
  end
156
171
 
@@ -0,0 +1,15 @@
1
+ module Redde::Layout
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ layout :layout_by_resource
6
+ end
7
+
8
+ def layout_by_resource
9
+ if devise_controller? && controller_name == 'sessions'
10
+ 'login'
11
+ else
12
+ 'application'
13
+ end
14
+ end
15
+ end
data/lib/redde/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Redde
2
- VERSION = '0.1.9'
2
+ VERSION = '0.1.10'
3
3
  end
data/lib/redde.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'redde/version'
2
- require 'redde/sluggable'
3
- require 'redde/with_photo'
2
+ require 'redde/concerns/sluggable'
3
+ require 'redde/concerns/with_photo'
4
+
4
5
  module Redde
5
6
  require 'generators/redde/layout/layout_generator'
6
7
  require 'generators/redde/scaffold/scaffold_generator'
@@ -1,4 +1,5 @@
1
1
  class ApplicationController < ActionController::Base
2
+ include Redde::Layout
2
3
  # Prevent CSRF attacks by raising an exception.
3
4
  # For APIs, you may want to use :null_session instead.
4
5
  protect_from_forgery with: :exception
@@ -1,12 +1,8 @@
1
- # coding: utf-8
2
-
3
1
  class ArticlesController < ApplicationController
4
-
5
2
  def index
6
3
  end
7
4
 
8
5
  def show
9
6
  @article = Article.find(params[:id])
10
7
  end
11
-
12
- end
8
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redde
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Bovykin
@@ -245,10 +245,11 @@ files:
245
245
  - lib/generators/redde/scaffold/templates/edit.html.haml
246
246
  - lib/generators/redde/scaffold/templates/index.html.haml
247
247
  - lib/redde.rb
248
- - lib/redde/sluggable.rb
248
+ - lib/redde/concerns/layout.rb
249
+ - lib/redde/concerns/sluggable.rb
250
+ - lib/redde/concerns/with_photo.rb
249
251
  - lib/redde/url_generator.rb
250
252
  - lib/redde/version.rb
251
- - lib/redde/with_photo.rb
252
253
  - redde.gemspec
253
254
  - spec/dummy/.rspec
254
255
  - spec/dummy/README.rdoc
File without changes