Skip to content

Commit

Permalink
Converted tolk to mountable engine
Browse files Browse the repository at this point in the history
2 tests still fail and integration tests must be run with selenium
because of bug in capybara.
  • Loading branch information
drogus committed Sep 12, 2010
1 parent 863399b commit 7e06bea
Show file tree
Hide file tree
Showing 82 changed files with 66,881 additions and 283 deletions.
5 changes: 4 additions & 1 deletion .gitignore
@@ -1 +1,4 @@
tmp/**/*
tmp/**/*
test/dummy/db/migrate/*.tolk.rb
Gemfile.lock
.bundle
16 changes: 16 additions & 0 deletions Gemfile
@@ -1 +1,17 @@
source "http://rubygems.org"

gem "rails", :git => "http://github.com/rails/rails.git"
gem "arel", :git => "http://github.com/rails/arel.git"

gem 'will_paginate', :git => 'http://github.com/mislav/will_paginate.git', :branch => 'rails3'
gem "ya2yaml"

gem "factory_girl_rails"
gem "capybara", ">= 0.3.9"
gem "sqlite3-ruby", :require => "sqlite3"
gem "mocha"

if RUBY_VERSION < '1.9'
gem "ruby-debug", ">= 0.10.3"
end

43 changes: 36 additions & 7 deletions Rakefile
@@ -1,10 +1,39 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require(File.join(File.dirname(__FILE__), 'config', 'boot'))

# encoding: UTF-8
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/gempackagetask'

require 'rake/testtask'

Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end

task :default => :test

Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'Tolk'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end

spec = Gem::Specification.new do |s|
s.name = "tolk"
s.summary = "Rails engine providing web interface for managing i18n yaml files"
s.description = "Tolk is a web interface for doing i18n translations packaged as an engine for Rails applications."
s.files = FileList["[A-Z]*", "lib/**/*"]
s.version = "2.0.0.beta"
end

Rake::GemPackageTask.new(spec) do |pkg|
end

require 'tasks/rails'
desc "Install the gem #{spec.name}-#{spec.version}.gem"
task :install do
system("gem install pkg/#{spec.name}-#{spec.version}.gem --no-ri --no-rdoc")
end
2 changes: 1 addition & 1 deletion app/controllers/tolk/application_controller.rb
Expand Up @@ -11,7 +11,7 @@ def authenticate
end

def ensure_no_primary_locale
redirect_to tolk_locales_path if @locale.primary?
redirect_to tolk.locales_path if @locale.primary?
end
end
end
2 changes: 1 addition & 1 deletion app/models/tolk/locale.rb
Expand Up @@ -133,7 +133,7 @@ def phrases_without_translation(page = nil, options = {})
existing_ids = self.translations.all(:select => 'tolk_translations.phrase_id').map(&:phrase_id).uniq
phrases = phrases.scoped(:conditions => ['tolk_phrases.id NOT IN (?)', existing_ids]) if existing_ids.present?

result = phrases.paginate({:page => page}.merge(options))
result = phrases.paginate({:page => page, :per_page => Phrase.per_page}.merge(options))
Tolk::Phrase.send :preload_associations, result, :translations
result
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/tolk/application.html.erb
Expand Up @@ -19,7 +19,7 @@
<body>
<div id="container">
<div id="head">
<h1><span class="home"><%= link_to "Tolk", tolk_root_path %></span><%= yield :locale %></h1>
<h1><span class="home"><%= link_to "Tolk", tolk.root_path %></span><%= yield :locale %></h1>
</div>
<%= yield %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/tolk/locales/all.html.erb
Expand Up @@ -4,7 +4,7 @@
<h3 class="switch">Completed translations <span>(<%= link_to 'See phrases missing translation', @locale %>)</span></h3>

<% if @locale.has_updated_translations? && action_name != 'updated' %>
<span class="notice">Some phrases have changed. <%= link_to "Update translations", updated_tolk_locale_path(@locale) %>.</span>
<span class="notice">Some phrases have changed. <%= link_to "Update translations", tolk.updated_locale_path(@locale) %>.</span>
<% end %>

