shakes 0.4.0 → 0.4.1
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/README.md
CHANGED
|
@@ -54,9 +54,10 @@ and that view will be used.
|
|
|
54
54
|
Change The Default Actions
|
|
55
55
|
--------------------------
|
|
56
56
|
You can change the default actions that Shakes uses. First you need to install the Shakes initializer at
|
|
57
|
-
`config/initializers/shakes.rb`. Run the following command to install the initialization file
|
|
57
|
+
`config/initializers/shakes.rb`. Run the following command to install the initialization file (this will also generate a
|
|
58
|
+
Shakes aware layout):
|
|
58
59
|
|
|
59
|
-
script/generate
|
|
60
|
+
script/generate shakes
|
|
60
61
|
|
|
61
62
|
Then you can create your new default implementation for you custom default action. For example, to change the index
|
|
62
63
|
action I would create a module like so:
|
|
@@ -81,66 +82,49 @@ placed in `app/views/shakes`:
|
|
|
81
82
|
|
|
82
83
|
script/generate shakes_views
|
|
83
84
|
|
|
84
|
-
Now, if I wanted
|
|
85
|
+
Now, if I wanted the show view to render like the original scaffold markup, I could do that by modifying
|
|
86
|
+
`app/views/shakes/show.html.erb` to the following:
|
|
85
87
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
</p>
|
|
94
|
-
<% end -%>
|
|
95
|
-
<% end -%>
|
|
96
|
-
|
|
97
|
-
<%- if @controller_class.new.respond_to? :edit %>
|
|
98
|
-
<%= link_to 'Edit', method("edit_#{@resource_instance_name}_path".to_sym).call(@resource) %>
|
|
99
|
-
<% end -%>
|
|
100
|
-
<%- if @controller_class.new.respond_to? :edit and @controller_class.new.respond_to? :index %>
|
|
101
|
-
|
|
|
102
|
-
<% end -%>
|
|
103
|
-
<%- if @controller_class.new.respond_to? :index %>
|
|
104
|
-
<%= link_to "Back", method("#{@resource_collection_name}_path".to_sym).call %>
|
|
105
|
-
<% end -%>
|
|
106
|
-
|
|
107
|
-
Formtastic Aware Layouts
|
|
108
|
-
------------------------
|
|
109
|
-
The default `new` and `edit` view implementations use Formtastic to create the form HTML. To get the most out of
|
|
110
|
-
Formtastic, I suggest you install and use the stylesheets that are included in the gem. See the section on Formtastic
|
|
111
|
-
Aware Layouts above to see how this can be done automatically for you.
|
|
88
|
+
<%- shakes_fields_for(:show).each do |field| -%>
|
|
89
|
+
<% content_tag :p do %>
|
|
90
|
+
<%= content_tag :b, shakes_human_attribute_name_for(field) %>
|
|
91
|
+
<%= h @resource[field] %>
|
|
92
|
+
<% end %>
|
|
93
|
+
<%- end -%>
|
|
94
|
+
<%= shakes_link_to_for([:edit, :index], @resource) %>
|
|
112
95
|
|
|
113
|
-
|
|
96
|
+
Alternatively, I could have just created `app/views/shakes/show.html.erb` without running the generator if that's all I
|
|
97
|
+
wanted to change.
|
|
114
98
|
|
|
115
|
-
|
|
99
|
+
Finally, there are two configuration options available when rendering Shakes views. They tell Shakes to use
|
|
100
|
+
[Formtastic](http://github.com/justinfrench/formtastic/) to render forms and Markdown to render text fields
|
|
101
|
+
respectively. They both default to `false`. To change one or both to `true` you need to install the Shakes initializer.
|
|
102
|
+
You can do that by running the following command (this will also generate a Shakes aware layout):
|
|
103
|
+
|
|
104
|
+
script/generate shakes
|
|
105
|
+
|
|
106
|
+
Than you can modify `config/initializers/shakes.rb` like so:
|
|
116
107
|
|
|
117
|
-
|
|
108
|
+
# Should Shakes attempt to use formtastic to render forms. Default is false
|
|
109
|
+
Shakes::Helpers::ViewsHelper::Configuration.use_formtastic = true
|
|
118
110
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
<%= formtastic_stylesheet_link_tag %>
|
|
122
|
-
...
|
|
123
|
-
</head>
|
|
111
|
+
# Should Shakes attempt to use markdown to display text fields. Default is false
|
|
112
|
+
Shakes::Helpers::ViewsHelper::Configuration.use_markdown = true
|
|
124
113
|
|
|
125
|
-
|
|
126
|
-
|
|
114
|
+
|
|
115
|
+
Shakes Aware Layouts
|
|
116
|
+
--------------------
|
|
117
|
+
To get the most out of Shakes, I suggest you install and use the stylesheets that are included in the gem. Run the
|
|
118
|
+
following command to install the stylesheets and create a version of `app/views/layouts/application.html.erb` that
|
|
119
|
+
includes them for you:
|
|
127
120
|
|
|
128
121
|
script/generate shakes_layout
|
|
129
122
|
|
|
130
123
|
Additionally, you can create more named layouts by running the command and passing the layout name. For example, the
|
|
131
|
-
following command will create a new
|
|
124
|
+
following command will create a new Shakes aware layout at `app/views/layouts/article.html.erb`:
|
|
132
125
|
|
|
133
126
|
script/generate shakes_layout article
|
|
134
127
|
|
|
135
|
-
See the [Formtastic](http://github.com/justinfrench/formtastic) project page for more information.
|
|
136
|
-
|
|
137
|
-
You Can Have It All
|
|
138
|
-
-------------------
|
|
139
|
-
You can create the customizable default views and actions and the application layout in one easy step. Just run the
|
|
140
|
-
following command and it will run the `shakes_actions`, `shakes_views` and `shakes_layout` generators all at once:
|
|
141
|
-
|
|
142
|
-
script/generate shakes
|
|
143
|
-
|
|
144
128
|
TODO
|
|
145
129
|
----
|
|
146
|
-
* Test against Rails 3
|
|
130
|
+
* Test against Rails 3
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<%= resource[field].length > 255 ? content_tag(:span, "#{resource[field][0,252]}...", :title => resource[field]) : shakedown(resource[field]) %>
|
|
1
|
+
<%= resource[field].length > 255 ? content_tag(:span, shakedown("#{resource[field][0,252]}..."), :title => h(resource[field])) : shakedown(resource[field]) %>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
<%= content_tag :label, shakes_human_attribute_name_for(field).titleize %>
|
|
2
|
-
<%= content_tag :span, resource[field] %>
|
|
2
|
+
<%= content_tag :span, h(resource[field]) %>
|
|
@@ -6,7 +6,6 @@ class ShakesViewsGenerator < Rails::Generator::Base
|
|
|
6
6
|
def manifest
|
|
7
7
|
record do |m|
|
|
8
8
|
m.directory 'app/views/shakes'
|
|
9
|
-
m.file '../../../app/views/shakes/_form.html.erb', "app/views/shakes/_form.html.erb"
|
|
10
9
|
m.file '../../../app/views/shakes/edit.html.erb', "app/views/shakes/edit.html.erb"
|
|
11
10
|
m.file '../../../app/views/shakes/index.html.erb', "app/views/shakes/index.html.erb"
|
|
12
11
|
m.file '../../../app/views/shakes/new.html.erb', "app/views/shakes/new.html.erb"
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: shakes
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 13
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 4
|
|
9
|
-
-
|
|
10
|
-
version: 0.4.
|
|
9
|
+
- 1
|
|
10
|
+
version: 0.4.1
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Jason Stahl
|