talia_core 0.4.22 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. data/VERSION.yml +2 -2
  2. data/config/database.yml +9 -9
  3. data/config/rdfstore.yml +4 -4
  4. data/config/talia_core.yml +5 -2
  5. data/generators/generator_helpers.rb +66 -25
  6. data/generators/talia_admin/talia_admin_generator.rb +9 -9
  7. data/generators/talia_admin/templates/app/controllers/admin/admin_site_controller.rb +5 -0
  8. data/generators/talia_admin/templates/app/controllers/admin/custom_templates_controller.rb +7 -0
  9. data/generators/talia_admin/templates/app/controllers/admin/front_controller.rb +19 -0
  10. data/generators/talia_admin/templates/app/controllers/admin/talia_collections_controller.rb +7 -0
  11. data/generators/talia_admin/templates/app/controllers/admin/talia_sources_controller.rb +17 -0
  12. data/generators/talia_admin/templates/app/controllers/admin/users_controller.rb +7 -0
  13. data/generators/talia_admin/templates/app/controllers/users_controller.rb +7 -0
  14. data/generators/talia_admin/templates/app/helpers/admin/front_helper.rb +2 -0
  15. data/generators/talia_admin/templates/app/helpers/admin/talia_sources_helper.rb +7 -0
  16. data/generators/talia_admin/templates/app/helpers/users_helper.rb +2 -0
  17. data/generators/talia_admin/templates/app/models/guest.rb +7 -0
  18. data/generators/talia_admin/templates/app/models/talia_collection.rb +56 -0
  19. data/generators/talia_admin/templates/app/models/talia_source.rb +43 -0
  20. data/generators/talia_admin/templates/app/models/user.rb +59 -0
  21. data/generators/talia_admin/templates/app/models/user_mailer.rb +14 -0
  22. data/generators/talia_admin/templates/app/viewhints/talia_source_hints.rb +3 -0
  23. data/generators/talia_admin/templates/app/views/admin/custom_templates/index.dryml +7 -0
  24. data/generators/talia_admin/templates/app/views/admin/front/index.dryml +29 -0
  25. data/generators/talia_admin/templates/app/views/admin/front/summary.dryml +103 -0
  26. data/generators/talia_admin/templates/app/views/admin/talia_collections/index.dryml +7 -0
  27. data/generators/talia_admin/templates/app/views/admin/talia_sources/index.dryml +17 -0
  28. data/generators/talia_admin/templates/app/views/admin/talia_sources/show.dryml +8 -0
  29. data/generators/talia_admin/templates/app/views/admin/users/index.dryml +7 -0
  30. data/generators/talia_admin/templates/app/views/taglibs/admin_site.dryml +91 -0
  31. data/generators/talia_admin/templates/app/views/taglibs/application.dryml +9 -0
  32. data/generators/talia_admin/templates/app/views/taglibs/auto/admin/rapid/cards.dryml +34 -0
  33. data/generators/talia_admin/templates/app/views/taglibs/auto/admin/rapid/forms.dryml +71 -0
  34. data/generators/talia_admin/templates/app/views/taglibs/auto/admin/rapid/pages.dryml +543 -0
  35. data/generators/talia_admin/templates/app/views/taglibs/auto/rapid/cards.dryml +37 -0
  36. data/generators/talia_admin/templates/app/views/taglibs/auto/rapid/forms.dryml +35 -0
  37. data/generators/talia_admin/templates/app/views/taglibs/auto/rapid/pages.dryml +175 -0
  38. data/generators/talia_admin/templates/app/views/taglibs/front_site.dryml +1 -0
  39. data/generators/talia_admin/templates/app/views/taglibs/themes/clean/clean.dryml +10 -0
  40. data/generators/talia_admin/templates/app/views/user_mailer/forgot_password.erb +10 -0
  41. data/generators/talia_admin/templates/config/hobo_initializer.rb +1 -0
  42. data/generators/talia_admin/templates/migrations/create_users.rb +22 -0
  43. data/generators/talia_admin/templates/public/hobothemes/clean/images/101-3B5F87-ACD3E6.png +0 -0
  44. data/generators/talia_admin/templates/public/hobothemes/clean/images/30-3E547A-242E42.png +0 -0
  45. data/generators/talia_admin/templates/public/hobothemes/clean/images/30-DBE1E5-FCFEF5.png +0 -0
  46. data/generators/talia_admin/templates/public/hobothemes/clean/images/300-ACD3E6-fff.png +0 -0
  47. data/generators/talia_admin/templates/public/hobothemes/clean/images/50-ACD3E6-fff.png +0 -0
  48. data/generators/talia_admin/templates/public/hobothemes/clean/images/fieldbg.gif +0 -0
  49. data/generators/talia_admin/templates/public/hobothemes/clean/images/pencil.png +0 -0
  50. data/generators/talia_admin/templates/public/hobothemes/clean/images/small_close.png +0 -0
  51. data/generators/talia_admin/templates/public/hobothemes/clean/images/spinner.gif +0 -0
  52. data/generators/talia_admin/templates/public/hobothemes/clean/stylesheets/clean.css +326 -0
  53. data/generators/talia_admin/templates/public/hobothemes/clean/stylesheets/rapid-ui.css +100 -0
  54. data/generators/talia_admin/templates/public/javascripts/IE7.js +2 -0
  55. data/generators/talia_admin/templates/public/javascripts/blank.gif +0 -0
  56. data/generators/talia_admin/templates/public/javascripts/dryml-support.js +132 -0
  57. data/generators/talia_admin/templates/public/javascripts/hobo-rapid.js +937 -0
  58. data/generators/talia_admin/templates/public/javascripts/ie7-recalc.js +166 -0
  59. data/generators/talia_admin/templates/public/javascripts/lowpro.js +43 -25
  60. data/generators/talia_admin/templates/public/stylesheets/application.css +0 -0
  61. data/generators/talia_admin/templates/public/stylesheets/hobo-rapid.css +94 -0
  62. data/generators/talia_admin/templates/public/stylesheets/reset.css +95 -0
  63. data/generators/talia_admin/templates/test/fixtures/users.yml +7 -0
  64. data/generators/talia_admin/templates/test/functional/admin/{custom_templates_controller_test.rb → front_controller_test.rb} +1 -1
  65. data/generators/talia_admin/templates/test/functional/users_controller_test.rb +8 -0
  66. data/generators/talia_admin/templates/test/unit/user_test.rb +8 -0
  67. data/generators/talia_base/talia_base_generator.rb +24 -17
  68. data/generators/talia_oai/USAGE +0 -0
  69. data/generators/talia_oai/talia_oai_generator.rb +19 -0
  70. data/generators/talia_oai/templates/oai_controller.rb +9 -0
  71. data/generators/talia_oai/templates/oai_initializer.rb +16 -0
  72. data/lib/custom_template.rb +24 -0
  73. data/lib/talia_core/active_source_parts/class_methods.rb +1 -1
  74. data/lib/talia_core/active_source_parts/finders.rb +4 -0
  75. data/lib/talia_core/collection.rb +4 -0
  76. data/lib/talia_core/oai/active_source_model.rb +113 -0
  77. data/lib/talia_core/oai/active_source_oai_adapter/class_methods.rb +17 -0
  78. data/lib/talia_core/oai/active_source_oai_adapter.rb +106 -0
  79. data/lib/talia_core/semantic_property.rb +1 -0
  80. data/lib/talia_core/semantic_relation.rb +1 -0
  81. data/test/talia_core/active_source_test.rb +13 -0
  82. metadata +71 -59
  83. data/generators/talia_admin/templates/controllers/admin/background_controller.rb +0 -52
  84. data/generators/talia_admin/templates/controllers/admin/custom_templates_controller.rb +0 -25
  85. data/generators/talia_admin/templates/controllers/admin/locales_controller.rb +0 -15
  86. data/generators/talia_admin/templates/controllers/admin/roles_controller.rb +0 -8
  87. data/generators/talia_admin/templates/controllers/admin/sources_controller.rb +0 -9
  88. data/generators/talia_admin/templates/controllers/admin/translations_controller.rb +0 -61
  89. data/generators/talia_admin/templates/controllers/admin/users_controller.rb +0 -10
  90. data/generators/talia_admin/templates/controllers/admin_controller.rb +0 -7
  91. data/generators/talia_admin/templates/helpers/admin/background_helper.rb +0 -60
  92. data/generators/talia_admin/templates/helpers/admin/custom_templates_helper.rb +0 -5
  93. data/generators/talia_admin/templates/helpers/admin/locales_helper.rb +0 -2
  94. data/generators/talia_admin/templates/helpers/admin/roles_helper.rb +0 -2
  95. data/generators/talia_admin/templates/helpers/admin/sources_helper.rb +0 -65
  96. data/generators/talia_admin/templates/helpers/admin/translations_helper.rb +0 -51
  97. data/generators/talia_admin/templates/helpers/admin/users_helper.rb +0 -11
  98. data/generators/talia_admin/templates/helpers/admin_helper.rb +0 -30
  99. data/generators/talia_admin/templates/migrations/populate_users.rb +0 -14
  100. data/generators/talia_admin/templates/models/role.rb +0 -3
  101. data/generators/talia_admin/templates/public/javascripts/backend.js +0 -24
  102. data/generators/talia_admin/templates/public/stylesheets/talia_core/backend.css +0 -463
  103. data/generators/talia_admin/templates/public/stylesheets/talia_core/images/backend/body_bg.gif +0 -0
  104. data/generators/talia_admin/templates/public/stylesheets/talia_core/images/backend/footer_bg.gif +0 -0
  105. data/generators/talia_admin/templates/public/stylesheets/talia_core/images/backend/header.jpg +0 -0
  106. data/generators/talia_admin/templates/public/stylesheets/talia_core/images/backend/header_bg.gif +0 -0
  107. data/generators/talia_admin/templates/public/stylesheets/talia_core/images/backend/menu.jpg +0 -0
  108. data/generators/talia_admin/templates/public/stylesheets/talia_core/images/backend/menu_bg.gif +0 -0
  109. data/generators/talia_admin/templates/public/stylesheets/talia_core/images/backend/opednid.gif +0 -0
  110. data/generators/talia_admin/templates/public/stylesheets/talia_core/images/backend/page_bg.jpg +0 -0
  111. data/generators/talia_admin/templates/public/stylesheets/talia_core/images/backend/triangolino.gif +0 -0
  112. data/generators/talia_admin/templates/public/stylesheets/talia_core/images/backend/triangolino_full.gif +0 -0
  113. data/generators/talia_admin/templates/test/functional/admin/locales_controller_test.rb +0 -35
  114. data/generators/talia_admin/templates/test/functional/admin/sources_controller_test.rb +0 -109
  115. data/generators/talia_admin/templates/test/functional/admin/translations_controller_test.rb +0 -93
  116. data/generators/talia_admin/templates/test/functional/admin/users_controller_test.rb +0 -67
  117. data/generators/talia_admin/templates/test/functional/admin_controller_test.rb +0 -15
  118. data/generators/talia_admin/templates/views/admin/background/_finished.html.erb +0 -9
  119. data/generators/talia_admin/templates/views/admin/background/_pending.html.erb +0 -1
  120. data/generators/talia_admin/templates/views/admin/background/_progress.html.erb +0 -15
  121. data/generators/talia_admin/templates/views/admin/background/_running.html.erb +0 -11
  122. data/generators/talia_admin/templates/views/admin/background/environment.html.erb +0 -12
  123. data/generators/talia_admin/templates/views/admin/background/show.html.erb +0 -17
  124. data/generators/talia_admin/templates/views/admin/background/stderr.html.erb +0 -6
  125. data/generators/talia_admin/templates/views/admin/background/stdin.html.erb +0 -6
  126. data/generators/talia_admin/templates/views/admin/background/stdout.html.erb +0 -6
  127. data/generators/talia_admin/templates/views/admin/custom_templates/_content_form_column.rhtml +0 -2
  128. data/generators/talia_admin/templates/views/admin/custom_templates/_template_type_form_column.rhtml +0 -2
  129. data/generators/talia_admin/templates/views/admin/index.html.erb +0 -5
  130. data/generators/talia_admin/templates/views/admin/locales/new.html.erb +0 -9
  131. data/generators/talia_admin/templates/views/admin/sources/_show.html.erb +0 -13
  132. data/generators/talia_admin/templates/views/admin/translations/_new_translation.html.erb +0 -7
  133. data/generators/talia_admin/templates/views/admin/translations/_translation.html.erb +0 -10
  134. data/generators/talia_admin/templates/views/admin/translations/edit.html.erb +0 -16
  135. data/generators/talia_admin/templates/views/layouts/admin.html.erb +0 -56
  136. data/generators/talia_base/templates/script/setup_talia_backend +0 -43
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
- :minor: 4
4
- :patch: 22
3
+ :minor: 5
4
+ :patch: 0
5
5
  :build:
