rails-theme-helper 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rails-theme-helper.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Tse-Ching Ho
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # RailsThemeHelper
2
+
3
+ This gem helps you build themes for rails.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rails-theme-helper'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rails-theme-helper
18
+
19
+ ## Usage
20
+
21
+
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,8 @@
1
+ #site-name
2
+ h1
3
+ a
4
+ padding: 0
5
+ margin-left: 0
6
+ margin-right: 10px
7
+ h2
8
+ font-size: 10px
@@ -0,0 +1,86 @@
1
+ module RailsTheme
2
+ module BootstrapHelper
3
+ def dropdown_toggle(text, url = '#')
4
+ link_to url, class: 'dropdown-toggle', :'data-toggle' => 'dropdown' do
5
+ text.html_safe << ' ' << content_tag(:b, nil, class: 'caret')
6
+ end
7
+ end
8
+
9
+ def dropdown_btn(text, url = '#')
10
+ link_to url, class: 'btn dropdown-toggle', :'data-toggle' => 'dropdown' do
11
+ text.html_safe << ' ' << content_tag(:span, nil, class: 'caret')
12
+ end
13
+ end
14
+
15
+ def iconed_link_to(text, url, options = {})
16
+ icon_class = options.delete(:icon_class)
17
+ link_to url, options do
18
+ content_tag(:i, nil, class: icon_class) << ' ' << text
19
+ end
20
+ end
21
+
22
+ def link_to_show(url, options = {})
23
+ icon_class = options.delete(:icon_class) || 'icon-eye-open'
24
+ default_options = { title: t('helpers.show'), class: 'btn', icon_class: icon_class }
25
+ iconed_link_to nil, url, default_options.deep_merge(options)
26
+ end
27
+
28
+ def link_to_new(url, options = {})
29
+ icon_class = options.delete(:icon_class) || 'icon-plus'
30
+ default_options = { title: t('helpers.new'), class: 'btn', icon_class: icon_class }
31
+ iconed_link_to nil, url, default_options.deep_merge(options)
32
+ end
33
+
34
+ def link_to_edit(url, options = {})
35
+ icon_class = options.delete(:icon_class) || 'icon-edit'
36
+ default_options = { title: t('helpers.edit'), class: 'btn', icon_class: icon_class }
37
+ iconed_link_to nil, url, default_options.deep_merge(options)
38
+ end
39
+
40
+ def link_to_destroy(url, options = {})
41
+ icon_class = options.delete(:icon_class) || 'icon-trash'
42
+ default_options = { method: :delete, data: { confirm: t('helpers.are_you_sure') }, title: t('helpers.destroy'), class: 'btn', icon_class: icon_class }
43
+ iconed_link_to nil, url, default_options.deep_merge(options)
44
+ end
45
+
46
+ def link_to_open_modal(text, url, modal_id, options = {})
47
+ default_options = { remote: true, data: { target: modal_id, toggle: 'modal', type: 'html' }, class: 'modal-open' }
48
+ iconed_link_to text, url, default_options.deep_merge(options)
49
+ end
50
+
51
+ def link_to_edit_modal(url, modal_id)
52
+ default_options = { remote: true, data: { target: modal_id, toggle: 'modal', type: 'html' }, class: 'btn modal-open' }
53
+ link_to_edit url, default_options
54
+ end
55
+
56
+ def link_to_close_button
57
+ link_to t('helpers.close'), '#', data: { dismiss: 'modal' }, class: 'btn'
58
+ end
59
+
60
+ def modal_close_button
61
+ button_tag 'x', type: 'button', name: nil, class: 'close', data: { dismiss: 'modal' }
62
+ end
63
+
64
+ def submit_button(f, label = nil, options = {})
65
+ default_options = { name: nil, class: 'btn-primary' }
66
+ f.button :submit, label, default_options.deep_merge(options)
67
+ end
68
+
69
+ def render_btn_group(tag = :div, options = {})
70
+ buttons = []
71
+ yield buttons if block_given?
72
+ default_options = { class: 'btn-group' }
73
+ content_tag tag, buttons.join('').html_safe, default_options.deep_merge(options)
74
+ end
75
+
76
+ def link_to_tab(text, tab_pane_id, options = {})
77
+ default_options = { data: { toggle: 'tab', target: tab_pane_id} }
78
+ link_to text, tab_pane_id, default_options.deep_merge(options)
79
+ end
80
+
81
+ def link_to_remote_tab(text, url, tab_pane_id, options = {})
82
+ default_options = { remote: true, data: { toggle: 'tab', target: tab_pane_id, type: 'html' } }
83
+ link_to text, url, default_options.deep_merge(options)
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,29 @@
1
+ module RailsTheme
2
+ module LayoutHelper
3
+ def render_list(list = [], options = {})
4
+ options, list = list, [] if list.is_a? Hash
5
+ yield list if block_given?
6
+ items = ''.html_safe
7
+ list.each_with_index do |item, index|
8
+ if item.is_a? Array
9
+ item_options = item.pop
10
+ item_content = item.join('').html_safe
11
+ else
12
+ item_options = {}
13
+ item_content = item
14
+ end
15
+
16
+ item_class = []
17
+ item_class << 'first' if index == 0
18
+ item_class << 'last' if index == (list.length - 1)
19
+ link = item_content.match(/href=(["'])(.*?)(\1)/)[2] rescue nil
20
+ item_class << 'current active' if link and current_page?(link)
21
+ item_class << item_options.delete(:class) if item_options[:class]
22
+
23
+ li_class = item_class.empty? ? nil : item_class.join(' ')
24
+ items << content_tag(:li, item_content, item_options.merge(class: li_class) )
25
+ end
26
+ content_tag(:ul, items, options)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ <!--[if lt IE 7]>
2
+ <p class=chromeframe>Your browser is <em>ancient!</em> <a href="http://browsehappy.com/">Upgrade to a different browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to experience this site.</p>
3
+ <![endif]-->
@@ -0,0 +1,11 @@
1
+ <header class="hidden">
2
+ <h5><%= t('.title') %></h5>
3
+ </header>
4
+
5
+ <div class="messages">
6
+ <% flash.each do |key, value| %>
7
+ <%= content_tag :div, class: "alert alert-#{key} #{key}" do
8
+ link_to('&times;'.html_safe, '#', class: 'close', data: { dismiss: 'alert'}) << value
9
+ end %>
10
+ <% end %>
11
+ </div>
File without changes
@@ -0,0 +1,10 @@
1
+ <hgroup id="site-name">
2
+ <h1><%= link_to t('site.title'), secure_root_url, class: 'brand' %></h1>
3
+ <h2><%= t('site.subtitle') %></h2>
4
+ </hgroup>
5
+
6
+ <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
7
+ <span class="icon-bar"></span>
8
+ <span class="icon-bar"></span>
9
+ <span class="icon-bar"></span>
10
+ </a>
@@ -0,0 +1 @@
1
+ <%= will_paginate(collection, renderer: BootstrapLinkRenderer, inner_window: 2, outer_window: 0, class: 'pagination', previous_label: '&larr;'.html_safe, next_label: '&rarr;'.html_safe) %>
@@ -0,0 +1,28 @@
1
+ en:
2
+ helpers:
3
+ index: 'Index'
4
+ show: 'Show'
5
+ new: 'New'
6
+ edit: 'Edit'
7
+ destroy: 'Destroy'
8
+ are_you_sure: 'Are you sure?'
9
+ actions: 'Actions'
10
+ preview: 'Preview'
11
+ cancel: 'Cancel'
12
+ save: 'Save'
13
+ close: 'Close'
14
+ search: 'Search'
15
+ download: 'Download'
16
+ upload: 'Upload'
17
+ export: 'Export'
18
+ previous_step: 'Previous step'
19
+ next_step: 'Next step'
20
+ skip: 'Skip'
21
+ finish: 'Finish'
22
+ 'yes': 'Yes'
23
+ 'no': 'No'
24
+ not_available: '(Not Available)'
25
+ posted_by: 'Posted by %{name}'
26
+ application:
27
+ flash_messages:
28
+ title: '動態訊息'
@@ -0,0 +1,28 @@
1
+ zh-TW:
2
+ helpers:
3
+ index: '列表'
4
+ show: '顯示'
5
+ new: '新增'
6
+ edit: '編輯'
7
+ destroy: '刪除'
8
+ are_you_sure: '你確定嗎?'
9
+ actions: '動作'
10
+ preview: '預覽'
11
+ cancel: '取消'
12
+ save: '儲存'
13
+ close: '關閉'
14
+ search: '搜尋'
15
+ download: '下載'
16
+ upload: '上傳'
17
+ export: '匯出'
18
+ previous_step: '上一步'
19
+ next_step: '下一步'
20
+ skip: '略過'
21
+ finish: '完成'
22
+ 'yes': '是'
23
+ 'no': '否'
24
+ not_available: '(尚無資料)'
25
+ posted_by: '由 %{name} 發佈'
26
+ application:
27
+ flash_messages:
28
+ title: '動態訊息'
@@ -0,0 +1,5 @@
1
+ require 'rails-theme-helper/version'
2
+ require 'rails-theme-helper/engine'
3
+
4
+ module RailsThemeHelper
5
+ end
@@ -0,0 +1,6 @@
1
+ app_path = File.expand_path('../../../app', __FILE__)
2
+ helpers_path = "#{app_path}/helpers"
3
+ $LOAD_PATH.unshift helpers_path unless $LOAD_PATH.include? helpers_path
4
+
5
+ require 'rails_theme/layout_helper.rb'
6
+ require 'rails_theme/bootstrap_helper.rb'
@@ -0,0 +1,4 @@
1
+ module RailsTheme
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module RailsThemeHelper
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rails-theme-helper/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = 'rails-theme-helper'
8
+ gem.version = RailsThemeHelper::VERSION
9
+ gem.authors = ['Tse-Ching Ho']
10
+ gem.email = ['tsechingho@gmail.com']
11
+ gem.description = %q{This gem helps you build themes for rails}
12
+ gem.summary = %q{helps you build themes for rails}
13
+ gem.homepage = 'https://github.com/tsechingho/rails-theme-helper'
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ['lib']
19
+
20
+ gem.add_dependency 'railties', '>= 3.1.1'
21
+ gem.add_dependency 'jquery-rails'
22
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-theme-helper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Tse-Ching Ho
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: railties
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 3.1.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.1.1
30
+ - !ruby/object:Gem::Dependency
31
+ name: jquery-rails
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: This gem helps you build themes for rails
47
+ email:
48
+ - tsechingho@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - LICENSE.txt
56
+ - README.md
57
+ - Rakefile
58
+ - app/assets/stylesheets/rails_theme/simple_layout.css.sass
59
+ - app/helpers/rails_theme/bootstrap_helper.rb
60
+ - app/helpers/rails_theme/layout_helper.rb
61
+ - app/views/application/_chromeframe.html.erb
62
+ - app/views/application/_flash_messages.html.erb
63
+ - app/views/application/_footer.html.erb
64
+ - app/views/application/_header.html.erb
65
+ - app/views/application/_pagination.html.erb
66
+ - config/locales/rails_theme.en.yml
67
+ - config/locales/rails_theme.zh-TW.yml
68
+ - lib/rails-theme-helper.rb
69
+ - lib/rails-theme-helper/app_helpers.rb
70
+ - lib/rails-theme-helper/engine.rb
71
+ - lib/rails-theme-helper/version.rb
72
+ - rails-theme-helper.gemspec
73
+ homepage: https://github.com/tsechingho/rails-theme-helper
74
+ licenses: []
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ segments:
86
+ - 0
87
+ hash: 3919916104356732355
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ segments:
95
+ - 0
96
+ hash: 3919916104356732355
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 1.8.24
100
+ signing_key:
101
+ specification_version: 3
102
+ summary: helps you build themes for rails
103
+ test_files: []