frontie 0.1.1 → 0.2.0

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.
File without changes
@@ -0,0 +1,20 @@
1
+ module BodyClassHelper
2
+
3
+ # Set additional body classes from the view
4
+ def set_body_class body_classes
5
+ @body_classes = body_classes
6
+ end
7
+
8
+ # Get the body classes based on the controller and actions
9
+ def body_class
10
+ qualified_controller_name = controller.controller_path.gsub('/','-')
11
+ basic_body_class = "#{qualified_controller_name} #{qualified_controller_name}-#{controller.action_name}"
12
+
13
+ if @body_classes
14
+ "#{basic_body_class} #{@body_classes}"
15
+ else
16
+ basic_body_class
17
+ end
18
+ end
19
+
20
+ end
File without changes
File without changes
File without changes
@@ -0,0 +1,33 @@
1
+ module MetaDataHelper
2
+
3
+ # Set the meta data
4
+ def set_meta meta={}
5
+ @meta = meta
6
+ end
7
+
8
+ # Display the meta data by merging @meta with defaults
9
+ def display_meta defaults={}
10
+ meta = defaults.merge(@meta || {}).reject{ |k,v| v.blank? }
11
+
12
+ output = meta.map do |key, value|
13
+ # If the value is a hash, let's iterate over those items
14
+ # and add to our output
15
+ if value.is_a?(Hash)
16
+ value.map do |property, content|
17
+ %Q[<meta name="#{key}:#{property}" content="#{normalize(content)}"/>]
18
+ end.join("\n")
19
+ else
20
+ %Q[<meta name="#{key}" content="#{normalize(value)}"/>]
21
+ end
22
+ end.join("\n")
23
+
24
+ output.html_safe
25
+ end
26
+
27
+
28
+ private
29
+ def normalize s
30
+ s.gsub(/<\/?[^>]*>/, '').gsub('"',"'") rescue s
31
+ end
32
+
33
+ end
@@ -0,0 +1,28 @@
1
+ module PageTitleHelper
2
+
3
+ # Set or append to the page title
4
+ def set_page_title page_title, replace_default_page_title=true
5
+ @page_title = page_title
6
+ @replace_default_page_title = replace_default_page_title
7
+ end
8
+
9
+ # Page title
10
+ def page_title options = {}
11
+ app_name = options[:app_name] || Rails.application.class.to_s.split('::').first
12
+ separator = options[:separator] || ' : '
13
+
14
+ if @page_title
15
+ # Option to allow users to ignore the rest of the page title
16
+ # and only display the title set in the view
17
+ if @replace_default_page_title
18
+ @page_title
19
+ else
20
+ "#{@page_title} #{separator} #{app_name}"
21
+ end
22
+ else
23
+ app_name
24
+ end
25
+ end
26
+
27
+
28
+ end
File without changes
data/lib/frontie.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require "frontie/version"
2
2
 
3
3
  module Frontie
4
- require 'frontie/railtie' if defined?(Rails)
4
+ if defined?(Rails)
5
+ require "frontie/engine"
6
+ end
5
7
  end
@@ -0,0 +1,4 @@
1
+ module Frontie
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -1,3 +1,3 @@
1
1
  module Frontie
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frontie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-29 00:00:00.000000000 Z
12
+ date: 2013-10-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -55,14 +55,17 @@ files:
55
55
  - LICENSE.txt
56
56
  - README.md
57
57
  - Rakefile
58
+ - app/helpers/active_state_helper.rb
59
+ - app/helpers/body_class_helper.rb
60
+ - app/helpers/date_time_helper.rb
61
+ - app/helpers/links_helper.rb
62
+ - app/helpers/map_helper.rb
63
+ - app/helpers/meta_data_helper.rb
64
+ - app/helpers/page_title_helper.rb
65
+ - app/helpers/utility_helper.rb
58
66
  - frontie.gemspec
59
67
  - lib/frontie.rb
60
- - lib/frontie/active_state_helper.rb
61
- - lib/frontie/date_time_helper.rb
62
- - lib/frontie/links_helper.rb
63
- - lib/frontie/map_helper.rb
64
- - lib/frontie/railtie.rb
65
- - lib/frontie/utility_helper.rb
68
+ - lib/frontie/engine.rb
66
69
  - lib/frontie/version.rb
67
70
  homepage: ''
68
71
  licenses:
@@ -1,25 +0,0 @@
1
- require 'frontie/active_state_helper'
2
- require 'frontie/date_time_helper'
3
- require 'frontie/links_helper'
4
- require 'frontie/map_helper'
5
- require 'frontie/utility_helper'
6
-
7
- module Frontie
8
- class Railtie < Rails::Railtie
9
- initializer 'active_state.helper' do |app|
10
- ActionView::Base.send :include, ActiveStateHelper
11
- end
12
- initializer 'date_time.helper' do |app|
13
- ActionView::Base.send :include, DateTimeHelper
14
- end
15
- initializer 'links.helper' do |app|
16
- ActionView::Base.send :include, LinksHelper
17
- end
18
- initializer 'map.helper' do |app|
19
- ActionView::Base.send :include, MapHelper
20
- end
21
- initializer 'utility.helper' do |app|
22
- ActionView::Base.send :include, UtilityHelper
23
- end
24
- end
25
- end