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 +4 -4
- data/README.md +42 -27
- data/lib/redde/concerns/layout.rb +15 -0
- data/lib/redde/version.rb +1 -1
- data/lib/redde.rb +3 -2
- data/spec/dummy/app/controllers/application_controller.rb +1 -0
- data/spec/dummy/app/controllers/articles_controller.rb +1 -5
- metadata +4 -3
- /data/lib/redde/{sluggable.rb → concerns/sluggable.rb} +0 -0
- /data/lib/redde/{with_photo.rb → concerns/with_photo.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e9c5fd3d5b0a6b212e42d958015be835b3ca326
|
4
|
+
data.tar.gz: 211e8ec998cd34478082efba8e8418bc7dad1859
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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 ==
|
53
|
+
if devise_controller? && controller_name == 'sessions'
|
33
54
|
'login'
|
34
55
|
else
|
35
|
-
|
56
|
+
'application'
|
36
57
|
end
|
37
58
|
end
|
38
59
|
|
39
|
-
|
60
|
+
Feel free to change this methos as you need.
|
40
61
|
|
41
|
-
|
62
|
+
### Scaffold
|
42
63
|
|
43
|
-
|
64
|
+
To generate admin views and controller for a model, enter:
|
44
65
|
|
45
|
-
|
66
|
+
rails g redde:scaffold ModelNames
|
46
67
|
|
47
|
-
|
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
|
-
|
54
|
-
|
55
|
-
|
74
|
+
generator = Redde::UrlGenerator.new(1, 'тестовый заголовок $%##@$@#$')
|
75
|
+
generator.url
|
76
|
+
=> '1-testovyy-zagolovok'
|
56
77
|
|
57
|
-
|
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
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
91
|
+
class Book < ActiveRecord::Base
|
92
|
+
TITLE_SYMBOL = :name
|
93
|
+
include Redde::Sluggable
|
94
|
+
validates :name, presence: true
|
95
|
+
end
|
75
96
|
|
76
|
-
|
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
|
-
|
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', :
|
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
|
-
|
168
|
+
resources :article_categories do
|
154
169
|
post 'sort', on: :collection
|
155
170
|
end
|
156
171
|
|
data/lib/redde/version.rb
CHANGED
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'
|
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.
|
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/
|
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
|
File without changes
|