metazilla 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -0
- data/lib/metazilla/translator.rb +5 -1
- data/lib/metazilla/version.rb +1 -1
- data/lib/metazilla/view_helper.rb +1 -1
- data/lib/metazilla.rb +20 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b73475d91bed1c7be91b5b4f04098e4fe29fba77
|
4
|
+
data.tar.gz: f98750b74d3174646714fee94e41699e4ec916c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce6e2680705523bad3777ef5e76c72f67c11e4c235ed54169a917722035278d2c651d05e42338554468f1f095cfb21089443ec82a35da0155235e7b548a7a2ab
|
7
|
+
data.tar.gz: 15179e16b9d06ea2dafa6b2a1794e21dbabdc2f99fefee92d0952dba4181bd2cf1c8f50d93ac67d2baff1d44b15f521f4d6ab7874b2433df1ba77669ab036620
|
data/README.md
CHANGED
@@ -28,6 +28,16 @@ And then execute:
|
|
28
28
|
|
29
29
|
`title_tag` generates `<title>` tag with full title. Place this in your layout.
|
30
30
|
|
31
|
+
#### Custom title separator
|
32
|
+
|
33
|
+
If you want your title tag content to look like this: `My Application > My cool page`, tell Metazilla to use custom separator.
|
34
|
+
|
35
|
+
config/initializers/metazilla.rb:
|
36
|
+
|
37
|
+
Metazilla.configure do |config|
|
38
|
+
config.separator = " > "
|
39
|
+
end
|
40
|
+
|
31
41
|
### Meta tags
|
32
42
|
|
33
43
|
`meta :description, "My app description"` to set meta tag.
|
@@ -82,6 +92,18 @@ View:
|
|
82
92
|
|
83
93
|
title # => User: John Doe
|
84
94
|
|
95
|
+
### Action aliasing (:create and :update problem)
|
96
|
+
|
97
|
+
Metaziila uses name of the current action for resolving titles, so when you submit a form and it fails to save, your rendered `new` template inside the `create` action. To avoid setting duplicated titles for both `new` and `create` (and `edit` and `update`), this actions is mapped in gem's configuration.
|
98
|
+
If your application have similar non-RESTful pair of actions, your can add them to mapping:
|
99
|
+
|
100
|
+
config/initializers/metazilla.rb:
|
101
|
+
|
102
|
+
Metazilla.configure do |config|
|
103
|
+
config.mapping[:perform_parse] = :parse
|
104
|
+
end
|
105
|
+
|
106
|
+
Now you can define title only for `parse` action, `perform_parse` will use it automagically.
|
85
107
|
|
86
108
|
### Namespacing
|
87
109
|
|
data/lib/metazilla/translator.rb
CHANGED
@@ -13,7 +13,7 @@ module Metazilla
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def lookup_for_current_path(key)
|
16
|
-
lookup_recursively(key, [namespace, controller,
|
16
|
+
lookup_recursively(key, [namespace, controller, mapped_action].flatten)
|
17
17
|
end
|
18
18
|
|
19
19
|
private
|
@@ -35,6 +35,10 @@ module Metazilla
|
|
35
35
|
nil
|
36
36
|
end
|
37
37
|
|
38
|
+
def mapped_action
|
39
|
+
(Metazilla.configuration.mapping[action.to_sym] || action).to_s.freeze
|
40
|
+
end
|
41
|
+
|
38
42
|
def lookup_in_namespace(key, namespace = [])
|
39
43
|
t_key = [namespace, key].flatten.compact.join('.')
|
40
44
|
i18n_set?(t_key) ? I18n.t(t_key, context) : nil
|
data/lib/metazilla/version.rb
CHANGED
data/lib/metazilla.rb
CHANGED
@@ -3,6 +3,26 @@ require "metazilla/version"
|
|
3
3
|
require "metazilla/view_helper"
|
4
4
|
|
5
5
|
module Metazilla
|
6
|
+
def self.configure
|
7
|
+
yield(configuration) if block_given?
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.configuration
|
11
|
+
@configuration ||= Configuration.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.reset_configuration
|
15
|
+
@configuration = Configuration.new
|
16
|
+
end
|
17
|
+
|
18
|
+
class Configuration
|
19
|
+
attr_accessor :separator, :mapping
|
20
|
+
|
21
|
+
def initialize
|
22
|
+
@separator = ' | '
|
23
|
+
@mapping = { create: :new, update: :edit }
|
24
|
+
end
|
25
|
+
end
|
6
26
|
end
|
7
27
|
|
8
28
|
ActionView::Base.send :include, Metazilla::ViewHelper
|