data/config/database.yml CHANGED
@@ -1,19 +1,19 @@
1
1
  ---
2
2
  development:
3
3
  adapter: jdbcmysql
4
- database: talia_library_talia_development
5
- username: rails
6
- password: rails
4
+ database: testx_talia_development
5
+ username: talia
6
+ password: talia
7
7
  host: localhost
8
8
  test:
9
9
  adapter: jdbcmysql
10
- database: talia_library_talia_test
11
- username: rails
12
- password: rails
10
+ database: testx_talia_test
11
+ username: talia
12
+ password: talia
13
13
  host: localhost
14
14
  production:
15
15
  adapter: jdbcmysql
16
- database: talia_library_talia_production
17
- username: rails
18
- password: rails
16
+ database: testx_talia_production
17
+ username: talia
18
+ password: talia
19
19
  host: localhost
data/config/rdfstore.yml CHANGED
@@ -1,13 +1,13 @@
1
1
  ---
2
2
  production:
3
3
  type: sesame
4
- location: ./sesame_production.db
5
4
  backend: native
5
+ location: ./sesame_production.db
6
6
  test:
7
7
  type: sesame
8
- location: ./sesame_test.db
9
8
  backend: native
10
- development:
9
+ location: ./sesame_test.db
10
+ development:
11
11
  type: sesame
