talia_core 0.4.1 → 0.4.2

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.
Files changed (139) hide show
  1. data/VERSION.yml +4 -0
  2. data/config/database.yml +19 -0
  3. data/config/database.yml.example +35 -0
  4. data/config/rdfstore.yml +13 -0
  5. data/config/rdfstore.yml.example +13 -0
  6. data/config/rdfstore.yml.rdflite_example +16 -0
  7. data/config/rdfstore.yml.redland_example +46 -0
  8. data/config/talia_core.yml +14 -0
  9. data/config/talia_core.yml.example +42 -0
  10. data/generators/generator_helpers.rb +49 -0
  11. data/generators/talia_admin/USAGE +1 -0
  12. data/generators/talia_admin/talia_admin_generator.rb +19 -0
  13. data/generators/talia_admin/templates/controllers/admin/background_controller.rb +50 -0
  14. data/generators/talia_admin/templates/controllers/admin/custom_templates_controller.rb +25 -0
  15. data/generators/talia_admin/templates/controllers/admin/locales_controller.rb +15 -0
  16. data/generators/talia_admin/templates/controllers/admin/sources_controller.rb +71 -0
  17. data/generators/talia_admin/templates/controllers/admin/translations_controller.rb +61 -0
  18. data/generators/talia_admin/templates/controllers/admin/users_controller.rb +48 -0
  19. data/generators/talia_admin/templates/controllers/admin_controller.rb +7 -0
  20. data/generators/talia_admin/templates/helpers/admin/background_helper.rb +60 -0
  21. data/generators/talia_admin/templates/helpers/admin/custom_templates_helper.rb +5 -0
  22. data/generators/talia_admin/templates/helpers/admin/locales_helper.rb +2 -0
  23. data/generators/talia_admin/templates/helpers/admin/sources_helper.rb +65 -0
  24. data/generators/talia_admin/templates/helpers/admin/translations_helper.rb +51 -0
  25. data/generators/talia_admin/templates/helpers/admin/users_helper.rb +2 -0
  26. data/generators/talia_admin/templates/helpers/admin_helper.rb +11 -0
  27. data/generators/talia_admin/templates/public/images/backend/body_bg.gif +0 -0
  28. data/generators/talia_admin/templates/public/images/backend/footer_bg.gif +0 -0
  29. data/generators/talia_admin/templates/public/images/backend/header.jpg +0 -0
  30. data/generators/talia_admin/templates/public/images/backend/header_bg.gif +0 -0
  31. data/generators/talia_admin/templates/public/images/backend/menu.jpg +0 -0
  32. data/generators/talia_admin/templates/public/images/backend/menu_bg.gif +0 -0
  33. data/generators/talia_admin/templates/public/images/backend/opednid.gif +0 -0
  34. data/generators/talia_admin/templates/public/images/backend/page_bg.jpg +0 -0
  35. data/generators/talia_admin/templates/public/images/backend/triangolino.gif +0 -0
  36. data/generators/talia_admin/templates/public/images/backend/triangolino_full.gif +0 -0
  37. data/generators/talia_admin/templates/public/javascripts/backend.js +24 -0
  38. data/generators/talia_admin/templates/public/javascripts/lowpro.js +321 -0
  39. data/generators/talia_admin/templates/public/stylesheets/backend.css +466 -0
  40. data/generators/talia_admin/templates/test/fixtures/users.yml +32 -0
  41. data/generators/talia_admin/templates/test/functional/admin/custom_templates_controller_test.rb +8 -0
  42. data/generators/talia_admin/templates/test/functional/admin/locales_controller_test.rb +35 -0
  43. data/generators/talia_admin/templates/test/functional/admin/sources_controller_test.rb +109 -0
  44. data/generators/talia_admin/templates/test/functional/admin/translations_controller_test.rb +93 -0
  45. data/generators/talia_admin/templates/test/functional/admin/users_controller_test.rb +67 -0
  46. data/generators/talia_admin/templates/test/functional/admin_controller_test.rb +15 -0
  47. data/generators/talia_admin/templates/test/unit/user_test.rb +134 -0
  48. data/generators/talia_admin/templates/views/admin/background/_finished.html.erb +9 -0
  49. data/generators/talia_admin/templates/views/admin/background/_pending.html.erb +1 -0
  50. data/generators/talia_admin/templates/views/admin/background/_progress.html.erb +15 -0
  51. data/generators/talia_admin/templates/views/admin/background/_running.html.erb +11 -0
  52. data/generators/talia_admin/templates/views/admin/background/environment.html.erb +12 -0
  53. data/generators/talia_admin/templates/views/admin/background/show.html.erb +17 -0
  54. data/generators/talia_admin/templates/views/admin/background/stderr.html.erb +6 -0
  55. data/generators/talia_admin/templates/views/admin/background/stdin.html.erb +6 -0
  56. data/generators/talia_admin/templates/views/admin/background/stdout.html.erb +6 -0
  57. data/generators/talia_admin/templates/views/admin/custom_templates/_content_form_column.rhtml +2 -0
  58. data/generators/talia_admin/templates/views/admin/custom_templates/_template_type_form_column.rhtml +2 -0
  59. data/generators/talia_admin/templates/views/admin/index.html.erb +5 -0
  60. data/generators/talia_admin/templates/views/admin/locales/new.html.erb +9 -0
  61. data/generators/talia_admin/templates/views/admin/sources/_data.html.erb +6 -0
  62. data/generators/talia_admin/templates/views/admin/sources/_data_form.html.erb +15 -0
  63. data/generators/talia_admin/templates/views/admin/sources/_form.html.erb +7 -0
  64. data/generators/talia_admin/templates/views/admin/sources/_list.html.erb +3 -0
  65. data/generators/talia_admin/templates/views/admin/sources/_notice.html.erb +1 -0
  66. data/generators/talia_admin/templates/views/admin/sources/_predicate.html.erb +22 -0
  67. data/generators/talia_admin/templates/views/admin/sources/_predicates.html.erb +15 -0
  68. data/generators/talia_admin/templates/views/admin/sources/_sources.html.erb +17 -0
  69. data/generators/talia_admin/templates/views/admin/sources/_upload.html.erb +6 -0
  70. data/generators/talia_admin/templates/views/admin/sources/edit.html.erb +6 -0
  71. data/generators/talia_admin/templates/views/admin/sources/index.html.erb +5 -0
  72. data/generators/talia_admin/templates/views/admin/translations/_new_translation.html.erb +7 -0
  73. data/generators/talia_admin/templates/views/admin/translations/_translation.html.erb +10 -0
  74. data/generators/talia_admin/templates/views/admin/translations/edit.html.erb +16 -0
  75. data/generators/talia_admin/templates/views/admin/users/_form.html.erb +10 -0
  76. data/generators/talia_admin/templates/views/admin/users/_form_roles.html.erb +8 -0
  77. data/generators/talia_admin/templates/views/admin/users/edit.html.erb +12 -0
  78. data/generators/talia_admin/templates/views/admin/users/index.html.erb +22 -0
  79. data/generators/talia_admin/templates/views/admin/users/new.html.erb +5 -0
  80. data/generators/talia_admin/templates/views/admin/users/show.html.erb +6 -0
  81. data/generators/talia_admin/templates/views/layouts/admin.html.erb +56 -0
  82. data/generators/talia_base/USAGE +5 -0
  83. data/generators/talia_base/talia_base_generator.rb +62 -0
  84. data/generators/talia_base/templates/app/controllers/custom_templates_controller.rb +27 -0
  85. data/generators/talia_base/templates/app/controllers/ontologies_controller.rb +13 -0
  86. data/generators/talia_base/templates/app/controllers/sessions_controller.rb +90 -0
  87. data/generators/talia_base/templates/app/controllers/source_data/show.html.erb +2 -0
  88. data/generators/talia_base/templates/app/controllers/source_data_controller.rb +43 -0
  89. data/generators/talia_base/templates/app/controllers/sources_controller.rb +62 -0
  90. data/generators/talia_base/templates/app/controllers/types_controller.rb +23 -0
  91. data/generators/talia_base/templates/app/helpers/custom_templates_helper.rb +2 -0
  92. data/generators/talia_base/templates/app/helpers/ontologies_helper.rb +2 -0
  93. data/generators/talia_base/templates/app/helpers/sessions_helper.rb +2 -0
  94. data/generators/talia_base/templates/app/helpers/source_data/show.html.erb +2 -0
  95. data/generators/talia_base/templates/app/helpers/source_data_helper.rb +2 -0
  96. data/generators/talia_base/templates/app/helpers/sources_helper.rb +39 -0
  97. data/generators/talia_base/templates/app/helpers/types_helper.rb +2 -0
  98. data/generators/talia_base/templates/app/views/ontologies/index.builder +10 -0
  99. data/generators/talia_base/templates/app/views/ontologies/show.builder +7 -0
  100. data/generators/talia_base/templates/app/views/sessions/new.html.erb +33 -0
  101. data/generators/talia_base/templates/app/views/source_data/show.html.erb +2 -0
  102. data/generators/talia_base/templates/app/views/sources/_form.html.erb +15 -0
  103. data/generators/talia_base/templates/app/views/sources/edit.html.erb +9 -0
  104. data/generators/talia_base/templates/app/views/sources/index.html.erb +2 -0
  105. data/generators/talia_base/templates/app/views/sources/new.html.erb +8 -0
  106. data/generators/talia_base/templates/app/views/sources/show.html.erb +19 -0
  107. data/generators/talia_base/templates/app/views/types/index.html.erb +4 -0
  108. data/generators/talia_base/templates/app/views/types/show.html.erb +3 -0
  109. data/generators/talia_base/templates/config/routes.rb +83 -0
  110. data/generators/talia_base/templates/config/talia_initializer.rb +8 -0
  111. data/generators/talia_base/templates/migrations/bj_migration.rb +10 -0
  112. data/generators/talia_base/templates/migrations/constraint_migration.rb +24 -0
  113. data/generators/talia_base/templates/migrations/create_active_sources.rb +15 -0
  114. data/generators/talia_base/templates/migrations/create_custom_templates.rb +17 -0
  115. data/generators/talia_base/templates/migrations/create_data_records.rb +27 -0
  116. data/generators/talia_base/templates/migrations/create_open_id.rb +26 -0
  117. data/generators/talia_base/templates/migrations/create_progress_jobs.rb +18 -0
  118. data/generators/talia_base/templates/migrations/create_roles.rb +20 -0
  119. data/generators/talia_base/templates/migrations/create_semantic_properties.rb +14 -0
  120. data/generators/talia_base/templates/migrations/create_semantic_relations.rb +17 -0
  121. data/generators/talia_base/templates/migrations/create_sessions.rb +16 -0
  122. data/generators/talia_base/templates/migrations/create_users.rb +20 -0
  123. data/generators/talia_base/templates/migrations/create_workflows.rb +28 -0
  124. data/generators/talia_base/templates/migrations/populate_users.rb +11 -0
  125. data/generators/talia_base/templates/migrations/upgrade_relations.rb +12 -0
  126. data/generators/talia_base/templates/ontologies/hyper_ontology.owl +1462 -0
  127. data/generators/talia_base/templates/ontologies/hyper_ontology.pprj +9351 -0
  128. data/generators/talia_base/templates/ontologies/hyper_ontology.repository +6 -0
  129. data/generators/talia_base/templates/ontologies/scholar_0.1.owl +109 -0
  130. data/generators/talia_base/templates/script/configure_talia +292 -0
  131. data/generators/talia_base/templates/script/prepare_images +100 -0
  132. data/generators/talia_base/templates/talia.sh +51 -0
  133. data/generators/talia_base/templates/tasks/talia_core.rk +1 -0
  134. data/lib/loader_helper.rb +9 -0
  135. data/lib/talia_core.rb +0 -2
  136. data/lib/talia_dependencies.rb +5 -0
  137. data/lib/talia_util/rake_tasks.rb +223 -0
  138. data/tasks/talia_core_tasks.rake +2 -0
  139. metadata +138 -13
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :minor: 4
3
+ :major: 0
4
+ :patch: 2
@@ -0,0 +1,19 @@
1
+ ---
2
+ production:
3
+ adapter: jdbcmysql
4
+ host: localhost
5
+ password: talia
6
+ username: talia
7
+ database: talia_2_3_new_talia_production
8
+ test:
9
+ adapter: jdbcmysql
10
+ host: localhost
11
+ password: talia
12
+ username: talia
13
+ database: talia_2_3_new_talia_test
14
+ development:
15
+ adapter: jdbcmysql
16
+ host: localhost
17
+ password: talia
18
+ username: talia
19
+ database: talia_2_3_new_talia_development
@@ -0,0 +1,35 @@
1
+ # MySQL (default setup). Versions 4.1 and 5.0 are recommended.
2
+ #
3
+ # Install the MySQL driver:
4
+ # gem install mysql
5
+ # On MacOS X:
6
+ # gem install mysql -- --include=/usr/local/lib
7
+ # On Windows:
8
+ # There is no gem for Windows. Install mysql.so from RubyForApache.
9
+ # http://rubyforge.org/projects/rubyforapache
10
+ #
11
+ # And be sure to use new-style password hashing:
12
+ # http://dev.mysql.com/doc/refman/5.0/en/old-client.html
13
+ development:
14
+ adapter: mysql
15
+ database: Talia_development
16
+ username: rails
17
+ password: slilRuAmNep3
18
+ host: localhost
19
+
20
+ # Warning: The database defined as 'test' will be erased and
21
+ # re-generated from your development database when you run 'rake'.
22
+ # Do not set this db to the same as development or production.
23
+ test:
24
+ adapter: mysql
25
+ database: Talia_test
26
+ username: rails
27
+ password: slilRuAmNep3
28
+ host: localhost
29
+
30
+ production:
31
+ adapter: mysql
32
+ database: Talia_production
33
+ username: rails
34
+ password: slilRuAmNep3
35
+ host: localhost
@@ -0,0 +1,13 @@
1
+ ---
2
+ production:
3
+ type: sesame
4
+ location: ./sesame_production.db
5
+ backend: native
6
+ test:
7
+ type: sesame
8
+ location: ./sesame_test.db
9
+ backend: native
10
+ development:
11
+ type: sesame
12
+ location: ./sesame_development.db
13
+ backend: native
@@ -0,0 +1,13 @@
1
+ ---
2
+ production:
3
+ type: sesame
4
+ location: ./sesame_production.db
5
+ backend: native
6
+ test:
7
+ type: sesame
8
+ location: ./sesame_test.db
9
+ backend: native
10
+ development:
11
+ type: sesame
12
+ location: ./sesame_development.db
13
+ backend: native
@@ -0,0 +1,16 @@
1
+ # RDF store setup for rdland
2
+ development:
3
+ type: rdflite
4
+ dbfile: rdflite_development.db
5
+
6
+ # Warning: The database defined as 'test' will be erased and
7
+ # re-generated from your development database when you run 'rake'.
8
+ # Do not set this db to the same as development or production.
9
+ test:
10
+ type: rdflite
11
+
12
+
13
+ # WARNING: YOU REALLY DO NOT WANT TO USE RDFLIT IN AN PRODUCTION ENVIRONMENT!
14
+ production:
15
+ type: rdflite
16
+ dbfile: rdflist_production.db
@@ -0,0 +1,46 @@
1
+ # RDF store setup for rdland with mysql store
2
+ development:
3
+ type: redland
4
+ name: dbl
5
+ location: mysql
6
+ database: Talia_development_rdf
7
+ user: root
8
+ password:
9
+ host: localhost
10
+
11
+ # Configuration example for redland with hashes(bdb) store
12
+ # You may also use "memory" instead of "hashes" for the memory-only store
13
+ #
14
+ # development:
15
+ # type: redland
16
+ # location: hashes
17
+ # name: talia_development
18
+ # hash-type: bdb
19
+ # dir: .
20
+
21
+
22
+ # Warning: The database defined as 'test' will be erased and
23
+ # re-generated from your development database when you run 'rake'.
24
+ # Do not set this db to the same as development or production.
25
+ test:
26
+ type: rdflite
27
+
28
+ production:
29
+ type: redland
30
+ name: dbl
31
+ location: mysql
32
+ database: Talia_production_rdf
33
+ user: root
34
+ password:
35
+ host: localhost
36
+
37
+ # Configuration example for redland with hashes(bdb) store
38
+ # You may also use "memory" instead of "hashes" for the memory-only store
39
+ #
40
+ # production:
41
+ # type: redland
42
+ # location: hashes
43
+ # name: talia_production
44
+ # hash-type: bdb
45
+ # dir: .
46
+
@@ -0,0 +1,14 @@
1
+ ---
2
+ site_name: Talia 2.3.
3
+ rdf_connection_file: rdfstore
4
+ ardf_log_level: 0
5
+ local_uri: http://localhost:5000/
6
+ default_namespace_uri: http://default.dummy/
7
+ iip_root_directory_location:
8
+ standalone_db: true
9
+ db_file: database
10
+ namespaces:
11
+ dcns: http://purl.org/dc/elements/1.1/
12
+ dct: http://purl.org/dc/terms/
13
+ dcmit: http://purl.org/dc/dcmitype/
14
+ hyper: http://www.hypernietzsche.org/ontology/
@@ -0,0 +1,42 @@
1
+ # TaliaCore configuration file
2
+
3
+ # The domain URI that is the "local" domain of this installation
4
+ local_uri: "http://test.dummy/"
5
+ # The domain URI that is used as a default if no namespace is given
6
+ default_namespace_uri: "http://default.dummy/"
7
+
8
+ # The RDF store configuration can be read from a file
9
+ rdf_connection_file: rdfstore
10
+ # RDF configuration can also be given as a hash here
11
+ # rdf_connection:
12
+
13
+ # Set the logging level for ActiveRDF
14
+ ardf_log_level: 0
15
+
16
+ # If standalone_db is set, ActiveRecord will be configured for use
17
+ # without the Rails environment
18
+ standalone_db: true
19
+ db_file: database
20
+ # Database configuration can also be given as a hash here
21
+ # db_connection:
22
+ # If unset, the databse log will end up in the default log directory
23
+ # db_log: database.log
24
+
25
+ # The location for data files (only set if you need to change
26
+ # the default location)
27
+ # data_directory_location: "/var/www/talia_data/"
28
+
29
+ # Configure the namespaces for use with RDF
30
+ namespaces:
31
+ # Default namespaces rdf, rdfs, xsd, owl are defined in the semantic_naming
32
+ # library.
33
+ # HyperNietzsche namespace
34
+ hyper: "http://www.hypernietzsche.org/ontology/"
35
+ # DublinCore namespace
36
+ dcns: "http://purl.org/dc/elements/1.1/"
37
+ dct: "http://purl.org/dc/terms/"
38
+ dcmit: "http://purl.org/dc/dcmitype/"
39
+
40
+
41
+
42
+
@@ -0,0 +1,49 @@
1
+ module GeneratorHelpers
2
+
3
+ DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
4
+
5
+ def files_in(m, dir, top_dir = '')
6
+ Dir["#{File.join(self_dir, 'templates', dir)}/*"].each do |file|
7
+
8
+ m.directory "#{top_dir}#{dir}"
9
+
10
+ if(File.directory?(file))
11
+ files_in(m, "#{dir}/#{File.basename(file)}", top_dir)
12
+ else
13
+ m.file "#{dir}/#{File.basename(file)}", "#{top_dir}#{dir}/#{File.basename(file)}"
14
+ end
15
+ end
16
+ end
17
+
18
+ def make_migration(m, template_name)
19
+ m.migration_template "migrations/#{template_name}", "db/migrate", :migration_file_name => template_name.gsub(/\.rb\Z/, '')
20
+ end
21
+
22
+ end
23
+
24
+ # This monkeypatches a problem in the generator that causes it to have
25
+ # migration ids based on the timestamp in seconds. If more than one
26
+ # migration is generated at a time (that is, whithin one second),
27
+ # this will cause them to not work because of identical ids.
28
+ module Rails
29
+ module Generator
30
+ module Commands
31
+ class Create
32
+
33
+ alias :orig_migration_string :next_migration_string
34
+
35
+ def migration_count
36
+ @m_count ||= 0
37
+ @m_count += 1
38
+ @m_count
39
+ end
40
+
41
+ def next_migration_string(padding = 3)
42
+ return orig_migration_string(padding) unless(ActiveRecord::Base.timestamped_migrations)
43
+ (Time.now.utc.strftime("%Y%m%d%H%M") + ("%.2d" % migration_count))
44
+ end
45
+
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1 @@
1
+ Installs all files for the Talia administration backend.
@@ -0,0 +1,19 @@
1
+ require File.dirname(__FILE__) + '/../generator_helpers'
2
+
3
+ class TaliaAdminGenerator < Rails::Generator::Base
4
+
5
+ include GeneratorHelpers
6
+
7
+ def self_dir ; File.dirname(__FILE__) ; end
8
+
9
+ def manifest
10
+ record do |m|
11
+ files_in m, 'views', 'app/'
12
+ files_in m, 'helpers', 'app/'
13
+ files_in m, 'controllers', 'app/'
14
+ files_in m, 'public'
15
+ files_in m, 'test'
16
+ end
17
+ end
18
+
19
+ end
@@ -0,0 +1,50 @@
1
+ class Admin::BackgroundController < ApplicationController
2
+ layout 'admin', :except => [:update_progress]
3
+ require_role 'admin'
4
+
5
+ active_scaffold 'Bj::Table::Job' do |config|
6
+ # runner = Bj::Runner.ping
7
+ runner_label = "no runner active"
8
+ config.label = "Job Management (#{runner_label})"
9
+
10
+ if(!Bj.config[Bj::Runner.no_tickle_key])
11
+ config.action_links.add('tickle', :label => 'Tickle Runner', :action => 'tickle', :parameters => {:id => '0'})
12
+ end
13
+
14
+ config.actions.exclude :create, :update, :delete
15
+ config.show.link.inline = false
16
+ config.columns = [ :state, :tag, :pid, :submitter, :runner, :submitted_at ]
17
+ end
18
+
19
+ def tickle
20
+ Bj::Runner.tickle
21
+ redirect_to :action => 'index'
22
+ end
23
+
24
+ def show
25
+ @job = Bj::Table::Job.find(params['id'])
26
+ end
27
+
28
+ def stdin
29
+ @job = Bj::Table::Job.find(params['id'])
30
+ end
31
+
32
+ def stdout
33
+ @job = Bj::Table::Job.find(params['id'])
34
+ end
35
+
36
+ def stderr
37
+ @job = Bj::Table::Job.find(params['id'])
38
+ end
39
+
40
+ def environment
41
+ @job = Bj::Table::Job.find(params['id'])
42
+ @environment = @job.env ? YAML.load(@job.env) : nil
43
+ end
44
+
45
+ def update_progress
46
+ @job = Bj::Table::Job.find(params['id'])
47
+ @progress_job = TaliaCore::BackgroundJobs::ProgressJob.find(:first, :conditions => { :job_id => @job.id })
48
+ render :partial => 'progress'
49
+ end
50
+ end
@@ -0,0 +1,25 @@
1
+ class Admin::CustomTemplatesController < ApplicationController
2
+ layout 'admin'
3
+ require_role 'admin'
4
+
5
+ active_scaffold :custom_template do |config|
6
+ config.columns = [:name, :template_type, :content]
7
+ config.action_links.add 'clear_cache', :label => 'Clear Cache'
8
+ end
9
+
10
+ def clear_cache
11
+ CustomTemplate.find(:all).each do |template|
12
+ expire_page(:controller => '/custom_templates', :action => template.template_type, :id => template.name)
13
+ end
14
+ render :text => 'Template cache cleared'
15
+ end
16
+
17
+ protected
18
+
19
+ # Before an updated record, clean out the cache for that page
20
+ def before_update_save(record)
21
+ expire_page(:controller => '/custom_templates', :action => record.template_type, :id => record.name)
22
+ puts "EXPIRED"
23
+ end
24
+
25
+ end
@@ -0,0 +1,15 @@
1
+ class Admin::LocalesController < ApplicationController
2
+ layout 'admin'
3
+
4
+ def new
5
+ end
6
+
7
+ def create
8
+ if I18n.add_locale(params[:name], params[:code])
9
+ redirect_to edit_admin_translation_path(params[:code])
10
+ else
11
+ flash[:error] = "Invalid locale, please check the format and make sure the language is available."
12
+ render :action => 'new'
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,71 @@
1
+ require 'paginator'
2
+
3
+ class Admin::SourcesController < ApplicationController
4
+ include TaliaCore
5
+ require_role 'admin'
6
+ layout 'admin'
7
+ cache_sweeper :av_media_sweeper, :only => :update
8
+
9
+ # GET /admin/sources
10
+ # GET /admin/sources.xml
11
+ def index
12
+ @sources = TaliaCore::Source.paginate :page => params[:page], :per_page => 10
13
+
14
+ respond_to do |format|
15
+ format.html # index.html.erb
16
+ format.xml { render :xml => @sources }
17
+ format.js do
18
+ render :update do |page|
19
+ page.replace_html 'sources', :partial => 'sources'
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ # GET /admin/sources/1/edit
26
+ def edit
27
+ @source = TaliaCore::Source.find_by_partial_uri(params[:id])
28
+ end
29
+
30
+ # PUT /admin/sources/1
31
+ # PUT /admin/sources/1.xml
32
+ def update
33
+ @source = TaliaCore::Source.find_by_id(params[:id])
34
+
35
+ respond_to do |format|
36
+ if @source.update_attributes(params[:source])
37
+ flash[:notice] = 'Source was successfully updated.'
38
+ format.html { redirect_to :action => "index" }
39
+ format.xml { head :ok }
40
+ else
41
+ format.html { render :action => "edit" }
42
+ format.xml { render :xml => @source.errors, :status => :unprocessable_entity }
43
+ end
44
+ end
45
+ end
46
+
47
+ # GET /admin/sources/data/1
48
+ def data
49
+ # We need to specify the clause, because of Source#find overwrite the
50
+ # default behavior.
51
+ @source = TaliaCore::Source.find_by_id(params[:id])
52
+
53
+ respond_to do |format|
54
+ format.js do
55
+ render :update do |page|
56
+ page.replace_html 'list', :partial => 'list'
57
+ page.insert_html :top, 'data', :partial => 'notice', :locals => { :text => 'Your file has been saved.'}
58
+ page[:data_notice].visual_effect :highlight
59
+ page[:data_notice].visual_effect :fade, :duration => 3
60
+ page.delay(3.1) { page.remove :data_notice }
61
+ end
62
+ end
63
+ end
64
+ end
65
+
66
+ # GET /admin/sources/auto_complete_for_source/aaa
67
+ def auto_complete_for_source
68
+ @items = TaliaCore::Source.find_by_uri_token(params[:source][:predicates_attributes].first[:titleized])
69
+ render :inline => "<%= auto_complete_result @items, 'titleized' %>"
70
+ end
71
+ end
@@ -0,0 +1,61 @@
1
+ class Admin::TranslationsController < ApplicationController
2
+ layout 'admin'
3
+ require_role 'admin'
4
+ PER_PAGE = 30
5
+
6
+ after_filter :flush_locale, :only => [:update, :destroy]
7
+
8
+ # GET /admin/translations
9
+ def index
10
+ redirect_to edit_admin_translation_path(Locale.active.code)
11
+ end
12
+
13
+ # GET /admin/translations/search?key1=hello%20world&key2=good_morning
14
+ def search
15
+ keys = params.map {|key, value| value if key.to_s =~ /key/}.compact
16
+ translations = ViewTranslation.find_by_locale_and_tr_key(params[:locale], keys)
17
+ session[:reference_locale] = params[:locale]
18
+
19
+ respond_to do |format|
20
+ format.js { render :layout => false, :inline => translations.to_json }
21
+ end
22
+ end
23
+
24
+ # GET /admin/translations/en-US/edit
25
+ def edit
26
+ @translations = ViewTranslation.find_by_locale(params[:id], :order => "tr_key ASC")
27
+ @locale_code = params[:id]
28
+ @autoload = load_reference_translations?
29
+ end
30
+
31
+ # PUT /admin/translations/en-US
32
+ def update
33
+ if ViewTranslation.create_or_update(params[:translations], params[:id])
34
+ flash[:notice] = 'Your translations has been saved'
35
+ else
36
+ flash[:error] = 'There was some problems'
37
+ end
38
+
39
+ redirect_to edit_admin_translation_path(params[:id])
40
+ end
41
+
42
+ # DELETE /admin/translations/1
43
+ def destroy
44
+ @translation = ViewTranslation.find(params[:id])
45
+ @translation.destroy
46
+
47
+ respond_to do |format|
48
+ format.html do
49
+ flash[:notice] = 'Your translation has been deleted'
50
+ redirect_to edit_admin_translation_path(params[:locale])
51
+ end
52
+ format.js
53
+ end
54
+ end
55
+
56
+ private
57
+
58
+ def load_reference_translations?
59
+ !!session[:reference_locale] && session[:reference_locale] != params[:locale]
60
+ end
61
+ end
@@ -0,0 +1,48 @@
1
+ class Admin::UsersController < ApplicationController
2
+ require_role 'admin'
3
+ layout 'admin'
4
+ PER_PAGE = 10
5
+
6
+ def index
7
+ @users = User.paginate(:page => params[:page], :per_page => PER_PAGE)
8
+ end
9
+
10
+ def show
11
+ @user = User.find(params[:id])
12
+ end
13
+
14
+ def new
15
+ @user = User.new
16
+ end
17
+
18
+ def create
19
+ @user = User.new(params[:user])
20
+
21
+ if @user.save
22
+ flash[:notice] = "User was successfully created."
23
+ redirect_to :action => 'show', :id => @user
24
+ else
25
+ render :action => 'new'
26
+ end
27
+ end
28
+
29
+ def edit
30
+ @user = User.find(params[:id])
31
+ end
32
+
33
+ def update
34
+ @user = User.find(params[:id])
35
+
36
+ if @user.update_attributes(params[:user])
37
+ flash[:notice] = "User was successfully updated."
38
+ redirect_to :action => 'show', :id => @user
39
+ else
40
+ render :action => 'edit'
41
+ end
42
+ end
43
+
44
+ def destroy
45
+ User.find(params[:id]).destroy
46
+ redirect_to :action => 'index'
47
+ end
48
+ end
@@ -0,0 +1,7 @@
1
+ class AdminController < ApplicationController
2
+ require_role 'admin'
3
+
4
+ def index
5
+ @links = %w(users custom_templates translations) # sources removed as non-working
6
+ end
7
+ end
@@ -0,0 +1,60 @@
1
+ module Admin::BackgroundHelper
2
+
3
+ def render_job
4
+ case(@job.state)
5
+ when 'finished'
6
+ render :partial => 'finished'
7
+ when 'running'
8
+ render :partial => 'running'
9
+ when 'pending'
10
+ render :partial => 'pending'
11
+ else
12
+ "Unknown state #{@job.state}"
13
+ end
14
+ end
15
+
16
+ def progress_eta
17
+ return 'Finishing...' unless(@progress_job.percentage < 100)
18
+ ('ETA: ' + duration_s(@progress_job.eta)).gsub(' ', '&nbsp;')
19
+ end
20
+
21
+ def job_tag
22
+ "- #{@job.tag}" if(@job.tag)
23
+ end
24
+
25
+ def job_duration
26
+ finished = @job.finished_at || Time.now
27
+ duration_s(finished - @job.started_at)
28
+ end
29
+
30
+ def job_link
31
+ link_to('Back to job', :action => 'show', :id => @job.id)
32
+ end
33
+
34
+ def stdout_link
35
+ link_to('View STDOUT', :action => 'stdout', :id => @job.id) unless(@job.stdout.blank?)
36
+ end
37
+
38
+ def stderr_link
39
+ link_to('View STDERR', :action => 'stderr', :id => @job.id) unless(@job.stderr.blank?)
40
+ end
41
+
42
+ def stdin_link
43
+ link_to('View STDIN', :action => 'stdin', :id => @job.id) unless(@job.stdin.blank?)
44
+ end
45
+
46
+ def environment_link
47
+ link_to('Runtime Environment', :action => 'environment', :id => @job.id) unless(@job.env.blank?)
48
+ end
49
+
50
+ def duration_s(seconds)
51
+ minutes, seconds = seconds.divmod(60)
52
+ hours, minutes = (minutes == 0) ? [0, 0] : minutes.divmod(60)
53
+ duration_s = ''
54
+ (duration_s << "#{hours.to_i} hours ") if(hours != 0)
55
+ (duration_s << "#{minutes.to_i} minutes ") if(minutes != 0)
56
+ duration_s << "#{seconds.to_i} seconds"
57
+ duration_s
58
+ end
59
+
60
+ end
@@ -0,0 +1,5 @@
1
+ module Admin::CustomTemplatesHelper
2
+ def content_column(record)
3
+ h(record.content[0..20] + ' ...')
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ module Admin::LocalesHelper
2
+ end