Skip to content

Commit

Permalink
added config yml and updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Priit Tamboom committed Apr 5, 2012
1 parent 38dd480 commit 7eda280
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 7 deletions.
14 changes: 11 additions & 3 deletions README
Expand Up @@ -4,20 +4,28 @@ Tolk is a Rails engine designed to facilitate the translators doing the dirty wo

To install :

$ script/plugin install git://github.com/gitlabeu/tolk.git
$ script/plugin install git://github.com/dhh/tolk.git

To setup :
1) Copy example config file and update required:
$ cd vendor/plugins/tolk/config
$ cp config-example.yml config.yml
$ vi config.yml

1) Generate tolk migration and migrate your database :
2) Generate tolk migration and migrate your database :

$ script/generate tolk_migration
$ rake db:migrate

2) Setup Tolk assets by creating a symlink to tolk/public/tolk inside your application's public directory :
3) Setup Tolk assets by creating a symlink to tolk/public/tolk inside your application's public directory :

$ cd public
$ ln -s ../vendor/plugins/tolk/public/tolk tolk

4) Add custom logo

Make sure your master application has logo file at master app: /public/images/logo.png

And you're all set!

* Usage
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/tolk/application_controller.rb
Expand Up @@ -8,12 +8,12 @@ class ApplicationController < ActionController::Base

def authenticate
#self.authenticator.bind(self).call if self.authenticator && self.authenticator.respond_to?(:call)
if !['priit', 'testlab'].include?(Socket.gethostname)
if !(::ALLOWED_HOSTNAMES.include?(Socket.gethostname))
return render :text => 'No permission', :status => 403
end

authenticate_or_request_with_http_basic do |user_name, password|
user_name == 'lux' && password == 'luxtranslation'
user_name == ::USERNAME && password == ::PASSWORD
end

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">
<a href='<%= tolk_root_path %>' style='display: block; margin-bottom: 35px'>
<img src='/images/lux_express_logo.png' height='60px' />
<img src='/images/logo.png' height='60px' />
</a>

<div id="head">
Expand Down
8 changes: 8 additions & 0 deletions config/config-example.yml
@@ -0,0 +1,8 @@
---
username: tolk
password: please-change-password

allowed_hostnames:
- priit
- veiko
- testlux
1 change: 1 addition & 0 deletions config/environment.rb
Expand Up @@ -14,3 +14,4 @@

$KCODE = 'UTF8'
require 'ya2yaml'

1 change: 1 addition & 0 deletions config/environments/development.rb
Expand Up @@ -15,3 +15,4 @@

# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false

8 changes: 8 additions & 0 deletions config/initializers/load_confing.rb
@@ -0,0 +1,8 @@
require 'yaml'
config = File.open('../config.yml')

YAML::load_documents(config) do |conf|
ALLOWED_HOSTNAMES = conf['allowed_hostnames']
USERNAME = conf['username']
PASSWORD = conf['password']
end
11 changes: 11 additions & 0 deletions lib/tolk.rb
@@ -1,2 +1,13 @@
module Tolk
end

# load local config file, is there any better place, somehow it didn't work on init.rb
require 'yaml'
config_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'config.yml'))
config = File.open(config_path)

YAML::load_documents(config) do |conf|
ALLOWED_HOSTNAMES = conf['allowed_hostnames']
USERNAME = conf['username']
PASSWORD = conf['password']
end
1 change: 0 additions & 1 deletion lib/tolk/import.rb
Expand Up @@ -42,6 +42,5 @@ def read_locale_file

self.class.flat_hash(YAML::load(IO.read(locale_file))[self.name])
end

end
end

0 comments on commit 7eda280

Please sign in to comment.