12
- location: ./sesame_development.db
13
12
  backend: native
13
+ location: ./sesame_development.db
@@ -15,5 +15,8 @@ namespaces:
15
15
  luccadom: http://trac.talia.discovery-project.eu/wiki/LuccaOntology#
16
16
  talias: http://trac.talia.discovery-project.eu/wiki/StructuralOntology#
17
17
  taliadom: http://trac.talia.discovery-project.eu/wiki/SampleDomainOntology#
18
- site_name: Talia Library
19
- iip_root_directory_location:
18
+ sesame: http://www.openrdf.org/schema/sesame#
19
+ site_name: Talia Test
20
+ iip_server_uri: http://localhost:80/fcgi-bin/iipsrv.fcgi
21
+ vips_command: /opt/local/vips
22
+ convert_command: /usr/local/bin/convert
@@ -1,36 +1,19 @@
1
1
  module GeneratorHelpers
2
-
2
+
3
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
-
4
+
22
5
  # This is more of a quick hack, but the functionality requires extra plugins
23
6
  # and by installing them from the generator everything can be done with
24
7
  # one single command
25
8
  def install_plugin(plugin_url)
26
9
  system("#{ruby_bin} #{plugin_script} install #{plugin_url}")
27
10
  end
28
-
11
+
29
12
  # Path to the plugin (installer) script
