tytus 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/.gitignore +6 -0
  2. data/.rspec +1 -0
  3. data/.rvmrc +13 -0
  4. data/.travis.yml +4 -0
  5. data/Gemfile +3 -0
  6. data/LICENSE +20 -0
  7. data/README.md +96 -0
  8. data/Rakefile +6 -0
  9. data/lib/tytus/compatibility.rb +21 -0
  10. data/lib/tytus/controller_extensions.rb +45 -0
  11. data/lib/tytus/railtie.rb +34 -0
  12. data/lib/tytus/version.rb +5 -0
  13. data/lib/tytus/view_extensions.rb +64 -0
  14. data/lib/tytus.rb +18 -0
  15. data/spec/rails_app/Rakefile +7 -0
  16. data/spec/rails_app/app/assets/images/rails.png +0 -0
  17. data/spec/rails_app/app/assets/javascripts/application.js +9 -0
  18. data/spec/rails_app/app/assets/stylesheets/application.css +7 -0
  19. data/spec/rails_app/app/controllers/application_controller.rb +3 -0
  20. data/spec/rails_app/app/controllers/articles_controller.rb +10 -0
  21. data/spec/rails_app/app/helpers/application_helper.rb +2 -0
  22. data/spec/rails_app/app/mailers/.gitkeep +0 -0
  23. data/spec/rails_app/app/models/.gitkeep +0 -0
  24. data/spec/rails_app/app/views/articles/index.html.erb +2 -0
  25. data/spec/rails_app/app/views/articles/show.html.erb +1 -0
  26. data/spec/rails_app/app/views/layouts/application.html.erb +14 -0
  27. data/spec/rails_app/config/application.rb +54 -0
  28. data/spec/rails_app/config/boot.rb +8 -0
  29. data/spec/rails_app/config/database.yml +25 -0
  30. data/spec/rails_app/config/environment.rb +5 -0
  31. data/spec/rails_app/config/environments/development.rb +30 -0
  32. data/spec/rails_app/config/environments/production.rb +60 -0
  33. data/spec/rails_app/config/environments/test.rb +39 -0
  34. data/spec/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  35. data/spec/rails_app/config/initializers/inflections.rb +10 -0
  36. data/spec/rails_app/config/initializers/mime_types.rb +5 -0
  37. data/spec/rails_app/config/initializers/secret_token.rb +7 -0
  38. data/spec/rails_app/config/initializers/session_store.rb +8 -0
  39. data/spec/rails_app/config/initializers/wrap_parameters.rb +14 -0
  40. data/spec/rails_app/config/locales/en.yml +4 -0
  41. data/spec/rails_app/config/routes.rb +4 -0
  42. data/spec/rails_app/config.ru +4 -0
  43. data/spec/rails_app/db/test.sqlite3 +0 -0
  44. data/spec/rails_app/lib/assets/.gitkeep +0 -0
  45. data/spec/rails_app/public/404.html +26 -0
  46. data/spec/rails_app/public/422.html +26 -0
  47. data/spec/rails_app/public/500.html +26 -0
  48. data/spec/rails_app/public/favicon.ico +0 -0
  49. data/spec/rails_app/script/rails +6 -0
  50. data/spec/rails_integration_spec.rb +19 -0
  51. data/spec/spec_helper.rb +32 -0
  52. data/spec/support/integration.rb +8 -0
  53. data/spec/tytus_spec.rb +81 -0
  54. data/tytus.gemspec +25 -0
  55. metadata +191 -0
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ *.swp
6
+ *.log
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rvmrc ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env bash
2
+
3
+ environment_id="ruby-1.9.2-p180@tytus"
4
+
5
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
6
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]] ; then
7
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
8
+
9
+ [[ -s ".rvm/hooks/after_use" ]] && . ".rvm/hooks/after_use"
10
+ else
11
+ # If the environment file has not yet been created, use the RVM CLI to select.
12
+ rvm --create "$environment_id"
13
+ fi
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ script: 'rake'
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Piotr Murach
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # Tytus <img src="http://upload.wikimedia.org/wikipedia/en/8/8f/Tytus_Harcerz.jpg" align="right" />
2
+ [![Build Status](https://secure.travis-ci.org/peter-murach/tytus.png?branch=master)][travis] [![Dependency Status](https://gemnasium.com/peter-murach/tytus.png?travis)][gemnasium]
3
+
4
+ [travis]: http://travis-ci.org/peter-murach/tytus
5
+ [gemnasium]: https://gemnasium.com/peter-murach/tytus
6
+
7
+ Helps you manage page titles in your Rails application.
8
+
9
+ In order to improve overall design of your app and increase findability of your pages in search ranks, Tytus gives you a declarative manner in which to title your pages.
10
+
11
+ ## Installation
12
+
13
+ Add to your Gemfile and run the `bundle` command to install.
14
+
15
+ ```ruby
16
+ gem 'tytus'
17
+ ```
18
+
19
+ To configure your Rails 2.x application, in `config/environment.rb` add
20
+
21
+ ```ruby
22
+ config.get 'tytus'
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ Update your locales file as in the following:
28
+
29
+ ```ruby
30
+ en:
31
+ titles:
32
+ site_name: Your site name goes here
33
+ ```
34
+
35
+ In your controllers:
36
+
37
+ ```ruby
38
+ class ArticlesController < ApplicationController
39
+
40
+ title 'A title for this particular controller'
41
+
42
+ end
43
+ ```
44
+
45
+ and this title will be inherited by all actions within controller. Alternatiely, `tytus` will look for controller specific titles in your locales file. You can add them yourself under `titles` key as in the following:
46
+
47
+ ```ruby
48
+ en:
49
+ titles:
50
+ plural_controller_name: Your site name goes here
51
+ ```
52
+
53
+ However, if you need you can overwrite controller specific title on per action basis:
54
+
55
+ ```ruby
56
+ class ArticlesController < ApplicationController
57
+
58
+ title 'A title for this particular controller'
59
+
60
+ def show
61
+ title 'A title for this particular action'
62
+ end
63
+ end
64
+ ```
65
+
66
+ In your views:
67
+
68
+ ```ruby
69
+ <%- title 'A title for this particular view' %>
70
+ ```
71
+
72
+ and this will overwrite controller set titles.
73
+
74
+ Once you set your titles, in your layout call helper method `render_page_title`:
75
+
76
+ ```html
77
+ <head>
78
+ <title><%= render_page_title %></title>
79
+ </head>
80
+ ```
81
+
82
+ By default `::` separator is used to change this pass `separator` hash parameter:
83
+
84
+ ```html
85
+ <head>
86
+ <title><%= render_page_title :separator => ' | ' %></title>
87
+ </head>
88
+ ```
89
+
90
+ ## Development
91
+
92
+ Questions or problems? Please post them on the [issue tracker](https://github.com/peter-murach/tytus/issues). You can contribute changes by forking the project and submitting a pull request. You can ensure the tests are passing by running `bundle` and `rake`.
93
+
94
+ ## Copyright
95
+
96
+ Copyright (c) 2011 Piotr Murach. See LICENSE for further details.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ if defined? Rails
4
+ if Rails.version.to_i < 3
5
+ def rails_3
6
+ false
7
+ end
8
+
9
+ def rails_2
10
+ yield
11
+ end
12
+ else
13
+ def rails_3
14
+ yield
15
+ end
16
+
17
+ def rails_2
18
+ false
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,45 @@
1
+ # encoding: utf-8
2
+
3
+ module Tytus
4
+ module ControllerExtensions
5
+
6
+ def self.included(base)
7
+ base.extend ClassMethods
8
+ if base.respond_to? :class_inheritable_accessor
9
+ base.class_inheritable_accessor :_page_title
10
+ elsif base.respond_to? :class_attribute
11
+ base.class_attribute :_page_title
12
+ else
13
+ base.superclass_delegating_accessor :_page_title
14
+ end
15
+ base.class_eval do
16
+ include InstanceMethods
17
+ end
18
+ end
19
+
20
+ module ClassMethods
21
+
22
+ # Setup before filter which loads title for all actions.
23
+ #
24
+ def title(*args)
25
+ options = args.extract_options!
26
+ text = args
27
+ before_filter(options) do |instance|
28
+ instance.send(:title, text)
29
+ end
30
+ end
31
+
32
+ end # ClassMethods
33
+
34
+ module InstanceMethods
35
+
36
+ # Setup title for the current resource
37
+ #
38
+ def title(text)
39
+ self.class._page_title = text
40
+ end
41
+
42
+ end # InstanceMethods
43
+
44
+ end # ControllerExtensions
45
+ end # Tytus
@@ -0,0 +1,34 @@
1
+ # encoding: utf-8
2
+
3
+ require 'action_controller'
4
+ require 'action_view'
5
+
6
+ module Tytus
7
+ if defined? Rails::Railtie
8
+ class Railtie < Rails::Railtie
9
+ initializer 'tytus.view_extensions' do
10
+ ActiveSupport.on_load :action_view do
11
+ Tytus::Railtie.insert_view
12
+ end
13
+ end
14
+ initializer 'tytus.controller_extensions' do
15
+ ActiveSupport.on_load :action_controller do
16
+ Tytus::Railtie.insert_controller
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ class Railtie
23
+ class << self
24
+ def insert_view
25
+ ::ActionView::Base.send :include, Tytus::ViewExtensions
26
+ end
27
+
28
+ def insert_controller
29
+ ::ActionController::Base.send :include, Tytus::ControllerExtensions
30
+ end
31
+ end
32
+ end
33
+
34
+ end # Tytus
@@ -0,0 +1,5 @@
1
+ # encoding: utf-8
2
+
3
+ module Tytus
4
+ VERSION = "0.0.1"
5
+ end # Tytus
@@ -0,0 +1,64 @@
1
+ # encoding: utf-8
2
+
3
+ module Tytus
4
+ module ViewExtensions
5
+
6
+ attr_accessor :separator
7
+
8
+ # Retrives the current site name, by default reads the name from
9
+ # the locals file.
10
+ #
11
+ def site_name(name = nil)
12
+ name || translate('titles.site_name')
13
+ end
14
+
15
+ # Inserts title string inbetween html title tags.
16
+ #
17
+ def render_page_title(*args)
18
+ options = args.extract_options!
19
+ separator = options[:separator] || " :: "
20
+ if _page_title.present?
21
+ "#{[_page_title].flatten.join(separator)} #{separator} #{site_name}"
22
+ else
23
+ site_name
24
+ end
25
+ end
26
+
27
+ # Check and where possible use translation from the current locale file.
28
+ #
29
+ def check_translation(controller_name)
30
+ if translate('titles.' + controller_name) =~ /translation missing/
31
+ controller_name.humanize
32
+ else
33
+ translate('titles.' + controller_name)
34
+ end
35
+ end
36
+
37
+ # Allows for setting titles in the view layer.
38
+ #
39
+ def title(*args)
40
+ options = args.extract_options!
41
+ unless args.empty?
42
+ @controller.class._page_title = args
43
+ end
44
+ end
45
+
46
+ private
47
+
48
+ def _page_title
49
+ controller_name = @controller.class.name.gsub('Controller', '').downcase
50
+ @controller.class._page_title || check_translation(controller_name)
51
+ end
52
+
53
+ def _content_defined?(symbol)
54
+ rails_2 { !instance_variable_get("@content_for_#{symbol.to_s}").nil? } ||
55
+ rails_3 { content_for? symbol }
56
+ end
57
+
58
+ def _content_for(symbol)
59
+ rails_2 { instance_variable_get("@content_for_#{symbol.to_s}") } ||
60
+ rails_3 { content_for symbol }
61
+ end
62
+
63
+ end # ViewExtensions
64
+ end # Tytus
data/lib/tytus.rb ADDED
@@ -0,0 +1,18 @@
1
+ # encoding: utf-8
2
+
3
+ require "tytus/version"
4
+ require "tytus/railtie"
5
+ require "tytus/compatibility"
6
+ require "tytus/controller_extensions"
7
+ require "tytus/view_extensions"
8
+
9
+ module Tytus
10
+
11
+ if defined? Rails::Railtie
12
+ require "tytus/railtie"
13
+ else
14
+ Tytus::Railtie.insert_view
15
+ Tytus::Railtie.insert_controller
16
+ end
17
+
18
+ end # Tytus
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
3
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
+
5
+ require File.expand_path('../config/application', __FILE__)
6
+
7
+ RailsApp::Application.load_tasks
@@ -0,0 +1,9 @@
1
+ // This is a manifest file that'll be compiled into including all the files listed below.
2
+ // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3
+ // be included in the compiled file accessible from http://example.com/assets/application.js
4
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
+ // the compiled file.
6
+ //
7
+ //= require jquery
8
+ //= require jquery_ujs
9
+ //= require_tree .
@@ -0,0 +1,7 @@
1
+ /*
2
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
3
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
5
+ *= require_self
6
+ *= require_tree .
7
+ */
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,10 @@
1
+ class ArticlesController < ApplicationController
2
+
3
+ title 'All Articles'
4
+
5
+ def index; end
6
+
7
+ def show
8
+ end
9
+
10
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+ <h1>Articles index view</h1>
2
+ <% title 'index', 'view', 'title' %>
@@ -0,0 +1 @@
1
+ <h1>Articles show view</h1>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title><%= render_page_title %></title>
5
+ <%= stylesheet_link_tag "application" %>
6
+ <%= javascript_include_tag "application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,54 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require "active_model/railtie"
4
+ require "active_record/railtie"
5
+ require "action_controller/railtie"
6
+ require "action_view/railtie"
7
+ require "action_mailer/railtie"
8
+
9
+ if defined?(Bundler)
10
+ # If you precompile assets before deploying to production, use this line
11
+ Bundler.require(*Rails.groups(:assets => %w(development test)))
12
+ # If you want your assets lazily compiled in production, use this line
13
+ # Bundler.require(:default, :assets, Rails.env)
14
+ end
15
+
16
+ require 'tytus'
17
+
18
+ module RailsApp
19
+ class Application < Rails::Application
20
+ # Settings in config/environments/* take precedence over those specified here.
21
+ # Application configuration should go into files in config/initializers
22
+ # -- all .rb files in that directory are automatically loaded.
23
+
24
+ # Custom directories with classes and modules you want to be autoloadable.
25
+ # config.autoload_paths += %W(#{config.root}/extras)
26
+
27
+ # Only load the plugins named here, in the order given (default is alphabetical).
28
+ # :all can be used as a placeholder for all plugins not explicitly named.
29
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
30
+
31
+ # Activate observers that should always be running.
32
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
33
+
34
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
35
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
36
+ # config.time_zone = 'Central Time (US & Canada)'
37
+
38
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
39
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
40
+ # config.i18n.default_locale = :de
41
+
42
+ # Configure the default encoding used in templates for Ruby 1.9.
43
+ config.encoding = "utf-8"
44
+
45
+ # Configure sensitive parameters which will be filtered from the log file.
46
+ config.filter_parameters += [:password]
47
+
48
+ # Enable the asset pipeline
49
+ config.assets.enabled = true
50
+
51
+ # Version of your assets, change this if you want to expire all your assets
52
+ config.assets.version = '1.0'
53
+ end
54
+ end
@@ -0,0 +1,8 @@
1
+ require 'rubygems'
2
+
3
+ # Set up gems listed in the Gemfile.
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
5
+
6
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
7
+
8
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ development:
7
+ adapter: sqlite3
8
+ database: db/development.sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ # Warning: The database defined as "test" will be erased and
13
+ # re-generated from your development database when you run "rake".
14
+ # Do not set this db to the same as development or production.
15
+ test:
16
+ adapter: sqlite3
17
+ database: db/test.sqlite3
18
+ pool: 5
19
+ timeout: 5000
20
+
21
+ production:
22
+ adapter: sqlite3
23
+ database: db/production.sqlite3
24
+ pool: 5
25
+ timeout: 5000
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ RailsApp::Application.initialize!
@@ -0,0 +1,30 @@
1
+ RailsApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ # Print deprecation notices to the Rails logger
20
+ config.active_support.deprecation = :log
21
+
22
+ # Only use best-standards-support built into browsers
23
+ config.action_dispatch.best_standards_support = :builtin
24
+
25
+ # Do not compress assets
26
+ config.assets.compress = false
27
+
28
+ # Expands the lines which load the assets
29
+ config.assets.debug = true
30
+ end
@@ -0,0 +1,60 @@
1
+ RailsApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # Code is not reloaded between requests
5
+ config.cache_classes = true
6
+
7
+ # Full error reports are disabled and caching is turned on
8
+ config.consider_all_requests_local = false
9
+ config.action_controller.perform_caching = true
10
+
11
+ # Disable Rails's static asset server (Apache or nginx will already do this)
12
+ config.serve_static_assets = false
13
+
14
+ # Compress JavaScripts and CSS
15
+ config.assets.compress = true
16
+
17
+ # Don't fallback to assets pipeline if a precompiled asset is missed
18
+ config.assets.compile = false
19
+
20
+ # Generate digests for assets URLs
21
+ config.assets.digest = true
22
+
23
+ # Defaults to Rails.root.join("public/assets")
24
+ # config.assets.manifest = YOUR_PATH
25
+
26
+ # Specifies the header that your server uses for sending files
27
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
28
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
29
+
30
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
31
+ # config.force_ssl = true
32
+
33
+ # See everything in the log (default is :info)
34
+ # config.log_level = :debug
35
+
36
+ # Use a different logger for distributed setups
37
+ # config.logger = SyslogLogger.new
38
+
39
+ # Use a different cache store in production
40
+ # config.cache_store = :mem_cache_store
41
+
42
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server
43
+ # config.action_controller.asset_host = "http://assets.example.com"
44
+
45
+ # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
46
+ # config.assets.precompile += %w( search.js )
47
+
48
+ # Disable delivery errors, bad email addresses will be ignored
49
+ # config.action_mailer.raise_delivery_errors = false
50
+
51
+ # Enable threaded mode
52
+ # config.threadsafe!
53
+
54
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
55
+ # the I18n.default_locale when a translation can not be found)
56
+ config.i18n.fallbacks = true
57
+
58
+ # Send deprecation notices to registered listeners
59
+ config.active_support.deprecation = :notify
60
+ end
@@ -0,0 +1,39 @@
1
+ RailsApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Configure static asset server for tests with Cache-Control for performance
11
+ config.serve_static_assets = true
12
+ config.static_cache_control = "public, max-age=3600"
13
+
14
+ # Log error messages when you accidentally call methods on nil
15
+ config.whiny_nils = true
16
+
17
+ # Show full error reports and disable caching
18
+ config.consider_all_requests_local = true
19
+ config.action_controller.perform_caching = false
20
+
21
+ # Raise exceptions instead of rendering exception templates
22
+ config.action_dispatch.show_exceptions = false
23
+
24
+ # Disable request forgery protection in test environment
25
+ config.action_controller.allow_forgery_protection = false
26
+
27
+ # Tell Action Mailer not to deliver emails to the real world.
28
+ # The :test delivery method accumulates sent emails in the
29
+ # ActionMailer::Base.deliveries array.
30
+ config.action_mailer.delivery_method = :test
31
+
32
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
33
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
34
+ # like if you have constraints or database-specific column types
35
+ # config.active_record.schema_format = :sql
36
+
37
+ # Print deprecation notices to the stderr
38
+ config.active_support.deprecation = :stderr
39
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,10 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ RailsApp::Application.config.secret_token = '812ca3d4fc05514bdf140a44bbb92e9bcb98b4821a4ee24480a21c2b709d22c968ae50b99ad89dc69cabd012c0a158b1e1af559eafc709ab210b68302125425e'
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ RailsApp::Application.config.session_store :cookie_store, key: '_rails_app_session'
4
+
5
+ # Use the database for sessions instead of the cookie-based default,
6
+ # which shouldn't be used to store highly confidential information
7
+ # (create the session table with "rails generate session_migration")
8
+ # RailsApp::Application.config.session_store :active_record_store
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json]
9
+ end
10
+
11
+ # Disable root element in JSON by default.
12
+ ActiveSupport.on_load(:active_record) do
13
+ self.include_root_in_json = false
14
+ end
@@ -0,0 +1,4 @@
1
+ en:
2
+ titles:
3
+ site_name: 'My Site Name'
4
+ projects: 'All Projects'
@@ -0,0 +1,4 @@
1
+ RailsApp::Application.routes.draw do
2
+ root :to => 'articles#index'
3
+ resources :articles
4
+ end
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run RailsApp::Application
Binary file
File without changes
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ <p>We've been notified about this issue and we'll take a look at it shortly.</p>
24
+ </div>
25
+ </body>
26
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+ require 'tytus/railtie'
5
+
6
+ Tytus::Railtie.insert_view
7
+ Tytus::Railtie.insert_controller
8
+
9
+ describe "Rails integration", Tytus do
10
+
11
+ include Integration
12
+
13
+ let(:controller) { Class.new(ActionController::Base)}
14
+
15
+ it 'should be able to set title for controller' do
16
+ pending
17
+ # visit root_path
18
+ end
19
+ end
@@ -0,0 +1,32 @@
1
+ require 'tytus'
2
+
3
+ # Configure Rails Envinronment
4
+ ENV["RAILS_ENV"] = "test"
5
+
6
+ require File.expand_path("../rails_app/config/environment.rb", __FILE__)
7
+ require "rails/test_help"
8
+
9
+ require 'action_controller'
10
+ require 'action_view'
11
+
12
+ ActionMailer::Base.delivery_method = :test
13
+ ActionMailer::Base.perform_deliveries = true
14
+ ActionMailer::Base.default_url_options[:host] = "test.com"
15
+
16
+ Rails.backtrace_cleaner.remove_silencers!
17
+
18
+ RSpec.configure do |config|
19
+ config.include ActionController
20
+ config.include ActionView
21
+ end
22
+
23
+ # Configure capybara for integration testing
24
+ require "capybara/rails"
25
+ Capybara.default_driver = :rack_test
26
+ Capybara.default_selector = :css
27
+
28
+ # Run any available migration
29
+ ActiveRecord::Migrator.migrate File.expand_path("rails_app/db/migrate/", __FILE__)
30
+
31
+ # Load support files
32
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
@@ -0,0 +1,8 @@
1
+ module Integration
2
+ def self.included(base)
3
+ base.class_eval do
4
+ include Capybara::DSL
5
+ include Rails.application.routes.url_helpers
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,81 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Tytus do
6
+
7
+ let(:controller) { Class.new(ActionController::Base) }
8
+ let(:controller_instance) { controller.new }
9
+ let(:view) { Class.new(ActionView::Base) }
10
+ let(:view_instance) { view.new }
11
+
12
+ context "methods for classes extending ControllerExtensions" do
13
+
14
+ it "should be mixed in into ActionController::Base" do
15
+ controller.included_modules.include?(Tytus::ControllerExtensions).should be_true
16
+ end
17
+
18
+ context '.title' do
19
+ it "shoulbe be available to ActionController::Base" do
20
+ controller.should respond_to :title
21
+ end
22
+
23
+ it "shoulbe be available to ActionController instance methods" do
24
+ controller_instance.should respond_to :title
25
+ end
26
+ end
27
+
28
+ end # ControllerExtensions
29
+
30
+ context "methods for classes extending ViewExtensions" do
31
+
32
+ it "should be mixed in into ActionView::Base" do
33
+ view.included_modules.include?(Tytus::ViewExtensions).should be_true
34
+ end
35
+
36
+ context '.site_name' do
37
+ it "should be avaialbe to view" do
38
+ view_instance.should respond_to :site_name
39
+ end
40
+
41
+ it "should use translation if name not present" do
42
+ view_instance.site_name.should eq 'My Site Name'
43
+ end
44
+
45
+ it "should use name parameter if given" do
46
+ view_instance.site_name('my-site').should eq 'my-site'
47
+ end
48
+ end
49
+
50
+ context '.render_page_title' do
51
+ it 'should be available to view' do
52
+ view_instance.should respond_to :render_page_title
53
+ end
54
+ end
55
+
56
+ context '.check_translation' do
57
+ it 'should find translation for controller-name' do
58
+ view_instance.check_translation('projects').should eq 'All Projects'
59
+ end
60
+
61
+ it 'should fail to find translation and return humanized controller name' do
62
+ view_instance.check_translation('SomeController').should eq 'Somecontroller'
63
+ end
64
+ end
65
+
66
+ context '.title' do
67
+ it 'should be available to view' do
68
+ view_instance.should respond_to :title
69
+ end
70
+
71
+ it "should " do
72
+ pending
73
+ # controller_instance.stub(:class).and_return controller
74
+ # controller.stub(:name).and_return 'ArticlesController'
75
+ # view_instance.title 'some', 'view'
76
+ # controller._page_title.should eq 'some :: view'
77
+ end
78
+ end
79
+ end # ViewExtensions
80
+
81
+ end # Tytus
data/tytus.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "tytus/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "tytus"
7
+ s.version = Tytus::VERSION
8
+ s.authors = ["Piotr Murach"]
9
+ s.email = [""]
10
+ s.homepage = "https://github.com/peter-murach/tytus"
11
+ s.summary = %q{Helps you manage page titles in your Rails application.}
12
+ s.description = %q{In order to improve overall design of your app and increase findability of your pages in search ranks, Tytus gives you a declarative manner in which to title your pages.}
13
+
14
+ s.rubyforge_project = "tytus"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_development_dependency "rails"
22
+ s.add_development_dependency "sqlite3"
23
+ s.add_development_dependency "rspec"
24
+ s.add_development_dependency "capybara"
25
+ end
metadata ADDED
@@ -0,0 +1,191 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tytus
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Piotr Murach
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-12-17 00:00:00 +00:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rails
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0"
25
+ type: :development
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: sqlite3
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: "0"
36
+ type: :development
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: rspec
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ type: :development
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: capybara
51
+ prerelease: false
52
+ requirement: &id004 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ type: :development
59
+ version_requirements: *id004
60
+ description: In order to improve overall design of your app and increase findability of your pages in search ranks, Tytus gives you a declarative manner in which to title your pages.
61
+ email:
62
+ - ""
63
+ executables: []
64
+
65
+ extensions: []
66
+
67
+ extra_rdoc_files: []
68
+
69
+ files:
70
+ - .gitignore
71
+ - .rspec
72
+ - .rvmrc
73
+ - .travis.yml
74
+ - Gemfile
75
+ - LICENSE
76
+ - README.md
77
+ - Rakefile
78
+ - lib/tytus.rb
79
+ - lib/tytus/compatibility.rb
80
+ - lib/tytus/controller_extensions.rb
81
+ - lib/tytus/railtie.rb
82
+ - lib/tytus/version.rb
83
+ - lib/tytus/view_extensions.rb
84
+ - spec/rails_app/Rakefile
85
+ - spec/rails_app/app/assets/images/rails.png
86
+ - spec/rails_app/app/assets/javascripts/application.js
87
+ - spec/rails_app/app/assets/stylesheets/application.css
88
+ - spec/rails_app/app/controllers/application_controller.rb
89
+ - spec/rails_app/app/controllers/articles_controller.rb
90
+ - spec/rails_app/app/helpers/application_helper.rb
91
+ - spec/rails_app/app/mailers/.gitkeep
92
+ - spec/rails_app/app/models/.gitkeep
93
+ - spec/rails_app/app/views/articles/index.html.erb
94
+ - spec/rails_app/app/views/articles/show.html.erb
95
+ - spec/rails_app/app/views/layouts/application.html.erb
96
+ - spec/rails_app/config.ru
97
+ - spec/rails_app/config/application.rb
98
+ - spec/rails_app/config/boot.rb
99
+ - spec/rails_app/config/database.yml
100
+ - spec/rails_app/config/environment.rb
101
+ - spec/rails_app/config/environments/development.rb
102
+ - spec/rails_app/config/environments/production.rb
103
+ - spec/rails_app/config/environments/test.rb
104
+ - spec/rails_app/config/initializers/backtrace_silencers.rb
105
+ - spec/rails_app/config/initializers/inflections.rb
106
+ - spec/rails_app/config/initializers/mime_types.rb
107
+ - spec/rails_app/config/initializers/secret_token.rb
108
+ - spec/rails_app/config/initializers/session_store.rb
109
+ - spec/rails_app/config/initializers/wrap_parameters.rb
110
+ - spec/rails_app/config/locales/en.yml
111
+ - spec/rails_app/config/routes.rb
112
+ - spec/rails_app/db/test.sqlite3
113
+ - spec/rails_app/lib/assets/.gitkeep
114
+ - spec/rails_app/public/404.html
115
+ - spec/rails_app/public/422.html
116
+ - spec/rails_app/public/500.html
117
+ - spec/rails_app/public/favicon.ico
118
+ - spec/rails_app/script/rails
119
+ - spec/rails_integration_spec.rb
120
+ - spec/spec_helper.rb
121
+ - spec/support/integration.rb
122
+ - spec/tytus_spec.rb
123
+ - tytus.gemspec
124
+ has_rdoc: true
125
+ homepage: https://github.com/peter-murach/tytus
126
+ licenses: []
127
+
128
+ post_install_message:
129
+ rdoc_options: []
130
+
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ none: false
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: "0"
139
+ required_rubygems_version: !ruby/object:Gem::Requirement
140
+ none: false
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: "0"
145
+ requirements: []
146
+
147
+ rubyforge_project: tytus
148
+ rubygems_version: 1.6.2
149
+ signing_key:
150
+ specification_version: 3
151
+ summary: Helps you manage page titles in your Rails application.
152
+ test_files:
153
+ - spec/rails_app/Rakefile
154
+ - spec/rails_app/app/assets/images/rails.png
155
+ - spec/rails_app/app/assets/javascripts/application.js
156
+ - spec/rails_app/app/assets/stylesheets/application.css
157
+ - spec/rails_app/app/controllers/application_controller.rb
158
+ - spec/rails_app/app/controllers/articles_controller.rb
159
+ - spec/rails_app/app/helpers/application_helper.rb
160
+ - spec/rails_app/app/mailers/.gitkeep
161
+ - spec/rails_app/app/models/.gitkeep
162
+ - spec/rails_app/app/views/articles/index.html.erb
163
+ - spec/rails_app/app/views/articles/show.html.erb
164
+ - spec/rails_app/app/views/layouts/application.html.erb
165
+ - spec/rails_app/config.ru
166
+ - spec/rails_app/config/application.rb
167
+ - spec/rails_app/config/boot.rb
168
+ - spec/rails_app/config/database.yml
169
+ - spec/rails_app/config/environment.rb
170
+ - spec/rails_app/config/environments/development.rb
171
+ - spec/rails_app/config/environments/production.rb
172
+ - spec/rails_app/config/environments/test.rb
173
+ - spec/rails_app/config/initializers/backtrace_silencers.rb
174
+ - spec/rails_app/config/initializers/inflections.rb
175
+ - spec/rails_app/config/initializers/mime_types.rb
176
+ - spec/rails_app/config/initializers/secret_token.rb
177
+ - spec/rails_app/config/initializers/session_store.rb
178
+ - spec/rails_app/config/initializers/wrap_parameters.rb
179
+ - spec/rails_app/config/locales/en.yml
180
+ - spec/rails_app/config/routes.rb
181
+ - spec/rails_app/db/test.sqlite3
182
+ - spec/rails_app/lib/assets/.gitkeep
183
+ - spec/rails_app/public/404.html
184
+ - spec/rails_app/public/422.html
185
+ - spec/rails_app/public/500.html
186
+ - spec/rails_app/public/favicon.ico
187
+ - spec/rails_app/script/rails
188
+ - spec/rails_integration_spec.rb
189
+ - spec/spec_helper.rb
190
+ - spec/support/integration.rb
191
+ - spec/tytus_spec.rb