<div class="search">
Expand Down
1 change: 0 additions & 1 deletion app/views/tolk/locales/index.html.erb
Expand Up @@ -21,7 +21,6 @@
<% end %>
<%= form_for(Tolk::Locale.new) do |f| %>
<div class="submit">
<%= f.error_messages %>
<p>
<%= f.label "Add a new Locale" %>
<select id="select_tolk_locale_name" name="tolk_locale[name]">
Expand Down
6 changes: 3 additions & 3 deletions app/views/tolk/locales/show.html.erb
Expand Up @@ -3,13 +3,13 @@
<% end %>
<% content_for :head do %>
<link rel="alternate" type="application/rss+xml" title="RSS" href="<%= tolk_locale_path(@locale, :format => 'atom') -%>" />
<link rel="alternate" type="application/rss+xml" title="RSS" href="<%= tolk.locale_path(@locale, :format => 'atom') -%>" />
<% end %>

<h3 class="switch">Phrases missing translation (<%= @locale.count_phrases_without_translation %>) <span>(<%= link_to 'See completed translations', all_tolk_locale_path(@locale) %>)</span></h3>
<h3 class="switch">Phrases missing translation (<%= @locale.count_phrases_without_translation %>) <span>(<%= link_to 'See completed translations', tolk.all_locale_path(@locale) %>)</span></h3>

<% if @locale.has_updated_translations? && action_name != 'updated' %>
<span class="notice">Some phrases have changed. <%= link_to "Update translations", updated_tolk_locale_path(@locale) %>.</span>
<span class="notice">Some phrases have changed. <%= link_to "Update translations", tolk.updated_locale_path(@locale) %>.</span>
<% end %>

<div class="search">
Expand Down
2 changes: 1 addition & 1 deletion app/views/tolk/searches/show.html.erb
Expand Up @@ -9,7 +9,7 @@
<div class="search_exits">
<%= link_to "Phrases missing translation", @locale %>
&nbsp;
<%= link_to "Completed translations", all_tolk_locale_path(@locale) %>
<%= link_to "Completed translations", tolk.all_locale_path(@locale) %>
</div>

<div class="translations">
Expand Down
109 changes: 0 additions & 109 deletions config/boot.rb

This file was deleted.

16 changes: 0 additions & 16 deletions config/environment.rb

This file was deleted.

17 changes: 0 additions & 17 deletions config/environments/development.rb

This file was deleted.

24 changes: 0 additions & 24 deletions config/environments/production.rb

This file was deleted.

22 changes: 0 additions & 22 deletions config/environments/test.rb

This file was deleted.

1 change: 0 additions & 1 deletion config/initializers/mime_types.rb

This file was deleted.

17 changes: 0 additions & 17 deletions config/initializers/new_rails_defaults.rb

This file was deleted.

13 changes: 8 additions & 5 deletions config/routes.rb
@@ -1,7 +1,10 @@
Rails.application.routes.draw do |map|
map.namespace('tolk') do |tolk|
tolk.root :controller => 'locales'
tolk.resources :locales, :member => {:all => :get, :updated => :get}
tolk.resource :search
Tolk::Engine.routes.draw do
root :to => 'locales#index'
resources :locales do
member do
get :all
get :updated
end
end
resource :search
end
2 changes: 2 additions & 0 deletions lib/tolk.rb
@@ -1,6 +1,8 @@
require 'will_paginate'
require 'ya2yaml'
require 'tolk/engine'
require 'tolk/sync'
require 'tolk/import'

module Tolk
end
2 changes: 1 addition & 1 deletion lib/tolk/engine.rb
Expand Up @@ -2,6 +2,6 @@

module Tolk
class Engine < Rails::Engine
engine_name :tolk
namespace Tolk
end
end
7 changes: 7 additions & 0 deletions test/dummy/Rakefile
@@ -0,0 +1,7 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)
require 'rake'

Dummy::Application.load_tasks

0 comments on commit 7e06bea

Please sign in to comment.