30
13
  def plugin_script
31
14
  @plugin_script ||= File.join(RAILS_ROOT, 'script', 'plugin')
32
15
  end
33
-
16
+
34
17
  # Path to the ruby binary that we're currently using
35
18
  def ruby_bin
36
19
  @ruby_bin ||= begin
@@ -41,6 +24,57 @@ module GeneratorHelpers
41
24
 
42
25
  end
43
26
 
27
+ module CreatorHelpers
28
+ def files_in(dir, top_dir = '')
29
+ Dir["#{File.join(self_dir, 'templates', dir)}/*"].each do |file|
30
+
31
+ directory "#{top_dir}#{dir}"
32
+
33
+ if(File.directory?(file))
34
+ files_in("#{dir}/#{File.basename(file)}", top_dir)
35
+ else
36
+ file "#{dir}/#{File.basename(file)}", "#{top_dir}#{dir}/#{File.basename(file)}"
37
+ end
38
+ end
39
+ end
40
+
41
+ def make_migration(template_name)
42
+ migration_template "migrations/#{template_name}", "db/migrate", :migration_file_name => template_name.gsub(/\.rb\Z/, '')
43
+ end
44
+
45
+ def route(route)
46
+ sentinel = 'ActionController::Routing::Routes.draw do |map|'
47
+ logger.route route
48
+ gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |m|
49
+ "#{m}\n #{route}\n"
50
+ end
51
+ end
52
+
53
+ def gem_dependency(gem_name)
54
+ sentinel = 'Rails::Initializer.run do |config|'
55
+ logger.gem_depend gem_name
56
+ gsub_file 'config/environment.rb', /(#{Regexp.escape(sentinel)})/mi do |m|
57
+ "#{m}\n # Autoconfigured gem dependency\n config.gem \"#{gem_name}\"\n"
58
+ end
59
+ end
60
+
61
+ def rewrite_file(relative_file, old_value, new_value)
62
+ logger.rewrite_file "#{relative_file} from #{old_value} to #{new_value}"
63
+ gsub_file relative_file, /(#{Regexp.escape(old_value)})/mi, new_value
64
+ end
65
+
66
+ end
67
+
68
+ module DestructorHelpers
69
+
70
+ def route(route)
71
+ logger.remove_route route
72
+ to_remove = "\n\n #{route}"
73
+ gsub_file 'config/routes.rb', /(#{to_remove})/mi, ''
74
+ end
75
+
76
+ end
77
+
44
78
  # This monkeypatches a problem in the generator that causes it to have
45
79
  # migration ids based on the timestamp in seconds. If more than one
46
80
  # migration is generated at a time (that is, whithin one second),
@@ -50,16 +84,18 @@ module Rails
50
84
  module Commands
51
85
  class Create
52
86
 
53
- alias :orig_migration_string :next_migration_string
87
+ include CreatorHelpers
54
88
 
89
+ alias :orig_migration_string :next_migration_string
90
+
55
91
  def migration_xtime
56
92
  @migration_xtime ||= Time.now
57
93
  end
58
-
94
+
59
95
  def migration_time
60
96
  @migration_time ||= migration_xtime.utc.strftime('%Y%m%d%H%M')
61
97
  end
62
-
98
+
63
99
  def migration_count
64
100
  @m_count ||= begin
65
101
  Dir.glob("#{RAILS_ROOT}/#{@migration_directory}/#{migration_time}*.rb").inject(migration_xtime.sec) do |max, file|
@@ -75,8 +111,13 @@ module Rails
75
111
  return orig_migration_string(padding) unless(ActiveRecord::Base.timestamped_migrations)
76
112
  migration_time + ("%.2d" % migration_count)
77
113
  end
78
-
114
+
79
115
  end
116
+
117
+ class Destroy
118
+ include DestructorHelpers
119
+ end
120
+
80
121
  end
81
122
  end
82
123
  end
@@ -8,17 +8,17 @@ class TaliaAdminGenerator < Rails::Generator::Base
8
8
 
9
9
  def manifest
10
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
-
17
- m.directory 'app/models'
18
- m.file 'models/role.rb', 'app/models/role.rb', :collision => :force
11
+ m.gem_dependency 'hobo'
12
+ m.route 'Hobo.add_routes(map)'
13
+ m.route "map.admin '/admin', :controller => 'admin/front', :action => 'index'"
14
+ m.route "map.site_search 'search', :controller => 'admin/front', :action => 'search'"
15
+ m.file 'config/hobo_initializer.rb', 'config/initializers/hobo.rb'
16
+ m.files_in 'app'
17
+ m.files_in 'public'
18
+ m.files_in 'test'
19
19
 
20
20
  m.directory 'db/migrate'
21
- make_migration m, "populate_users.rb"
21
+ m.make_migration "create_users.rb"
22
22
  end
23
23
  end
24
24
 
@@ -0,0 +1,5 @@
1
+ class Admin::AdminSiteController < ApplicationController
2
+
3
+ hobo_controller
4
+
5
+ end
@@ -0,0 +1,7 @@
1
+ class Admin::CustomTemplatesController < Admin::AdminSiteController
2
+
3
+ hobo_model_controller
4
+
5
+ auto_actions :all
6
+
7
+ end
@@ -0,0 +1,19 @@
1
+ class Admin::FrontController < ApplicationController
2
+
3
+ hobo_controller
4
+
5
+ def index; end
6
+
7
+ def summary
8
+ if !current_user.administrator?
9
+ redirect_to user_login_path
10
+ end
11
+ end
12
+
13
+ def search
14
+ if params[:query]
15
+ site_search(params[:query])
16
+ end
17
+ end
18
+
19
+ end
@@ -0,0 +1,7 @@
1
+ class Admin::TaliaCollectionsController < Admin::AdminSiteController
2
+
3
+ hobo_model_controller
4
+
5
+ auto_actions :all
6
+
7
+ end
@@ -0,0 +1,17 @@
1
+ class Admin::TaliaSourcesController < Admin::AdminSiteController
2
+
3
+ hobo_model_controller
4
+
5
+ auto_actions :all
6
+
7
+ def show
8
+ @talia_source = find_instance
9
+ @real_source = @talia_source.real_source
10
+ @property_names = @real_source.direct_predicates
11
+ @properties = {}
12
+ @property_names.each do |pred|
13
+ @properties[pred.to_s] = @real_source[pred]
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,7 @@
1
+ class Admin::UsersController < ApplicationController
2
+
3
+ hobo_user_controller
4
+
5
+ auto_actions :all
6
+
7
+ end
@@ -0,0 +1,7 @@
1
+ class UsersController < ApplicationController
2
+
3
+ hobo_user_controller
4
+
5
+ auto_actions :all, :except => [ :index, :new, :create ]
6
+
7
+ end
@@ -0,0 +1,2 @@
1
+ module Admin::FrontHelper
2
+ end
@@ -0,0 +1,7 @@
1
+ module Admin::TaliaSourcesHelper
2
+
3
+ def all_collections
4
+ TaliaCollection.find(:all, :limit => 20)
5
+ end
6
+
7
+ end
@@ -0,0 +1,2 @@
1
+ module UsersHelper
2
+ end
@@ -0,0 +1,7 @@
1
+ class Guest < Hobo::Guest
2
+
3
+ def administrator?
4
+ false
5
+ end
6
+
7
+ end
@@ -0,0 +1,56 @@
1
+ class TaliaCollection < ActiveRecord::Base
2
+ hobo_model # Don't put anything above this
3
+
4
+ self.inheritance_column = 'foo'
5
+
6
+ fields do
7
+ uri :string
8
+ end
9
+
10
+ set_table_name "active_sources"
11
+
12
+
13
+
14
+ def create_permitted?
15
+ acting_user.administrator?
16
+ end
17
+
18
+ def update_permitted?
19
+ acting_user.administrator?
20
+ end
21
+
22
+ def view_permitted?(field)
23
+ true
24
+ end
25
+
26
+ def self.new(*args)
27
+ new_thing = super(*args)
28
+ new_thing[:type] = "TaliaCore::Collection"
29
+ new_thing
30
+ end
31
+
32
+ def self.find(*args)
33
+ puts args.inspect
34
+ result = TaliaCore::Collection.find(*args)
35
+ if(result.is_a?(Array))
36
+ result.collect { |s| from_real_collection(s) }
37
+ else
38
+ from_real_collection(result)
39
+ end
40
+ end
41
+
42
+ def self.count(*args)
43
+ TaliaCore::Collection.count(*args)
44
+ end
45
+
46
+ def name
47
+ N::URI.new(self.uri).to_name_s
48
+ end
49
+
50
+ private
51
+
52
+ def self.from_real_collection(real_collection)
53
+ TaliaCollection.send(:instantiate, real_collection.attributes)
54
+ end
55
+
56
+ end
@@ -0,0 +1,43 @@
1
+ class TaliaSource < ActiveRecord::Base
2
+ hobo_model # Don't put anything above this
3
+
4
+ self.inheritance_column = 'foo'
5
+
6
+ fields do
7
+ uri :string
8
+ type :string
9
+ end
10
+
11
+ set_table_name "active_sources"
12
+
13
+ def create_permitted?
14
+ acting_user.administrator?
15
+ end
16
+
17
+ def update_permitted?
18
+ acting_user.administrator?
19
+ end
20
+
21
+ def view_permitted?(field)
22
+ true
23
+ end
24
+
25
+ def name
26
+ real_source.respond_to?(:label) ? real_source.label : to_uri.to_name_s
27
+ end
28
+
29
+ def short_type
30
+ self.type ? self.type.gsub('TaliaCore::', '') : 'ActiveSource'
31
+ end
32
+
33
+ def to_uri
34
+ N::URI.new(self.uri)
35
+ end
36
+
37
+ def real_source
38
+ @real_source ||= TaliaCore::ActiveSource.find(self.id, :prefetch_relations => true)
39
+ end
40
+
41
+
42
+
43
+ end
@@ -0,0 +1,59 @@
1
+ class User < ActiveRecord::Base
2
+
3
+ hobo_user_model # Don't put anything above this
4
+
5
+ fields do
6
+ name :string, :required, :unique
7
+ email_address :email_address, :login => true
8
+ administrator :boolean, :default => false
9
+ timestamps
10
+ end
11
+
12
+ # This gives admin rights to the first sign-up.
13
+ # Just remove it if you don't want that
14
+ before_create { |user| user.administrator = true if !Rails.env.test? && count == 0 }
15
+
16
+
17
+ # --- Signup lifecycle --- #
18
+
19
+ lifecycle do
20
+
21
+ state :active, :default => true
22
+
23
+ create :signup, :available_to => "Guest",
24
+ :params => [:name, :email_address, :password, :password_confirmation],
25
+ :become => :active
26
+
27
+ transition :request_password_reset, { :active => :active }, :new_key => true do
28
+ UserMailer.deliver_forgot_password(self, lifecycle.key)
29
+ end
30
+
31
+ transition :reset_password, { :active => :active }, :available_to => :key_holder,
32
+ :params => [ :password, :password_confirmation ]
33
+
34
+ end
35
+
36
+
37
+ # --- Permissions --- #
38
+
39
+ def create_permitted?
40
+ acting_user.administrator?
41
+ end
42
+
43
+ def update_permitted?
44
+ acting_user.administrator? ||
45
+ (acting_user == self && only_changed?(:email_address, :crypted_password,
46
+ :current_password, :password, :password_confirmation))
47
+ # Note: crypted_password has attr_protected so although it is permitted to change, it cannot be changed
48
+ # directly from a form submission.
49
+ end
50
+
51
+ def destroy_permitted?
52
+ acting_user.administrator?
53
+ end
54
+
55
+ def view_permitted?(field)
56
+ true
57
+ end
58
+
59
+ end
@@ -0,0 +1,14 @@
1
+ class UserMailer < ActionMailer::Base
2
+
3
+ def forgot_password(user, key)
4
+ host = Hobo::Controller.request_host
5
+ app_name = Hobo::Controller.app_name || host
6
+ @subject = "#{app_name} -- forgotten password"
7
+ @body = { :user => user, :key => key, :host => host, :app_name => app_name }
8
+ @recipients = user.email_address
9
+ @from = "no-reply@#{host}"
10
+ @sent_on = Time.now
11
+ @headers = {}
12
+ end
13
+
14
+ end
@@ -0,0 +1,3 @@
1
+ class TaliaSourceHints < Hobo::ViewHints
2
+ field_names :type => "Da Type"
3
+ end
@@ -0,0 +1,7 @@
1
+ <index-page>
2
+ <collection: replace>
3
+ <table-plus fields="this, template_type, content">
4
+ <empty-message:>No templates match your criteria</empty-message:>
5
+ </table-plus>
6
+ </collection:>
7
+ </index-page>
@@ -0,0 +1,29 @@
1
+ <page title="Home">
2
+
3
+ <body: class="front-page"/>
4
+
5
+ <content:>
6
+ <header class="content-header">
7
+ <h1>Welcome to <app-name/></h1>
8
+ <section class="welcome-message">
9
+ <h3>Congratulations! Your Hobo Rails App is up and running</h3>
10
+ <ul>
11
+ <li>To customise this page: edit app/views/front/index.dryml</li>
12
+ </ul>
13
+
14
+ <% if User.count == 0 -%>
15
+ <h3 style="margin-top: 20px;">There are no user accounts - please provide the details of the site administrator</h3>
16
+ <do with="&User.new"><% this.exempt_from_edit_checks = true %>
17
+ <signup-form/>
18
+ </do>
19
+ <% end -%>
20
+
21
+
22
+ </section>
23
+ </header>
24
+
25
+ <section class="content-body">
26
+ </section>
27
+ </content:>
28
+
29
+ </page>
@@ -0,0 +1,103 @@
1
+ <page>
2
+ <content:>
3
+ <div class="content-body">
4
+ <h2>Application Summary</h2>
5
+
6
+ <table class="app-summary">
7
+ <tr> <th></th><th></th></tr>
8
+ <tr> <td>Application Name</td> <td><app-name/></td> </tr>
9
+ <tr> <td>Application Location</td> <td><rails-root/></td> </tr>
10
+ <tr> <td>Rails Version</td> <td><rails-version/></td> </tr>
11
+ <tr> <td>Rails Location</td> <td><rails-location/></td> </tr>
12
+ <tr> <td>Mode</td> <td><rails-env/></td> </tr>
13
+ </table>
14
+
15
+ <h3>Change Control</h3>
16
+ <table class="app-summary">
17
+ <tr> <th></th><th></th></tr>
18
+ <tr> <td>Method</td> <td><cms-method/></td> </tr>
19
+ <if test="&cms_method.strip=='git'">
20
+ <tr> <td>Version</td> <td><cms-version/></td> </tr>
21
+ <tr> <td>Date</td> <td><cms-last-commit-time/></td> </tr>
22
+ <tr> <td>Branch</td> <td><cms-branch/></td> </tr>
23
+ <tr> <td>Clean?</td> <td><cms-clean/></td></tr>
24
+ </if>
25
+ </table>
26
+
27
+
28
+ <h3>Gems</h3>
29
+ <table class="app-summary">
30
+ <with-gems>
31
+ <tr if="&first_item?"><th></th><th>Required</th><th>Installed</th><th>Status</th><th>Dependencies</th></tr>
32
+ <tr>
33
+ <td><gem-name/></td>
34
+ <td><gem-version-required/></td>
35
+ <td><gem-version/></td>
36
+ <td><gem-frozen/></td>
37
+ <td><gem-dependencies/></td>
38
+ </tr>
39
+ </with-gems>
40
+ </table>
41
+
42
+ <h3>Plugins</h3>
43
+ <table class="app-summary">
44
+ <with-plugins>
45
+ <tr if="&first_item?"><th></th><th>Location</th><th>Method</th><th>Clean?</th><th>Version</th></tr>
46
+ <tr>
47
+ <td><plugin-name/></td>
48
+ <td><plugin-location/></td>
49
+ <td><plugin-method/></td>
50
+ <td><plugin-clean/></td>
51
+ <td><plugin-version/></td>
52
+ </tr>
53
+ </with-plugins>
54
+ </table>
55
+
56
+ <h3>Environments</h3>
57
+ <table class="app-summary">
58
+ <tr><th></th><th colspan='2'>database</th></tr>
59
+ <with-environments>
60
+ <tr>
61
+ <td><environment-name /></td>
62
+ <td><database-type /></td>
63
+ <td><database-name /></td>
64
+ </tr>
65
+ </with-environments>
66
+ </table>
67
+
68
+ <h2>Models</h2>
69
+ <table class="app-summary">
70
+ <tr><th>Class</th><th>Table</th></tr>
71
+ <with-models>
72
+ <tr>
73
+ <td><model-name/></td>
74
+ <td><model-table-name/></td>
75
+ </tr>
76
+ </with-models>
77
+ </table>
78
+
79
+ <with-models>
80
+ <h3 if="&this.try.table_name"><model-name /></h3>
81
+ <table class="app-summary">
82
+ <with-model-columns>
83
+ <tr if="&first_item?"><th>Column</th><th>Type</th></tr>
84
+ <tr>
85
+ <td><model-column-name/></td>
86
+ <td><model-column-type/></td>
87
+ </tr>
88
+ </with-model-columns>
89
+ </table>
90
+ <table class="app-summary">
91
+ <with-model-associations>
92
+ <tr if="&first_item?"><th>Association</th><th>Macro</th><th>Class</th></tr>
93
+ <tr>
94
+ <td><model-association-name/></td>
95
+ <td><model-association-macro/></td>
96
+ <td><model-association-class-name/></td>
97
+ </tr>
98
+ </with-model-associations>
99
+ </table>
100
+ </with-models>
101
+ </div>
102
+ </content:>
103
+ </page>
@@ -0,0 +1,7 @@
1
+ <index-page>
2
+ <collection: replace>
3
+ <table-plus fields="this, uri">
4
+ <empty-message:>No collections match your criteria</empty-message:>
5
+ </table-plus>
6
+ </collection:>
7
+ </index-page>