titlefy 0.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/lib/titlefy.rb +45 -0
- metadata +54 -0
data/lib/titlefy.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
class Titlefy
|
2
|
+
module ClassMethods
|
3
|
+
|
4
|
+
def render(*args)
|
5
|
+
set_title_tag if (!!!@title || @title == "")
|
6
|
+
super
|
7
|
+
end
|
8
|
+
|
9
|
+
def set_title_tag
|
10
|
+
yml = YAML::load(ERB.new((IO.read("#{::Rails.root.to_s}/config/title_tags/#{I18n.locale}.yml"))).result)
|
11
|
+
namespace = ""
|
12
|
+
namespace = self.class.to_s.split("::").first.downcase if self.class.to_s.split("::").size > 1
|
13
|
+
begin
|
14
|
+
if namespace == ""
|
15
|
+
title_tag = yml[controller_name][action_name]
|
16
|
+
else
|
17
|
+
title_tag = yml[namespace][controller_name][action_name]
|
18
|
+
end
|
19
|
+
rescue
|
20
|
+
end
|
21
|
+
title_tag = yml["default"] unless title_tag
|
22
|
+
raise "No Title Tag defined" unless title_tag
|
23
|
+
begin
|
24
|
+
@title = eval(title_tag)
|
25
|
+
rescue
|
26
|
+
begin
|
27
|
+
@title = title_tag
|
28
|
+
rescue
|
29
|
+
raise "MISSING TITLE TAG"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def add_title(title)
|
35
|
+
@title = title
|
36
|
+
end
|
37
|
+
end
|
38
|
+
class Engine < Rails::Engine
|
39
|
+
initializer "including" do |app|
|
40
|
+
ActionController::Base.send :include, Titlefy::ClassMethods
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
metadata
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: titlefy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: "0.1"
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Huan Son
|
9
|
+
autorequire: builder
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-11-12 00:00:00 Z
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Simple TitleTag Helper. Reads from Multilingual YML Files.
|
17
|
+
email: info@fu-media.de
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- lib/titlefy.rb
|
26
|
+
homepage:
|
27
|
+
licenses: []
|
28
|
+
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
31
|
+
|
32
|
+
require_paths:
|
33
|
+
- lib
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: "0"
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
46
|
+
requirements: []
|
47
|
+
|
48
|
+
rubyforge_project:
|
49
|
+
rubygems_version: 1.8.11
|
50
|
+
signing_key:
|
51
|
+
specification_version: 3
|
52
|
+
summary: Multilingual TitleTag Helper. Reads and Set TitleTags from a YML file.
|
53
|
+
test_files: []
|
54
|
+
|