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
@@ -0,0 +1,22 @@
1
+ <table id="translations">
2
+ <tr>
3
+ <th>Login</th>
4
+ <th>E-Mail</th>
5
+ <th colspan="3"></th>
6
+ </tr>
7
+ <% for user in @users %>
8
+ <tr>
9
+ <td><%=h user.login %></td>
10
+ <td><%=h user.email %></td>
11
+ <td><%= link_to "Show", :action => 'show', :id => user %></td>
12
+ <td><%= link_to "Edit", :action => 'edit', :id => user %></td>
13
+ <td><%= link_to "Destroy", :action => 'destroy', :id => user, :confirm => 'Are you sure?', :method => :delete %></td>
14
+ </tr>
15
+ <% end %>
16
+ </table>
17
+ <br />
18
+
19
+ <%= will_paginate @users %>
20
+
21
+ <br />
22
+ <%= link_to "Create new user", :action => "new" %>
@@ -0,0 +1,5 @@
1
+ <%= error_messages_for :user %>
2
+ <% form_for(@user, :url => {:controller => 'admin/users', :action => 'create'}) do |f| %>
3
+ <%= render :partial => "form" %>
4
+ <p><%= f.submit "submit" %> or <%= link_to "cancel", :action => 'index' %></p>
5
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1><%=h @user.login %></h1>
2
+ <p><%= link_to h(@user.open_id), h(@user.open_id) %></p>
3
+ <h2>Roles</h2>
4
+ <div><%=h @user.roles_to_sentence %></div><br />
5
+
6
+ <%= link_to "Back", :action => 'index' %> | <%= link_to "Edit", :action => 'edit', :id => @user %>
@@ -0,0 +1,56 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
6
+ <meta name="keywords" content="parole chiave" />
7
+ <meta name="description" content="Descrizione" />
8
+ <meta name="copyright" content="Copyright" />
9
+ <meta name="robots" content="all" />
10
+ <meta http-equiv="pragma" content="no-cache" />
11
+ <%= stylesheet_link_tag('backend') %>
12
+ <%= javascript_include_tag('prototype') %>
13
+ <%= javascript_include_tag('scriptaculous') %>
14
+ <%= javascript_include_tag('lowpro') %>
15
+ <%= javascript_include_tag('backend') %>
16
+ <%= javascript_include_tag(:defaults) %>
17
+ <%= active_scaffold_includes %>
18
+ <%= yield :javascript %>
19
+ <link rel="shortcut icon" type="image/ico" href="/favicon.ico" />
20
+
21
+ <title><%= page_title %></title>
22
+ </head>
23
+
24
+ <body>
25
+
26
+ <div id="paginaExt">
27
+ <div id="paginaInt">
28
+ <div id="testata">
29
+ <h1>Discovery Project</h1>
30
+ <p class="testata_sottotitolo">Backend Management</p>
31
+ </div>
32
+
33
+ <div id="menu">
34
+ <ul>
35
+ <li><%= link_to('Home', '/') %>
36
+ <li><%= link_to('Users', :controller => 'admin/users') %></li>
37
+ <li><%= link_to('Translations', :controller => 'admin/translations') %></li>
38
+ <li><%= link_to('Templates', :controller => 'admin/custom_templates')%>
39
+ <li><%= link_to('Logout', '/logout') %></li>
40
+ </ul>
41
+ </div>
42
+
43
+ <div id="contenuti">
44
+
45
+ <div class="floatClear">
46
+ </div>
47
+
48
+ <!-- LOGIN -->
49
+ <div id="contenutoInterno">
50
+ <%= show_flash %>
51
+ <%= yield %>
52
+ </div>
53
+ </div>
54
+ </div>
55
+ </div>
56
+ </body>
@@ -0,0 +1,5 @@
1
+ Installs the base elements of a Talia application. This will install the migrations,
2
+ the base controllers, ontologies and scripts. You should also install talia's route.rb
3
+ file when asked.
4
+
5
+ After you ran this task, you can run script/configure_talia to generate a first configuration.
@@ -0,0 +1,62 @@
1
+ require File.dirname(__FILE__) + '/../generator_helpers'
2
+
3
+ class TaliaBaseGenerator < Rails::Generator::Base
4
+
5
+ include GeneratorHelpers
6
+
7
+ def manifest
8
+ puts "Trying to install the plugins before generation"
9
+ plugin_script = File.join(RAILS_ROOT, 'script', 'plugin')
10
+ c = ::Config::CONFIG
11
+ ruby = File.join(c['bindir'], c['ruby_install_name']) << c['EXEEXT']
12
+
13
+ system("#{ruby} #{plugin_script} install git://github.com/activescaffold/active_scaffold.git")
14
+ system("#{ruby} #{plugin_script} install git://github.com/timcharper/role_requirement.git")
15
+
16
+ record do |m|
17
+ # Some initialization stuff
18
+ m.directory 'config/initializers'
19
+ m.file "config/talia_initializer.rb", "config/initializers/talia.rb"
20
+ m.file "config/routes.rb", "config/routes.rb", :collision => :ask
21
+ m.file "talia.sh", "talia.sh", :shebang => '/bin/sh', :chmod => 0755
22
+
23
+ # Install the scripts
24
+ m.directory 'script'
25
+ m.file 'script/configure_talia', 'script/configure_talia', :shebang => DEFAULT_SHEBANG, :chmod => 0755
26
+ m.file 'script/prepare_images', 'script/prepare_images', :shebang => DEFAULT_SHEBANG, :chmod => 0755
27
+
28
+ # The whole app shebang of files
29
+ files_in m, 'app'
30
+
31
+ # The default ontologies
32
+ files_in m, 'ontologies'
33
+
34
+ # Add the migrations
35
+ m.directory 'db/migrate'
36
+ m.file "migrations/constraint_migration.rb", "db/migrate/constraint_migration.rb"
37
+ make_migration m, "create_sessions.rb"
38
+ make_migration m, "create_users.rb"
39
+ make_migration m, "create_open_id.rb"
40
+ make_migration m, "create_roles.rb"
41
+ make_migration m, "populate_users.rb"
42
+ make_migration m, "create_active_sources.rb"
43
+ make_migration m, "create_semantic_relations.rb"
44
+ make_migration m, "create_semantic_properties.rb"
45
+ make_migration m, "create_data_records.rb"
46
+ make_migration m, "create_workflows.rb"
47
+ make_migration m, "create_custom_templates.rb"
48
+ make_migration m, "upgrade_relations.rb"
49
+ make_migration m, "create_progress_jobs.rb"
50
+ make_migration m, "bj_migration.rb"
51
+
52
+ # Set up the rake tasks, only if we come from a gem
53
+ if(Gem.source_index.find_name('talia_core').first)
54
+ m.directory 'lib/tasks'
55
+ m.file 'tasks/talia_core.rk', 'lib/tasks/talia_core.rake'
56
+ end
57
+ end
58
+ end
59
+
60
+ def self_dir ; File.dirname(__FILE__) ; end
61
+
62
+ end
@@ -0,0 +1,27 @@
1
+ class CustomTemplatesController < ApplicationController
2
+
3
+ layout nil
4
+ session :off
5
+
6
+ caches_page :xslt
7
+
8
+ def stylesheets
9
+ render_template('css', 'text/css')
10
+ end
11
+
12
+ def xslt
13
+ render_template('xslt', 'application/xml')
14
+ end
15
+
16
+ private
17
+
18
+ def render_template(type, mime_type)
19
+ template = CustomTemplate.find(:first, :conditions => { :name => params[:id], :template_type => type })
20
+ if(template)
21
+ render(:text => template.content, :content_type => mime_type)
22
+ else
23
+ render(:nothing => true, :status => 404)
24
+ end
25
+ end
26
+
27
+ end
@@ -0,0 +1,13 @@
1
+ class OntologiesController < ApplicationController
2
+
3
+ def index
4
+ onto_qry = Query.new(N::URI).select(:context).distinct.where(N::TALIA.rdf_context_space, N::TALIA.rdf_file_context, :context)
5
+ @ontologies = onto_qry.execute.collect { |context| context.local_name }
6
+ end
7
+
8
+ def show
9
+ ontology_url = N::TALIA + URI.encode(params[:id])
10
+ @triples = Query.new(N::URI).select(:s, :p, :o).where(:s, :p, :o, ontology_url).execute
11
+ end
12
+
13
+ end
@@ -0,0 +1,90 @@
1
+ # This controller handles the login/logout function of the site.
2
+ class SessionsController < ApplicationController
3
+
4
+ cache_sweeper :editions_sweeper, :only => [:destroy]
5
+ layout 'admin'
6
+
7
+ # render new.rhtml
8
+ def new
9
+ end
10
+
11
+ # login
12
+ def create
13
+ if using_open_id?
14
+ open_id_authentication(params[:openid_url])
15
+ else
16
+ password_authentication(params[:login], params[:password])
17
+ end
18
+ end
19
+
20
+ # logout
21
+ def destroy
22
+ if logged_in?
23
+ self.current_user.forget_me
24
+ empty_cache = true
25
+ end
26
+ cookies.delete :auth_token
27
+ reset_session
28
+ flash[:notice] = "You have been logged out."
29
+ # When a translator logs out, we want to perform a cache cleaning, since we don't
30
+ # know what that translator changed and where.
31
+ # Still, we don't want to perform the cache cleaning any time a user invokes the
32
+ # /logout URL
33
+ # To check if we are _actually_ performing a logout, we check if we were logged_in?
34
+ #
35
+ # TODO: why are we still logged in here?
36
+ if empty_cache
37
+ # TODO: since we are still logged in here (why?), we need to empty the @current_user val
38
+ # otherwise the perform_caching method (in the application controller) will return false
39
+ # (as it esplicitely shuts down the caching when a user is logged in)
40
+ @current_user = nil
41
+ EditionsSweeper.instance.clean_cache
42
+ end
43
+ redirect_back_or_default('/')
44
+ end
45
+
46
+ protected
47
+
48
+ # password authentication
49
+ def password_authentication(login, password)
50
+ self.current_user = User.authenticate(login, password)
51
+ if logged_in?
52
+ successful_login
53
+ else
54
+ failed_login
55
+ end
56
+ end
57
+
58
+ # open id authentication
59
+ def open_id_authentication(identity_url)
60
+ authenticate_with_open_id(identity_url) do |status, identity_url|
61
+ if status.successful?
62
+ if self.current_user = User.open_id_authentication(identity_url)
63
+ successful_login
64
+ else
65
+ failed_login "Sorry, no user by that identity URL exists (#{identity_url})"
66
+ end
67
+ else
68
+ failed_login status.message
69
+ end
70
+ end
71
+ end
72
+
73
+ private
74
+
75
+ # login successful
76
+ def successful_login
77
+ if params[:remember_me] == "1"
78
+ self.current_user.remember_me
79
+ cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at }
80
+ end
81
+ redirect_back_or_default('/')
82
+ flash[:notice] = "Logged in successfully"
83
+ end
84
+
85
+ # login failed
86
+ def failed_login(message = nil)
87
+ flash[:error] = message if !message.nil?
88
+ render :action => 'new'
89
+ end
90
+ end
@@ -0,0 +1,2 @@
1
+ <h1>SourceData#show</h1>
2
+ <p>Find me in app/views/source_data/show.html.erb</p>
@@ -0,0 +1,43 @@
1
+ class SourceDataController < ApplicationController
2
+ include TaliaCore::DataTypes
3
+ # TODO: Needs upload_progress plugin - not so important atm
4
+ # upload_status_for :create
5
+
6
+ # GET /source_data/1
7
+ def show
8
+ send_record_data(TaliaCore::DataTypes::DataRecord.find(params[:id]))
9
+ end
10
+
11
+ def show_tloc
12
+ @source_data = TaliaCore::DataTypes::DataRecord.find_by_type_and_location!(params[:type], params[:location])
13
+ send_record_data(@source_data)
14
+ end
15
+
16
+ # POST /source_data
17
+ def create
18
+ status = TaliaCore::DataTypes::FileRecord.find_or_create_and_assign_file(params[:data_record]) ? 200 : 500
19
+ render :inline => '', :status => status
20
+ end
21
+
22
+ # DELETE /source_data/1
23
+ def destroy
24
+ @source_data = TaliaCore::DataTypes::DataRecord.find(params[:id])
25
+ @source = @source_data.source_record
26
+ @source_data.destroy
27
+ render :update do |page|
28
+ page.replace_html 'list', :partial => "admin/sources/data", :collection => @source.data
29
+ page.insert_html :top, 'data', :partial => 'admin/sources/notice', :locals => { :text => 'Your file has been destroyed.'}
30
+ page[:data_notice].visual_effect :highlight
31
+ page[:data_notice].visual_effect :fade, :duration => 3
32
+ page.delay(3.1) { page.remove :data_notice }
33
+ end
34
+ end
35
+
36
+ # Send the record to the browser
37
+ def send_record_data(record)
38
+ send_data record.content_string, :type => record.mime_type,
39
+ :disposition => 'inline',
40
+ :filename => "#{params[:location]}.tif"
41
+ end
42
+
43
+ end
@@ -0,0 +1,62 @@
1
+ class SourcesController < ApplicationController
2
+ include TaliaCore
3
+
4
+ before_filter :setup_format
5
+
6
+ PER_PAGE = 10
7
+
8
+ # GET /sources
9
+ # GET /sources.xml
10
+ def index
11
+
12
+ end
13
+
14
+ # GET /sources/1
15
+ # GET /sources/1.xml
16
+ def show
17
+ raise(ActiveRecord::RecordNotFound) unless(ActiveSource.exists?(params[:id]))
18
+ @source = ActiveSource.find(params[:id])
19
+ respond_to do |format|
20
+ format.xml { render :text => @source.to_xml }
21
+ format.rdf { render :text => @source.to_rdf }
22
+ format.html { render }
23
+ end
24
+ end
25
+
26
+ # GET /sources/1/name
27
+ def show_attribute
28
+ headers['Content-Type'] = Mime::TEXT
29
+ attribute = TaliaCore::Source.find(params[:source_id])[params[:attribute]]
30
+ status = '404 Not Found' if attribute.nil?
31
+ render :text => attribute.to_s, :status => status
32
+ end
33
+
34
+ # GET /sources/1/foaf/friend
35
+ def show_rdf_predicate
36
+ headers['Content-Type'] = Mime::TEXT
37
+ predicates = TaliaCore::Source.find(params[:id]).predicate(params[:namespace], params[:predicate])
38
+ if predicates.nil?
39
+ # This is a workaround: when predicates is nil it tries to render a template with the name of this method.
40
+ predicates = ''
41
+ status = '404 Not Found'
42
+ end
43
+ render :text => predicates, :status => status
44
+ end
45
+
46
+ private
47
+
48
+
49
+ # Hack around routing limitation: We use the @ instead of the dot as a delimiter
50
+ def setup_format
51
+ split_id = params[:id].split('@')
52
+ assit(split_id.size <= 2)
53
+ params[:id] = split_id.first
54
+ params[:format] = (split_id.size > 1) ? split_id.last : 'html'
55
+ end
56
+
57
+
58
+ def get_uri
59
+
60
+ end
61
+
62
+ end
@@ -0,0 +1,23 @@
1
+ class TypesController < ApplicationController
2
+
3
+ # GET /sources
4
+ # GET /sources.xml
5
+ def index
6
+ respond_to do |format|
7
+ format.html # index.html.erb
8
+ format.xml { render :xml => @sources }
9
+ end
10
+ end
11
+
12
+ # GET /sources/1
13
+ # GET /sources/1.xml
14
+ def show
15
+ @type = N::SourceClass.make_uri(params[:id], "_")
16
+ @page_title = "Talia | #{@type.to_name_s}"
17
+ respond_to do |format|
18
+ format.html # show.html.erb
19
+ format.xml { render :xml => @source }
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,2 @@
1
+ module CustomTemplatesHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module OntologiesHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module SessionsHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ <h1>SourceData#show</h1>
2
+ <p>Find me in app/views/source_data/show.html.erb</p>
@@ -0,0 +1,2 @@
1
+ module SourceDataHelper
2
+ end
@@ -0,0 +1,39 @@
1
+ module SourcesHelper
2
+
3
+ # Renders the data
4
+ def render_source_data
5
+ result = ""
6
+ if(@source.data_records.size > 0)
7
+ @source.data_records.each do |data_record|
8
+ case(data_record.mime_type)
9
+ when 'text/html'
10
+ result += "<h3>HTML Data: #{data_record.location}</h3>"
11
+ result += "<div>"
12
+ result += widget(:html_data, :data => data_record)
13
+ result += "</div>"
14
+ when 'text/xml'
15
+ result += "<pre><code>"
16
+ result += data_record.get_escaped_content_string
17
+ result += "</code></pre>"
18
+ when 'text/plain'
19
+ result += "<h3>Plain Text Data: #{data_record.location}</h3>"
20
+ result += "<pre> #{data_record.all_text} </pre>"
21
+ else
22
+ result += "<h3>Found data object of type #{data_record.class} (#{data_record.mime_type}): #{data_record.location}</h3>"
23
+ end
24
+ end
25
+ else
26
+ result ="<h3>Sorry mate, no data objects here</h3>"
27
+ end
28
+
29
+ result
30
+ end
31
+
32
+ def source_toolbar
33
+ widget(:toolbar, :buttons => [
34
+ ["Lucca", {:action => 'show', :id => 'Lucca'}],
35
+ ["All", {:action => 'index'} ],
36
+ ["Print Page", "javascript:print();"]
37
+ ] )
38
+ end
39
+ end
@@ -0,0 +1,2 @@
1
+ module TypesHelper
2
+ end
@@ -0,0 +1,10 @@
1
+ xml.instruct!
2
+
3
+ xml.urlset(:xmlns => 'http://www.sitemaps.org/schemas/sitemap/0.9', 'xmlns:sc' => 'http://sw.deri.org/2007/07/sitemapextension/scschema.xsd') do
4
+ @ontologies.each do |ontology|
5
+ xml.sc :dataset do
6
+ xml.sc :datasetLabel, ontology.titleize
7
+ xml.sc :datasetURI, url_for(:action => 'show', :id => ontology, :only_path => false)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ xml.instruct!
2
+
3
+ TaliaCore::ActiveSourceParts::Xml::RdfBuilder.open(:builder => xml) do |builder| # Create from the default builder passed to this template
4
+ @triples.each do |onto_triple|
5
+ builder.write_triple(*onto_triple)
6
+ end
7
+ end
@@ -0,0 +1,33 @@
1
+ <div id="password_login">
2
+ <% form_tag session_path do -%>
3
+ <p><label for="login">Login</label><br/>
4
+ <%= text_field_tag 'login' %></p>
5
+
6
+ <p><label for="password">Password</label><br/>
7
+ <%= password_field_tag 'password' %></p>
8
+ <!-- Uncomment this if you want this functionality
9
+ <p><label for="remember_me">Remember me:</label>
10
+ <%= check_box_tag 'remember_me' %></p>
11
+ -->
12
+
13
+ <p><%= submit_tag 'Log in' %></p>
14
+ <% end -%>
15
+ <a href="#">switch to open-id login</a>
16
+ </div>
17
+
18
+ <div id="openid_login">
19
+ <% form_tag session_path do -%>
20
+ <p><label for="openid_url">OpenId</label><br/>
21
+ <%= text_field_tag 'openid_url' %></p>
22
+
23
+ <!-- Uncomment this if you want this functionality
24
+ <p><label for="remember_me">Remember me:</label>
25
+ <%= check_box_tag 'remember_me' %></p>
26
+ -->
27
+
28
+ <p><%= submit_tag 'Log in' %></p>
29
+ <% end -%>
30
+ <a href="#">switch to username/password login</a>
31
+ </div>
32
+
33
+ <%= javascript_include_tag('session') %>
@@ -0,0 +1,2 @@
1
+ <h1>SourceData#show</h1>
2
+ <p>Find me in app/views/source_data/show.html.erb</p>
@@ -0,0 +1,15 @@
1
+ <%= error_messages_for 'source' %>
2
+ <!--[form:source]-->
3
+ <p><label for="source_name">Name</label><br/>
4
+ <%= text_field 'source', 'name', :value => @source.name,
5
+ :tabindex => 10 %></p>
6
+
7
+ <p><label for="source_uri">Uri</label><br/>
8
+ <%= text_field 'source', 'uri', :value => @source.uri,
9
+ :tabindex => 20 %></p>
10
+
11
+ <p><label for="source_primary_source">Primary Source</label><br/>
12
+ <%= select 'source', 'primary_source', [false, true],
13
+ :tabindex => 40 %>
14
+ </p>
15
+ <!--[eoform:source]-->
@@ -0,0 +1,9 @@
1
+ <h1>Edit source</h1>
2
+
3
+ <% form_tag :action => 'update', :html => {:method => :put} do %>
4
+ <%= render :partial => 'form' %>
5
+ <%= submit_tag "Update" %>
6
+ <% end %>
7
+
8
+ <%= link_to 'Back', :action => :index %> |
9
+ <%= link_to "Show", source_path(@source) %>
@@ -0,0 +1,2 @@
1
+ <h1>Sources found: <%= @sources.total_entries %></h1>
2
+ <%= widget(:grouped_list, :id => 'main_list', :group_property => :type, :group_values => @types, :group_increment => @group_increment) %>
@@ -0,0 +1,8 @@
1
+ <h1>New source</h1>
2
+
3
+ <% form_tag :action => 'create' do %>
4
+ <%= render :partial => 'form' %>
5
+ <%= submit_tag "Create" %>
6
+ <% end %>
7
+
8
+ <%= link_to 'Back', :action => :index %>
@@ -0,0 +1,19 @@
1
+ <h2><%= @source.uri.to_name_s %></h2>
2
+ <table>
3
+ <% for attribute, value in @source.attributes %>
4
+ <tr>
5
+ <td><%= attribute %></td>
6
+ <td><%= value %></td>
7
+ </tr>
8
+ <% end %>
9
+ <% for predicate in @source.direct_predicates %>
10
+ <tr>
11
+ <td><%= predicate %></td>
12
+ <td>
13
+ <% @source[predicate].each do |val| %>
14
+ <%= val %><br/>
15
+ <% end %>
16
+ </td>
17
+ </tr>
18
+ <% end %>
19
+ </table>
@@ -0,0 +1,4 @@
1
+ <div id="types_list">
2
+ <h2>Please select a type</h2>
3
+ </div>
4
+
@@ -0,0 +1,3 @@
1
+ <div id="types_list">
2
+ <%= widget(:source_list, :id => 'type_list', :source_options => { :type => @type, :per_page => 3 }) %>
3
+ </div>