Skip to content

Commit

Permalink
Layout and authentication handling
Browse files Browse the repository at this point in the history
  • Loading branch information
hubertlepicki committed Oct 8, 2010
1 parent 3a5ff0e commit 5f7d165
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
@@ -1,8 +1,11 @@
module GoTranslateYourself
class SiteTranslationsController < ApplicationController
before_filter :auth

def edit
@keys = GoTranslateYourself.current_store.keys_without_prefix
@locales = GoTranslateYourself.locales
render :layout => GoTranslateYourself.layout_name
end

def update
Expand All @@ -13,5 +16,12 @@ def update
end
redirect_to site_translations_path
end

private

def auth
GoTranslateYourself.auth_handler.bind(self).call if GoTranslateYourself.auth_handler.is_a? Proc
end
end
end

14 changes: 3 additions & 11 deletions lib/go_translate_yourself.rb
@@ -1,16 +1,8 @@
require 'go_translate_yourself/engine' if defined?(Rails) && Rails::VERSION::MAJOR == 3

module GoTranslateYourself
def self.current_store=(store)
@store = store
class << self
attr_accessor :layout_name, :locales, :auth_handler, :current_store
end

def self.current_store; @store; end

def self.locales=(array_of_locales)
@locales = array_of_locales
end

def self.locales; @locales; end

end

8 changes: 8 additions & 0 deletions spec/dummy/app/views/layouts/dummy_admin.html.erb
@@ -0,0 +1,8 @@
<html>
<head>
<title>Testing site for GoTranslateYourself!</title>
</head>
<body>
<%= yield %>
</body>
</html>
11 changes: 10 additions & 1 deletion spec/dummy/config/initializers/go_translate_yourself.rb
@@ -1,4 +1,13 @@
GoTranslateYourself.current_store = GoTranslateYourself::MongoStore.new(Mongo::Connection.new.db("go_translate_yourself_test").collection("translations"))
conn = Mongo::Connection.new.db("go_translate_yourself_test").collection("translations")
GoTranslateYourself.current_store = GoTranslateYourself::MongoStore.new(conn)
GoTranslateYourself.locales = [:pl, :de]

I18n.backend = I18n::Backend::KeyValue.new GoTranslateYourself.current_store

#GoTranslateYourself.auth_handler = proc {
# authenticate_or_request_with_http_basic do |user_name, password|
# user_name == 'some' && password == 'user'
# end
#}

GoTranslateYourself.layout_name = "dummy_admin"

0 comments on commit 5f7d165

Please sign in to comment.