ixtlan 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Manifest.txt CHANGED
@@ -43,6 +43,10 @@ lib/ixtlan/optimistic_persistence_module.rb
43
43
  lib/ixtlan/optimistic_persistence_validation.rb
44
44
  lib/ixtlan/error_notifier/error_notification.rhtml
45
45
  lib/ixtlan/controllers/texts_controller.rb
46
+ lib/ixtlan/controllers/permissions_controller.rb
47
+ lib/ixtlan/controllers/authentications_controller.rb
48
+ lib/ixtlan/controllers/configurations_controller.rb
49
+ lib/ixtlan/controllers/word_bundles_controller.rb
46
50
  lib/ixtlan/guard.rb
47
51
  lib/ixtlan/rails/audit.rb
48
52
  lib/ixtlan/rails/error_handling.rb
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ require 'yard'
11
11
 
12
12
  Hoe.spec('ixtlan') do |p|
13
13
  p.developer('mkristian', 'm.kristian@web.de')
14
- p.extra_deps = [['dm-core', '~>0.10.1'], ['dm-validations', '~>0.10.1'], ['dm-timestamps', '~>0.10.1'], ['dm-migrations', '~>0.10.1'], ['slf4r', '~>0.2.0'], ['datamapper4rails', '~>0.3.2'],['rack-datamapper', '~>0.2.5'], ['logging', '~>1.2.3']]
14
+ p.extra_deps = [['dm-core', '~>0.10.1'], ['dm-validations', '~>0.10.1'], ['dm-timestamps', '~>0.10.1'], ['dm-migrations', '~>0.10.1'], ['slf4r', '~>0.2.0'], ['datamapper4rails', '~>0.4.0'],['rack-datamapper', '~>0.2.5'], ['logging', '~>1.2.3']]
15
15
  p.rspec_options << '--options' << 'spec/spec.opts'
16
16
  end
17
17
 
@@ -1,5 +1,3 @@
1
- require 'ixtlan/audit'
2
-
3
1
  Logging.init :debug, :info, :warn, :error, :fatal unless Logging.const_defined? 'MAX_LEVEL_LENGTH'
4
2
 
5
3
  module Ixtlan
@@ -0,0 +1,24 @@
1
+ module Ixtlan
2
+ module Controllers
3
+ module AuthenticationsController
4
+
5
+ protected
6
+ def login_from_params
7
+ auth = params[:authentication]
8
+ User.authenticate(auth[:login], auth[:password])
9
+ end
10
+
11
+ public
12
+ def create
13
+ render_successful_login
14
+ end
15
+
16
+ def destroy
17
+ authentication_logger.log_user(current_user.nil? ? nil : current_user.login, "already logged out")
18
+ session.clear
19
+ head :ok
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,41 @@
1
+ module Ixtlan
2
+ module Controllers
3
+ module ConfigurationsController
4
+
5
+ # GET /configuration
6
+ # GET /configuration.xml
7
+ def show
8
+ @configuration = Configuration.instance
9
+
10
+ respond_to do |format|
11
+ format.html # show.html.erb
12
+ format.xml { render :xml => @configuration }
13
+ end
14
+ end
15
+
16
+ # GET /configuration/edit
17
+ def edit
18
+ @configuration = Configuration.instance
19
+ end
20
+
21
+ # PUT /configuration
22
+ # PUT /configuration.xml
23
+ def update
24
+ @configuration = Configuration.instance
25
+ @configuration.current_user = current_user
26
+
27
+ locales = params[:configuration].delete(:locales)
28
+ respond_to do |format|
29
+ if @configuration.update(params[:configuration]) or not @configuration.dirty?
30
+ flash[:notice] = 'Configuration was successfully updated.'
31
+ format.html { redirect_to(configuration_url) }
32
+ format.xml { render :xml => @configuration }
33
+ else
34
+ format.html { render :action => "edit" }
35
+ format.xml { render :xml => @configuration.errors, :status => :unprocessable_entity }
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,11 @@
1
+ module Ixtlan
2
+ module Controllers
3
+ module PermissionsController
4
+
5
+ def index
6
+ render :xml => Ixtlan::Guard.export_xml
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -8,7 +8,7 @@ module Ixtlan
8
8
  private
9
9
 
10
10
  def locale_guard
11
-
11
+ # TODO
12
12
  end
13
13
 
14
14
  public
@@ -22,17 +22,24 @@ module Ixtlan
22
22
  def create
23
23
  phrase = params[:phrase]
24
24
 
