humdrum-rails 0.0.3
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/.gitignore +18 -0
- data/Features.md +23 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/humdrum-rails.gemspec +30 -0
- data/lib/humdrum/version.rb +4 -0
- data/lib/humdrum.rb +4 -0
- data/lib/rails/generators/humdrum/layout/layout_generator.rb +133 -0
- data/lib/rails/generators/humdrum/layout/templates/controllers/admin_controller.rb +5 -0
- data/lib/rails/generators/humdrum/layout/templates/controllers/application_controller.rb +14 -0
- data/lib/rails/generators/humdrum/layout/templates/controllers/public_controller.rb +5 -0
- data/lib/rails/generators/humdrum/layout/templates/controllers/user_controller.rb +5 -0
- data/lib/rails/generators/humdrum/layout/templates/controllers/welcome_controller.rb +7 -0
- data/lib/rails/generators/humdrum/layout/templates/helpers/display_helper.rb +41 -0
- data/lib/rails/generators/humdrum/layout/templates/helpers/meta_tags_helper.rb +3 -0
- data/lib/rails/generators/humdrum/layout/templates/helpers/navigation_helper.rb +19 -0
- data/lib/rails/generators/humdrum/layout/templates/helpers/title_helper.rb +15 -0
- data/lib/rails/generators/humdrum/layout/templates/images/favicon.ico +0 -0
- data/lib/rails/generators/humdrum/layout/templates/images/glyphicons-halflings-white.png +0 -0
- data/lib/rails/generators/humdrum/layout/templates/images/glyphicons-halflings.png +0 -0
- data/lib/rails/generators/humdrum/layout/templates/javascripts/bootstrap.js +2276 -0
- data/lib/rails/generators/humdrum/layout/templates/javascripts/modernizr.2.6.2.js +815 -0
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/bootstrap-responsive.css +1109 -0
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/bootstrap.css +6158 -0
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/humdrum/boilerplate.css.scss +299 -0
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/humdrum/box.css.scss +57 -0
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/humdrum/caligraphy.css.scss +30 -0
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/humdrum/dividers.css.scss +18 -0
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/humdrum/form.css.scss +80 -0
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/humdrum/misc.css.scss +9 -0
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/humdrum/normalize.css.scss +533 -0
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/humdrum/palettes.css.scss +66 -0
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/humdrum/positioning.css.scss +702 -0
- data/lib/rails/generators/humdrum/layout/templates/stylesheets/overrides-bootstrap.css +24 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/admin/_footer.html.erb +0 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/admin/_header.html.erb +35 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/admin/_navbar.html.erb +0 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/admin.html.erb +65 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/common/_flash_message.html.erb +24 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/common/_meta_tags.html.erb +42 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/common/_overlays.html.erb +9 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/public/_footer.html.erb +0 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/public/_header.html.erb +35 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/public/_navbar.html.erb +0 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/public.html.erb +65 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/user/_footer.html.erb +0 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/user/_header.html.erb +35 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/user/_navbar.html.erb +0 -0
- data/lib/rails/generators/humdrum/layout/templates/views/layouts/user.html.erb +65 -0
- data/lib/rails/generators/humdrum/layout/templates/views/welcome/index.html.erb +5 -0
- data/lib/rails/generators/humdrum/resource/resource_generator.rb +237 -0
- data/lib/rails/generators/humdrum/resource/templates/config/locales/humdrum.en.yml +6 -0
- data/lib/rails/generators/humdrum/resource/templates/controllers/resource_controller.rb +192 -0
- data/lib/rails/generators/humdrum/resource/templates/migrations/create_resources.rb +14 -0
- data/lib/rails/generators/humdrum/resource/templates/models/resource.rb +5 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/_edit.html.erb +7 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/_filters.html.erb +9 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/_form.html.erb +44 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/_index.html.erb +22 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/_item.html.erb +21 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/_nav_filters.html.erb +9 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/_new.html.erb +9 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/_show.html.erb +38 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/_summary.html.erb +10 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/create.js.erb +15 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/destroy.js.erb +14 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/edit.js.erb +2 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/index.html.erb +33 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/index.js.erb +15 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/new.js.erb +2 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/show.js.erb +2 -0
- data/lib/rails/generators/humdrum/resource/templates/views/resource/update.js.erb +14 -0
- metadata +170 -0
data/.gitignore
ADDED
data/Features.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
## Desired Features
|
|
3
|
+
|
|
4
|
+
1. meta tag management: A meta tag helper along with a view partial and controller methods (before_filter) which uses it.
|
|
5
|
+
2. Including authorizers, rolify or any other permission management with role based access.
|
|
6
|
+
3. Change Log generators.
|
|
7
|
+
4. Put a nice footer.
|
|
8
|
+
5. Public pages:
|
|
9
|
+
1. landing page
|
|
10
|
+
2. about us page
|
|
11
|
+
3. contact us page
|
|
12
|
+
4. documentation page
|
|
13
|
+
5. faq page
|
|
14
|
+
6. pricing page
|
|
15
|
+
7. custom static page
|
|
16
|
+
6. Create a button set with colors.
|
|
17
|
+
7. Work with i18n
|
|
18
|
+
1. Load default text in locales/humdrum/en.yml
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## Bugs to be fixed
|
|
22
|
+
|
|
23
|
+
The close icon is not responding for alert boxes - especially while showing ajax flash messages.
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2013 Krishnaprasad Varma (krshnaprsad@gmail.com)
|
|
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
|
+
# Humdrum
|
|
2
|
+
|
|
3
|
+
humdrum is a collection of useful generators which are quite handy for starting up a project in ruby on rails. humdrum creates layouts using bootstrap, HTML5boilerplate, modernizer etc to kick start a project.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
gem 'humdrum'
|
|
10
|
+
|
|
11
|
+
And then execute:
|
|
12
|
+
|
|
13
|
+
$ bundle
|
|
14
|
+
|
|
15
|
+
Or install it yourself as:
|
|
16
|
+
|
|
17
|
+
$ gem install humdrum
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
TODO: Write usage instructions here
|
|
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,30 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'humdrum/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |gem|
|
|
7
|
+
|
|
8
|
+
gem.name = "humdrum-rails"
|
|
9
|
+
gem.email = "krishnaprasadvarma@gmail.com"
|
|
10
|
+
gem.version = Humdrum::VERSION
|
|
11
|
+
gem.platform = Gem::Platform::RUBY
|
|
12
|
+
gem.authors = ["Krishnan"]
|
|
13
|
+
gem.license = "MIT"
|
|
14
|
+
gem.homepage = "http://github.com/humdrum"
|
|
15
|
+
gem.description = %q{humdrum-rails is a collection of useful generators which are quite handy for starting up a project in ruby on railgem.}
|
|
16
|
+
gem.summary = %q{humdrum-rails creates layouts using bootstrap, HTML5boilerplate, modernizer etc to kick start a project.}
|
|
17
|
+
|
|
18
|
+
gem.rubyforge_project = "humdrum"
|
|
19
|
+
|
|
20
|
+
gem.files = `git ls-files`.split("\n")
|
|
21
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
22
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
23
|
+
gem.require_paths = ["lib"]
|
|
24
|
+
|
|
25
|
+
gem.add_runtime_dependency(%q<colorize>, ["~> 0.5.8"])
|
|
26
|
+
|
|
27
|
+
gem.add_development_dependency 'rails', '~> 3.0.0'
|
|
28
|
+
gem.add_development_dependency 'rainbow'
|
|
29
|
+
|
|
30
|
+
end
|
data/lib/humdrum.rb
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
module Humdrum
|
|
2
|
+
module Generators
|
|
3
|
+
class LayoutGenerator < Rails::Generators::Base
|
|
4
|
+
|
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
|
6
|
+
|
|
7
|
+
desc "Generates a layout file with the name 'public' and the required partials " <<
|
|
8
|
+
"which can be used for all public pages (user need not sign in) like about us, contact us." <<
|
|
9
|
+
"Pass --user_layout to generate another layout for users who are signed in." <<
|
|
10
|
+
"Pass --admin_layout to generate another layout for admin users."
|
|
11
|
+
|
|
12
|
+
argument :layout_name, :type=>:string, :default => "application"
|
|
13
|
+
argument :application_name, :type=>:string, :default => "Application Name"
|
|
14
|
+
|
|
15
|
+
class_option :fluid, :type => :boolean, :default => true, :desc => "Pass false to create fixed layouts. Default is true"
|
|
16
|
+
|
|
17
|
+
class_option :stylesheet, :type => :boolean, :default => true, :desc => "This will not generate the stylesheets"
|
|
18
|
+
class_option :javascript, :type => :boolean, :default => true, :desc => "This will not generate the javascripts"
|
|
19
|
+
class_option :graphics, :type => :boolean, :default => true, :desc => "This will not generate the graphics"
|
|
20
|
+
|
|
21
|
+
class_option :public_layout, :type => :boolean, :default => true, :desc => "This will create a public.html.erb which can be used for public pages, not logged in users."
|
|
22
|
+
class_option :admin_layout, :type => :boolean, :default => false, :desc => "This will create a public.html.erb which can be used for admin pages."
|
|
23
|
+
class_option :user_layout, :type => :boolean, :default => false, :desc => "This will create a public.html.erb which can be used for pages shown to a signed in user."
|
|
24
|
+
|
|
25
|
+
def remove_index_file
|
|
26
|
+
remove_file "public/index.html"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def generate_stylesheets
|
|
30
|
+
if options.stylesheet?
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
copy_file "stylesheets/bootstrap.css", "app/assets/stylesheets/bootstrap.css"
|
|
34
|
+
copy_file "stylesheets/bootstrap-responsive.css", "app/assets/stylesheets/bootstrap-responsive.css"
|
|
35
|
+
# Its named overrides-bootstrap so that it loads after bootstrap.css
|
|
36
|
+
copy_file "stylesheets/overrides-bootstrap.css", "app/assets/stylesheets/overrides-bootstrap.css"
|
|
37
|
+
|
|
38
|
+
copy_file "stylesheets/humdrum/boilerplate.css.scss", "app/assets/stylesheets/humdrum/boilerplate.css.scss"
|
|
39
|
+
|
|
40
|
+
copy_file "stylesheets/humdrum/normalize.css.scss", "app/assets/stylesheets/humdrum/normalize.css.scss"
|
|
41
|
+
copy_file "stylesheets/humdrum/positioning.css.scss", "app/assets/stylesheets/humdrum/positioning.css.scss"
|
|
42
|
+
copy_file "stylesheets/humdrum/palettes.css.scss", "app/assets/stylesheets/humdrum/palettes.css.scss"
|
|
43
|
+
copy_file "stylesheets/humdrum/box.css.scss", "app/assets/stylesheets/humdrum/box.css.scss"
|
|
44
|
+
copy_file "stylesheets/humdrum/caligraphy.css.scss", "app/assets/stylesheets/humdrum/caligraphy.css.scss"
|
|
45
|
+
copy_file "stylesheets/humdrum/dividers.css.scss", "app/assets/stylesheets/humdrum/dividers.css.scss"
|
|
46
|
+
copy_file "stylesheets/humdrum/form.css.scss", "app/assets/stylesheets/humdrum/form.css.scss"
|
|
47
|
+
copy_file "stylesheets/humdrum/misc.css.scss", "app/assets/stylesheets/humdrum/misc.css.scss"
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def generate_javascripts
|
|
52
|
+
if options.javascript?
|
|
53
|
+
copy_file "javascripts/bootstrap.js", "app/assets/javascripts/humdrum/bootstrap.js"
|
|
54
|
+
copy_file "javascripts/modernizr.2.6.2.js", "app/assets/javascripts/humdrum/modernizr.2.6.2.js"
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def generate_graphics
|
|
59
|
+
if options.graphics?
|
|
60
|
+
copy_file "images/favicon.ico", "app/assets/images/favicon.ico"
|
|
61
|
+
copy_file "images/glyphicons-halflings.png", "app/assets/images/glyphicons-halflings.png"
|
|
62
|
+
copy_file "images/glyphicons-halflings-white.png", "app/assets/images/glyphicons-halflings-white.png"
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def generate_helpers
|
|
67
|
+
template "helpers/title_helper.rb", "app/helpers/title_helper.rb"
|
|
68
|
+
template "helpers/navigation_helper.rb", "app/helpers/navigation_helper.rb"
|
|
69
|
+
template "helpers/meta_tags_helper.rb", "app/helpers/meta_tags_helper.rb"
|
|
70
|
+
template "helpers/display_helper.rb", "app/helpers/display_helper.rb"
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def generate_layout
|
|
74
|
+
template "views/layouts/common/_flash_message.html.erb", "app/views/layouts/common/_flash_message.html.erb"
|
|
75
|
+
template "views/layouts/common/_meta_tags.html.erb", "app/views/layouts/common/_meta_tags.html.erb"
|
|
76
|
+
template "views/layouts/common/_overlays.html.erb", "app/views/layouts/common/_overlays.html.erb"
|
|
77
|
+
|
|
78
|
+
if options.admin_layout?
|
|
79
|
+
template "views/layouts/admin.html.erb", "app/views/layouts/admin.html.erb"
|
|
80
|
+
template "views/layouts/admin/_header.html.erb", "app/views/layouts/admin/_header.html.erb"
|
|
81
|
+
template "views/layouts/admin/_footer.html.erb", "app/views/layouts/admin/_footer.html.erb"
|
|
82
|
+
template "views/layouts/admin/_navbar.html.erb", "app/views/layouts/admin/_navbar.html.erb"
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
if options.public_layout?
|
|
86
|
+
template "views/layouts/public.html.erb", "app/views/layouts/public.html.erb"
|
|
87
|
+
template "views/layouts/public/_header.html.erb", "app/views/layouts/public/_header.html.erb"
|
|
88
|
+
template "views/layouts/public/_footer.html.erb", "app/views/layouts/public/_footer.html.erb"
|
|
89
|
+
template "views/layouts/public/_navbar.html.erb", "app/views/layouts/public/_navbar.html.erb"
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
if options.user_layout?
|
|
93
|
+
template "views/layouts/user.html.erb", "app/views/layouts/user.html.erb"
|
|
94
|
+
template "views/layouts/user/_header.html.erb", "app/views/layouts/user/_header.html.erb"
|
|
95
|
+
template "views/layouts/user/_footer.html.erb", "app/views/layouts/user/_footer.html.erb"
|
|
96
|
+
template "views/layouts/user/_navbar.html.erb", "app/views/layouts/user/_navbar.html.erb"
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def generate_controllers
|
|
102
|
+
template "controllers/application_controller.rb", "app/controllers/application_controller.rb"
|
|
103
|
+
template "controllers/welcome_controller.rb", "app/controllers/welcome_controller.rb" if options.public_layout?
|
|
104
|
+
template "controllers/public_controller.rb", "app/controllers/public_controller.rb" if options.public_layout?
|
|
105
|
+
template "controllers/user_controller.rb", "app/controllers/user_controller.rb" if options.user_layout?
|
|
106
|
+
template "controllers/admin_controller.rb", "app/controllers/admin_controller.rb" if options.admin_layout?
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def generate_views
|
|
110
|
+
template "views/welcome/index.html.erb", "app/views/welcome/index.html.erb" if options.public_layout?
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def generate_routes
|
|
114
|
+
route("root :to => 'welcome#index'")
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
private
|
|
118
|
+
|
|
119
|
+
def file_name
|
|
120
|
+
layout_name.underscore
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def container_class
|
|
124
|
+
options.fluid? ? "container-fluid" : "container"
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def row_class
|
|
128
|
+
options.fluid? ? "row-fluid" : "row"
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class ApplicationController < ActionController::Base
|
|
2
|
+
protect_from_forgery
|
|
3
|
+
|
|
4
|
+
## This function will set a flash message depending up on the request type (ajax - xml http or direct http)
|
|
5
|
+
## example : store_flash_message("The message has been sent successfully", :success)
|
|
6
|
+
def store_flash_message(message, type)
|
|
7
|
+
if request.xhr?
|
|
8
|
+
flash.now[type] = message
|
|
9
|
+
else
|
|
10
|
+
flash[type] = message
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module DisplayHelper
|
|
2
|
+
|
|
3
|
+
def scrap_word(text, char_count_limit, more_text = nil, more_link = nil,style='')
|
|
4
|
+
# remove HTML tags
|
|
5
|
+
text = text.to_s.gsub(/<\/?[^>]*>/, " ")
|
|
6
|
+
# remove additional spaces
|
|
7
|
+
text = text.to_s.gsub(/[ ]+/, " ")
|
|
8
|
+
if text.length < char_count_limit
|
|
9
|
+
return text
|
|
10
|
+
end
|
|
11
|
+
teaser = ""
|
|
12
|
+
words = text.split(/ /)
|
|
13
|
+
words.each do |word|
|
|
14
|
+
if word.length > 0
|
|
15
|
+
if (teaser + word).length > char_count_limit
|
|
16
|
+
if more_text && more_link
|
|
17
|
+
teaser = teaser + " " + link_to(more_text, more_link,:style=>style, :target=>"_blank")
|
|
18
|
+
else
|
|
19
|
+
teaser = teaser.strip + "..."
|
|
20
|
+
end
|
|
21
|
+
break;
|
|
22
|
+
else
|
|
23
|
+
teaser = teaser + word + " "
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
return teaser
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def display_time(disp_time, class_name = nil)
|
|
31
|
+
return_str = ""
|
|
32
|
+
if ((Time.now - disp_time) < (6*24*60*60))
|
|
33
|
+
return_str = distance_of_time_in_words_to_now(disp_time) + " ago"
|
|
34
|
+
else
|
|
35
|
+
return_str = "#{disp_time.to_s(:hours)}:#{disp_time.to_s(:mins)}#{disp_time.to_s(:ampm).downcase} on #{disp_time.strftime('%m/%d/%y')}"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
return content_tag("span", return_str, :class => (class_name.nil? ? "text-color-grey" : class_name))
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|
|
Binary file
|
|
Binary file
|