winton-app_helpers 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.markdown +108 -0
  3. data/init.rb +7 -0
  4. metadata +59 -0
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Winton Welsh <mail@wintoni.us>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,108 @@
1
+ app_helpers
2
+ ===========
3
+
4
+ A collection of useful Rails application helpers and rake tasks.
5
+
6
+
7
+ Installation
8
+ ------------
9
+
10
+ Add app_helper submodule
11
+
12
+ git submodule add git://github.com:winton/app_helpers.git vendor/plugins/app_helpers
13
+
14
+ Copy resources (**app/views/app_helpers**)
15
+
16
+ rake app_helpers
17
+
18
+
19
+ Rake Tasks
20
+ ----------
21
+
22
+ ### app_helpers
23
+
24
+ Installs **app/views/app_helpers**, which includes a few partials required by `Tbl` and `Template`.
25
+
26
+ ### db:config
27
+
28
+ Prompts for a database name and generates **config/database.yml** for you.
29
+
30
+ ### git:submodule
31
+
32
+ Runs `git:submodule:update`, and `git:submodule:pull`.
33
+
34
+ #### git:submodule:update
35
+
36
+ git submodule init
37
+ git submodule update
38
+
39
+ #### git:submodule:pull
40
+
41
+ Finds submodules in **app/widgets**, **config**, and **vendor/plugins** and runs
42
+
43
+ git checkout master
44
+ git pull
45
+
46
+ on each.
47
+
48
+
49
+ Partials
50
+ --------
51
+
52
+ ### Method: `block_to_partial(partial_name, options = {}, &block)`
53
+
54
+ Sends the output of a block to a partial as the local variable `body`.
55
+
56
+ Example:
57
+
58
+ = block_to_partial 'some_partial', :locals => { :x => 0 } do
59
+ Two local variables will be sent to the partial; 'x' (0) and 'body' (this text).
60
+
61
+
62
+ ### Method: `script_tag_redirect_to(url)`
63
+
64
+ Renders an HTML javascript tag with the code `window.location=url`.
65
+
66
+
67
+ Tbl
68
+ ---
69
+
70
+ ### Method: `tbl(type, name, unit=:px, *widths, &block)`
71
+
72
+ Uses the partials in **app/views/app_helpers/tbl** to generate CSS tables (rows of content with specific column widths).
73
+
74
+ Include the following in your site-wide SASS:
75
+
76
+ .row
77
+ :overflow hidden
78
+ .parent
79
+ :float left
80
+ :display block
81
+
82
+ The view:
83
+
84
+ - tbl :row, :your_identifier, :px, 100, 200, 300 do
85
+ - tbl :cell, :your_identifier do
86
+ Row 1, Cell 1
87
+ - tbl :cell, :your_identifier do
88
+ Row 1, Cell 2
89
+ - tbl :cell, :your_identifier do
90
+ Row 1, Cell 3
91
+ - tbl :cell, :your_identifier do
92
+ Row 2, Cell 1
93
+ - tbl :cell, :your_identifier do
94
+ Row 2, Cell 2
95
+ - tbl :cell, :your_identifier do
96
+ Row 2, Cell 3
97
+
98
+ *Note*: Change `:px` to `'%'` for percentage widths.
99
+
100
+ See [rails_widget](https://github.com/winton/rails_widget) for a javascript implementation of Tbl.
101
+
102
+
103
+ Truncate
104
+ --------
105
+
106
+ ### Method: `better_truncate(text, length = 80, truncate_string = "...")`
107
+
108
+ Like `truncate`, but does the job without cutting words in half.
data/init.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'app_helpers'
2
+
3
+ ActionView::Base.send :include, AppHelpers
4
+ ActionController::Base.send :include, AppHelpers
5
+ ActionController::Base.class_eval do
6
+ public :render_to_string
7
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: winton-app_helpers
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Winton Welsh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-08-16 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: A collection of useful Rails application helpers and rake tasks
17
+ email: mail@wintoni.us
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - init.rb
26
+ - lib/*
27
+ - lib/**/*
28
+ - MIT-LICENSE
29
+ - README.markdown
30
+ - resources/**/*
31
+ - tasks/*
32
+ has_rdoc: false
33
+ homepage: http://github.com/winton/app_helpers
34
+ post_install_message:
35
+ rdoc_options: []
36
+
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ version:
51
+ requirements: []
52
+
53
+ rubyforge_project:
54
+ rubygems_version: 1.2.0
55
+ signing_key:
56
+ specification_version: 2
57
+ summary: A collection of useful Rails application helpers and rake tasks
58
+ test_files: []
59
+