25
- locale = LOCALE.get!(phrase.delete(:locale))
25
+ # load the locale and delete the locale parameter array
26
+ locale = LOCALE.get!(phrase.delete(:locale)[:code])
26
27
 
27
28
  if(TEXT.count(:version => nil, :code => phrase[:code], :locale => locale) == 1)
28
- raise "TODO precondition failed"
29
+ logger.warn "precondition failed: " + phrase.inspect
30
+ # mimic created action
31
+ render :xml => TEXT.first(:version => nil, :code => phrase[:code], :locale => locale).to_xml, :status => :created
32
+ return
29
33
  end
30
34
 
31
35
  phrase[:text] ||= phrase.delete(:current_text)
32
- phrase[:locale] = locale
33
36
 
34
37
  @text = TEXT.new(phrase)
35
38
 
39
+ # set the missing attributes
40
+ @text.locale = locale
41
+ @text.current_user = current_user
42
+
36
43
  respond_to do |format|
37
44
  if @text.save
38
45
  flash[:notice] = 'Text was successfully created.'
@@ -0,0 +1,26 @@
1
+ module Ixtlan
2
+ module Controllers
3
+ module WordBundlesController
4
+
5
+ def show
6
+ locale = params[:id]
7
+ # TODO load in following order and allow to replace findings in the
8
+ # intermediate result set
9
+ # * DEFAULT not_approved
10
+ # * DEFAULT latest_approved
11
+ # * locale-parent latest_approved
12
+ # * locale latest_approved
13
+ l = Locale.get!(locale)
14
+ wordMap = {}
15
+ Ixtlan::Models::Word.not_approved(:locale => Locale.default).each do |word|
16
+ wordMap[word.code] = word
17
+ end
18
+ Ixtlan::Models::Word.approved(:locale => Locale.default).each do |word|
19
+ wordMap[word.code] = word
20
+ end
21
+
22
+ render :xml => "<word_bundle><locale>#{locale}</locale><words>" + wordMap.values.collect { |w| w.to_xml }.join + "</words></word_bundle>"
23
+ end
24
+ end
25
+ end
26
+ end
@@ -16,6 +16,18 @@ module Ixtlan
16
16
 
17
17
  timestamps :created_at
18
18
 
19
+ def parent
20
+ c = attribute_get(:code)
21
+ case c.size
22
+ when 2
23
+ self.model.default
24
+ when 5
25
+ self.model.get!(code[0,2])
26
+ else
27
+ nil
28
+ end
29
+ end
30
+
19
31
  def self.default
20
32
  get(DEFAULT) || create(:code => DEFAULT)
21
33
  end
@@ -94,7 +94,7 @@ module Ixtlan
94
94
 
95
95
  # make sure login is immutable
96
96
  def login=(new_login)
97
- attribute_set(:login, new_login) if (login.nil? or login == "'NULL'" or login == "NULL")
97
+ attribute_set(:login, new_login) if login.nil?
98
98
  end
99
99
 
100
100
  if protected_instance_methods.find {|m| m == 'to_x'}.nil?
@@ -78,7 +78,7 @@ module Rails
78
78
  end
79
79
 
80
80
  def logout
81
- if(params[:login] == current_user.login or request.content_type == 'application/xml')
81
+ if(params[:login] == current_user.login && request.content_type != 'application/xml')
82
82
  authentication_logger.log_user(current_user.login, "logged out")
83
83
  current_user = nil
84
84
  session.clear
@@ -1,3 +1,3 @@
1
1
  class Ixtlan
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ixtlan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - mkristian
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-07 00:00:00 +05:30
12
+ date: 2009-12-18 00:00:00 +05:30
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -70,7 +70,7 @@ dependencies:
70
70
  requirements:
71
71
  - - ~>
72
72
  - !ruby/object:Gem::Version
73
- version: 0.3.2
73
+ version: 0.4.0
74
74
  version:
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: rack-datamapper
@@ -158,6 +158,10 @@ files:
158
158
  - lib/ixtlan/optimistic_persistence_validation.rb
159
159
  - lib/ixtlan/error_notifier/error_notification.rhtml
160
160
  - lib/ixtlan/controllers/texts_controller.rb
161
+ - lib/ixtlan/controllers/permissions_controller.rb
162
+ - lib/ixtlan/controllers/authentications_controller.rb
163
+ - lib/ixtlan/controllers/configurations_controller.rb
164
+ - lib/ixtlan/controllers/word_bundles_controller.rb
161
165
  - lib/ixtlan/guard.rb
162
166
  - lib/ixtlan/rails/audit.rb
163
167
  - lib/ixtlan/rails/error_handling.rb