happy-titles 1.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e55eb24dd98e18091d559700c94b1f7f783e1cd6
4
+ data.tar.gz: c3bcccda638ac02278d45a779ff738342d6c9528
5
+ SHA512:
6
+ metadata.gz: 530e81bf21dbbfc1fc32e0e5e267ea55d1037418b1220d5c83b5d5b5ac2023d0403ee84133bb77ba50a149676ea000e384d9fccd4c92406eac82cee11be71ff5
7
+ data.tar.gz: fdc55cd7ee3c33cc35979c876d47a7b1a1b237509eba57699478ea1a0137596e5e7abd3c7a3fb0706cfc72bac27ad7c3a932ba83207d423e2de9715cc966bd6d
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .DS_Store
2
+ pkg
3
+
4
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,56 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.3
3
+
4
+ # Output settings
5
+ DisplayCopNames: true
6
+ DisplayStyleGuide: true
7
+
8
+ # Don't enforce comments classes
9
+ Documentation:
10
+ Enabled: false
11
+
12
+ # More flexible array alignment
13
+ Style/IndentArray:
14
+ EnforcedStyle: consistent
15
+
16
+ # More flexible hash alignment
17
+ Style/IndentHash:
18
+ EnforcedStyle: consistent
19
+
20
+ Metrics/AbcSize:
21
+ Exclude:
22
+ - 'spec/**/*'
23
+
24
+ # Disable class length check for tests
25
+ Metrics/ClassLength:
26
+ Exclude:
27
+ - 'spec/**/*'
28
+
29
+ # Disable method length check for tests
30
+ Metrics/MethodLength:
31
+ Exclude:
32
+ - 'spec/**/*'
33
+
34
+ # 120 character width
35
+ Metrics/LineLength:
36
+ Max: 120
37
+ Exclude:
38
+ - 'spec/**/*'
39
+
40
+ # Allow method names starting with 'get_'
41
+ Style/AccessorMethodName:
42
+ Enabled: false
43
+
44
+ # Allow non-ascii characters in comments - e.g. the 'em' dash
45
+ Style/AsciiComments:
46
+ Enabled: false
47
+
48
+ # Prefer double quotes
49
+ Style/StringLiterals:
50
+ EnforcedStyle: double_quotes
51
+
52
+ # Ignore incorrectly named file
53
+ # It's too much work to rename the gem now :(
54
+ Style/FileName:
55
+ Exclude:
56
+ - 'lib/happy-titles.rb'
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.0
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ source "https://rubygems.org"
3
+
4
+ # Specify your gem's dependencies in happy-titles.gemspec
5
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,110 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ happy-titles (2.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actionpack (4.2.5.2)
10
+ actionview (= 4.2.5.2)
11
+ activesupport (= 4.2.5.2)
12
+ rack (~> 1.6)
13
+ rack-test (~> 0.6.2)
14
+ rails-dom-testing (~> 1.0, >= 1.0.5)
15
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
16
+ actionview (4.2.5.2)
17
+ activesupport (= 4.2.5.2)
18
+ builder (~> 3.1)
19
+ erubis (~> 2.7.0)
20
+ rails-dom-testing (~> 1.0, >= 1.0.5)
21
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
22
+ activesupport (4.2.5.2)
23
+ i18n (~> 0.7)
24
+ json (~> 1.7, >= 1.7.7)
25
+ minitest (~> 5.1)
26
+ thread_safe (~> 0.3, >= 0.3.4)
27
+ tzinfo (~> 1.1)
28
+ ast (2.2.0)
29
+ builder (3.2.2)
30
+ diff-lcs (1.2.5)
31
+ erubis (2.7.0)
32
+ i18n (0.7.0)
33
+ json (1.8.3)
34
+ loofah (2.0.3)
35
+ nokogiri (>= 1.5.9)
36
+ mini_portile2 (2.0.0)
37
+ minitest (5.8.4)
38
+ nokogiri (1.6.7.2)
39
+ mini_portile2 (~> 2.0.0.rc2)
40
+ parser (2.3.0.7)
41
+ ast (~> 2.2)
42
+ powerpack (0.1.1)
43
+ rack (1.6.4)
44
+ rack-test (0.6.3)
45
+ rack (>= 1.0)
46
+ rails-deprecated_sanitizer (1.0.3)
47
+ activesupport (>= 4.2.0.alpha)
48
+ rails-dom-testing (1.0.7)
49
+ activesupport (>= 4.2.0.beta, < 5.0)
50
+ nokogiri (~> 1.6.0)
51
+ rails-deprecated_sanitizer (>= 1.0.1)
52
+ rails-html-sanitizer (1.0.3)
53
+ loofah (~> 2.0)
54
+ railties (4.2.5.2)
55
+ actionpack (= 4.2.5.2)
56
+ activesupport (= 4.2.5.2)
57
+ rake (>= 0.8.7)
58
+ thor (>= 0.18.1, < 2.0)
59
+ rainbow (2.1.0)
60
+ rake (10.5.0)
61
+ rspec (3.4.0)
62
+ rspec-core (~> 3.4.0)
63
+ rspec-expectations (~> 3.4.0)
64
+ rspec-mocks (~> 3.4.0)
65
+ rspec-core (3.4.3)
66
+ rspec-support (~> 3.4.0)
67
+ rspec-expectations (3.4.0)
68
+ diff-lcs (>= 1.2.0, < 2.0)
69
+ rspec-support (~> 3.4.0)
70
+ rspec-html-matchers (0.7.1)
71
+ nokogiri (~> 1)
72
+ rspec (>= 3.0.0.a, < 4)
73
+ rspec-mocks (3.4.1)
74
+ diff-lcs (>= 1.2.0, < 2.0)
75
+ rspec-support (~> 3.4.0)
76
+ rspec-rails (3.4.2)
77
+ actionpack (>= 3.0, < 4.3)
78
+ activesupport (>= 3.0, < 4.3)
79
+ railties (>= 3.0, < 4.3)
80
+ rspec-core (~> 3.4.0)
81
+ rspec-expectations (~> 3.4.0)
82
+ rspec-mocks (~> 3.4.0)
83
+ rspec-support (~> 3.4.0)
84
+ rspec-support (3.4.1)
85
+ rubocop (0.38.0)
86
+ parser (>= 2.3.0.6, < 3.0)
87
+ powerpack (~> 0.1)
88
+ rainbow (>= 1.99.1, < 3.0)
89
+ ruby-progressbar (~> 1.7)
90
+ unicode-display_width (~> 1.0, >= 1.0.1)
91
+ ruby-progressbar (1.7.5)
92
+ thor (0.19.1)
93
+ thread_safe (0.3.5)
94
+ tzinfo (1.2.2)
95
+ thread_safe (~> 0.1)
96
+ unicode-display_width (1.0.2)
97
+
98
+ PLATFORMS
99
+ ruby
100
+
101
+ DEPENDENCIES
102
+ bundler (~> 1.11)
103
+ happy-titles!
104
+ rake (~> 10.5)
105
+ rspec-html-matchers (~> 0.7)
106
+ rspec-rails (~> 3.4)
107
+ rubocop (~> 0.38.0)
108
+
109
+ BUNDLED WITH
110
+ 1.11.2
data/README.md ADDED
@@ -0,0 +1,190 @@
1
+ # happy-titles
2
+
3
+ A simple (and cheerful) way to handle page titles in your layouts.
4
+
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'happy-titles'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install happy-titles
21
+
22
+
23
+ ## Usage
24
+
25
+ ### Setting up default values
26
+
27
+ Create a new file in `config/initializers` called `happy_titles.rb` or something else which makes sense!
28
+
29
+ In this new file, add the following lines to set the default site and tagline.
30
+
31
+ ```ruby
32
+ HappyTitles.configure do |config|
33
+ config.site = "Your Site"
34
+ config.tagline = "Your witty but informative tagline"
35
+ end
36
+ ```
37
+
38
+
39
+ ### Update your layout
40
+
41
+ In the layout where you want to display your title add the following call to the Happy Titles helper method.
42
+
43
+ ```
44
+ <%= page_title %>
45
+ ```
46
+
47
+ The header element of your layout might end up looking something like:
48
+
49
+ ```html
50
+ <head>
51
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
52
+ <%= page_title %>
53
+ </head>
54
+ ```
55
+
56
+ Notice you don't need to wrap the helper in a `<title>` element, this is done for you.
57
+
58
+
59
+ ### Set the title in your views
60
+
61
+ In each of your views call the `title` method to set the title for that page.
62
+
63
+ ```
64
+ <% title 'Your very first Happy Title!' %>
65
+ ```
66
+
67
+ ### See your titles!
68
+
69
+ Given the above settings, let's have a look at the output you will receive when you call the `page_title` method in your layouts.
70
+
71
+ On pages where the title has not been set you will see...
72
+
73
+ ```html
74
+ <title>Your Site | Your witty but informative tagline</title>
75
+ ```
76
+
77
+ ...and on pages where the title _has_ been set you will see...
78
+
79
+ ```html
80
+ <title>Your very first Happy Title! | Your Site</title>
81
+ ```
82
+
83
+ That really is all there is to setting up and using Happy Titles!
84
+
85
+
86
+ ## Customising the Title Templates
87
+
88
+ ### Intro
89
+
90
+ You have already seen how to set up and use Happy Titles, now let's take a look at how to customise the individual title templates.
91
+
92
+ In all of the following examples I am going to assume the same defaults that are set up in the Set the Defaults section of this README.
93
+
94
+ Before we have a look at that, let's have a look at the **placeholders** you can use. These placeholders will be replaced with the real content when the title is rendered.
95
+
96
+ | Placeholder | Example |
97
+ |:------------|:------------------------------------------------------------------------------------------|
98
+ | :site | "Your Site" |
99
+ | :tagline | "Your witty but informative tagline" |
100
+ | :title | Will become "Your very first Happy Title!" or `:tagline` if a page title has not been set |
101
+
102
+ Now let's have a look at the default templates.
103
+
104
+ | Template | Description |
105
+ |:--------------------|:------------------------------------------------------------------------------------------|
106
+ | :site &#124; :title | Is used when there is no title set: "Your Site &#124; Your witty but informative tagline" |
107
+ | :title &#124; :site | Is used when there *is* a title set: "Your very first Happy Title! &#124; Your Site" |
108
+
109
+ You can change the default templates by using the following setting in `config/initializers/happy_titles.rb`
110
+
111
+ ```ruby
112
+ HappyTitles.configure do |config|
113
+ config.templates do
114
+ # The second param is the template to use when there is no title set
115
+ # The third param is the template to use when there is a title set
116
+ default "[:site]", "[:site] :title"
117
+ end
118
+ end
119
+ ```
120
+
121
+ Then when you render your titles you will see the following
122
+
123
+ ```html
124
+ <title>[Your Site]</title> <!-- when there is no title -->
125
+ <title>[Your Site] Your very first Happy Title!</title> <!-- when the title is set -->
126
+ ```
127
+
128
+
129
+ ### Adding Additional Templates
130
+
131
+ As well as changing the default template, you can also add new templates and then use those when you need a different title format in a different layout.
132
+
133
+ In `config/initializers/happy_titles.rb`:
134
+
135
+ ```ruby
136
+ HappyTitles.configure do |config|
137
+ config.templates do
138
+ extra "++ :site ++", "++ :site ++ :title ++"
139
+ end
140
+ end
141
+ ```
142
+
143
+ Then in your layout, you can use the following to call the extra template.
144
+
145
+ ```
146
+ <%= page_title :extra %>
147
+ ```
148
+
149
+ And you will get the following output, as you probably would've guessed by now!
150
+
151
+ ```html
152
+ <title>++ Your Site ++</title> <!-- when there is no title -->
153
+ <title>++ Your Site ++ Your very first Happy Title! ++</title> <!-- when the title is set -->
154
+ ```
155
+
156
+ You can add as many additional title templates as you need!
157
+
158
+ One final thing to mention, you can create templates that just have one format. So...
159
+
160
+ In `config/initializers/happy_titles.rb`:
161
+
162
+ ```ruby
163
+ HappyTitles.configure do |config|
164
+ config.templates do
165
+ single ":site (:title)"
166
+ end
167
+ end
168
+ ```
169
+
170
+ In your layout:
171
+
172
+ ```
173
+ <%= page_title :single %>
174
+ ```
175
+
176
+ The output:
177
+
178
+ ```html
179
+ <title>Your Site (Your witty but informative tagline)</title> <!-- when there is no title -->
180
+ <title>Your Site (Your very first Happy Title!)</title> <!-- when the title is set -->
181
+ ```
182
+
183
+
184
+ ## Contributing
185
+
186
+ 1. Fork it ( https://github.com/andypearson/happy-titles/fork )
187
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
188
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
189
+ 4. Push to the branch (`git push origin my-new-feature`)
190
+ 5. Create a new Pull Request
data/RELEASE.md ADDED
@@ -0,0 +1,11 @@
1
+ # Releasing
2
+
3
+ These are steps for the maintainer to take to release a new version of this gem. Copied without mercy from [JacobEvelyn/friends](https://github.com/JacobEvelyn/friends).
4
+
5
+ 1. On the `master` branch, update the `VERSION` constant in
6
+ `lib/happy-titles/version.rb`.
7
+ 2. Commit the change (`git add -A && git commit -m 'Bump to vX.X.X'`).
8
+ 3. Add a tag (`git tag -am "vX.X.X" vX.X.X`).
9
+ 4. `git push && git push --tags`
10
+ 5. `gem build happy-titles.gemspec && gem push *.gem && rm *.gem`
11
+ 6. Celebrate!
data/Rakefile CHANGED
@@ -1,23 +1,2 @@
1
- require 'rubygems'
2
- require 'rake'
3
- require 'rspec/core/rake_task'
4
-
5
- desc 'Test the happy-titles plugin.'
6
- RSpec::Core::RakeTask.new('spec') do |t|
7
- t.pattern = FileList['spec/*_spec.rb']
8
- t.rspec_opts = ['-c']
9
- end
10
-
11
- begin
12
- require 'jeweler'
13
- Jeweler::Tasks.new do |gemspec|
14
- gemspec.name = "happy-titles"
15
- gemspec.summary = "A simple way to handle page titles in your layouts."
16
- gemspec.email = "andy@andy-pearson.com"
17
- gemspec.homepage = "http://github.com/andypearson/happy-titles"
18
- gemspec.authors = ["Andy Pearson"]
19
- end
20
- Jeweler::GemcutterTasks.new
21
- rescue LoadError
22
- puts "Jeweler not available. Install it with: gem install jeweler"
23
- end
1
+ # frozen_string_literal: true
2
+ require "bundler/gem_tasks"
data/TODO.md ADDED
@@ -0,0 +1,3 @@
1
+ # TODO
2
+
3
+ - [x] Setup Rubocop
data/happy-titles.gemspec CHANGED
@@ -1,50 +1,27 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
1
+ # coding: utf-8
2
+ # frozen_string_literal: true
3
+ lib = File.expand_path("../lib", __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require "happy-titles/version"
5
6
 
6
- Gem::Specification.new do |s|
7
- s.name = %q{happy-titles}
8
- s.version = "1.1.0"
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "happy-titles"
9
+ spec.version = HappyTitles::VERSION
10
+ spec.authors = ["Andy Pearson"]
11
+ spec.email = ["andy@andy-pearson.com"]
12
+ spec.summary = "A simple way to handle page titles in your layouts."
13
+ spec.description = "A simple way to handle page titles in your layouts."
14
+ spec.homepage = "https://github.com/andypearson/happy-titles"
15
+ spec.license = "MIT"
9
16
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Andy Pearson"]
12
- s.date = %q{2011-05-07}
13
- s.email = %q{andy@andy-pearson.com}
14
- s.extra_rdoc_files = [
15
- "README.markdown"
16
- ]
17
- s.files = [
18
- ".git_ignore",
19
- "MIT-LICENCE",
20
- "README.markdown",
21
- "Rakefile",
22
- "VERSION",
23
- "happy-titles.gemspec",
24
- "init.rb",
25
- "lib/happy-titles.rb",
26
- "lib/happy-titles/railtie.rb",
27
- "rails/init.rb",
28
- "spec/happy_titles_spec.rb",
29
- "spec/spec_helper.rb"
30
- ]
31
- s.homepage = %q{http://github.com/andypearson/happy-titles}
32
- s.require_paths = ["lib"]
33
- s.rubygems_version = %q{1.3.7}
34
- s.summary = %q{A simple way to handle page titles in your layouts.}
35
- s.test_files = [
36
- "spec/happy_titles_spec.rb",
37
- "spec/spec_helper.rb"
38
- ]
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
39
21
 
40
- if s.respond_to? :specification_version then
41
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
42
- s.specification_version = 3
43
-
44
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
- else
46
- end
47
- else
48
- end
22
+ spec.add_development_dependency "bundler", "~> 1.11"
23
+ spec.add_development_dependency "rake", "~> 10.5"
24
+ spec.add_development_dependency "rspec-html-matchers", "~> 0.7"
25
+ spec.add_development_dependency "rspec-rails", "~> 3.4"
26
+ spec.add_development_dependency "rubocop", "~> 0.38.0"
49
27
  end
50
-