wontomedia 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +661 -0
- data/COPYING.DOCUMENTATION +450 -0
- data/LICENSE +661 -0
- data/README.markdown +56 -0
- data/Rakefile +185 -0
- data/VERSION.yml +4 -0
- data/app/controllers/admin_controller.rb +144 -0
- data/app/controllers/application_controller.rb +29 -0
- data/app/controllers/connections_controller.rb +150 -0
- data/app/controllers/items_controller.rb +365 -0
- data/app/helpers/connections_helper.rb +67 -0
- data/app/helpers/format_helper.rb +154 -0
- data/app/helpers/items_helper.rb +105 -0
- data/app/models/category_item.rb +23 -0
- data/app/models/connection.rb +210 -0
- data/app/models/individual_item.rb +23 -0
- data/app/models/item.rb +86 -0
- data/app/models/property_item.rb +23 -0
- data/app/models/qualified_item.rb +23 -0
- data/app/views/admin/index.html.erb +74 -0
- data/app/views/connections/_index_outbound_links.html.erb +48 -0
- data/app/views/connections/_spo_select_controls.html.erb +151 -0
- data/app/views/connections/edit.html.erb +70 -0
- data/app/views/connections/index.html.erb +84 -0
- data/app/views/connections/new.html.erb +61 -0
- data/app/views/connections/show.html.erb +110 -0
- data/app/views/items/_active_content.html.erb +26 -0
- data/app/views/items/_content_examples.html.erb +55 -0
- data/app/views/items/_core_tasks.html.erb +23 -0
- data/app/views/items/_form_fields.html.erb +69 -0
- data/app/views/items/_list_outbound_links.html.erb +58 -0
- data/app/views/items/_screen_select.html.erb +24 -0
- data/app/views/items/_show_outbound_links.html.erb +70 -0
- data/app/views/items/_topic_list.html.erb +26 -0
- data/app/views/items/_type_select.html.erb +47 -0
- data/app/views/items/edit.html.erb +63 -0
- data/app/views/items/index.html.erb +74 -0
- data/app/views/items/new.html.erb +124 -0
- data/app/views/items/newpop.html.erb +58 -0
- data/app/views/items/show.html.erb +209 -0
- data/app/views/layouts/_amazon_ads.html.erb +55 -0
- data/app/views/layouts/_glossary_help_box.html.erb +43 -0
- data/app/views/layouts/_google_ads.html.erb +40 -0
- data/app/views/layouts/_language_select.html.erb +24 -0
- data/app/views/layouts/_login_controls.html.erb +24 -0
- data/app/views/layouts/_master_help.html.erb +24 -0
- data/app/views/layouts/_navigation_menu.html.erb +39 -0
- data/app/views/layouts/_search_box.html.erb +27 -0
- data/app/views/layouts/_status_msgs.html.erb +25 -0
- data/app/views/layouts/application.html.erb +67 -0
- data/app/views/layouts/base.html.erb +93 -0
- data/app/views/layouts/home.html.erb +67 -0
- data/app/views/layouts/popup.html.erb +23 -0
- data/assets/wontomedia-sample.rb +47 -0
- data/config/asset_packages.yml +44 -0
- data/config/boot.rb +110 -0
- data/config/cucumber.yml +65 -0
- data/config/database-mysql-development.yml +47 -0
- data/config/database-mysql.yml +26 -0
- data/config/environment.rb +94 -0
- data/config/environments/cucumber.rb +29 -0
- data/config/environments/development.rb +26 -0
- data/config/environments/production.rb +33 -0
- data/config/environments/test.rb +31 -0
- data/config/initializers/inflections.rb +19 -0
- data/config/initializers/mime_types.rb +14 -0
- data/config/initializers/new_rails_defaults.rb +26 -0
- data/config/locales/en.yml +14 -0
- data/config/routes.rb +37 -0
- data/db/fixtures/connections.yml +96 -0
- data/db/fixtures/items.yml +277 -0
- data/db/migrate/20090312212805_create_items.rb +31 -0
- data/db/migrate/20090406221320_create_connections.rb +32 -0
- data/db/migrate/20090411014503_add_type_for_item_subclasses.rb +29 -0
- data/db/migrate/20090415142152_rename_item_type.rb +31 -0
- data/db/migrate/20090518022918_rename_object_and_self.rb +33 -0
- data/db/migrate/20090529171442_add_flags_to_items.rb +27 -0
- data/db/migrate/20090529171508_add_flags_to_connections.rb +27 -0
- data/db/migrate/20090605213800_flags_columns_not_null.rb +29 -0
- data/db/migrate/20090605215028_flags_columns_default_zero.rb +29 -0
- data/db/schema.rb +30 -0
- data/default-custom/app/views/items/_home_extern_list.html.erb +32 -0
- data/default-custom/app/views/items/_home_introductory_text.html.erb +70 -0
- data/default-custom/app/views/items/home.html.erb +77 -0
- data/default-custom/public/images/logo.png +0 -0
- data/default-custom/public/images/logo.svg +74 -0
- data/default-custom/public/stylesheets/wm.css +301 -0
- data/doc/README.markdown +44 -0
- data/doc/README_FOR_APP +82 -0
- data/doc/customization.markdown +93 -0
- data/doc/scripts/rake-customize.markdown +83 -0
- data/lib/helpers/connection_helper.rb +41 -0
- data/lib/helpers/item_helper.rb +141 -0
- data/lib/helpers/tripple_navigation.rb +158 -0
- data/lib/tasks/cucumber.rake +83 -0
- data/lib/tasks/customize.rake +70 -0
- data/lib/tasks/db.rake +65 -0
- data/lib/tasks/javascript_testing_tasks.rake +176 -0
- data/public/404.html +50 -0
- data/public/422.html +50 -0
- data/public/500.html +53 -0
- data/public/dispatch.cgi +20 -0
- data/public/dispatch.fcgi +34 -0
- data/public/dispatch.rb +20 -0
- data/public/favicon.ico +0 -0
- data/public/images/blank_error_icon.png +0 -0
- data/public/images/blank_status_icon.png +0 -0
- data/public/images/error_error_icon.png +0 -0
- data/public/images/error_status_icon.png +0 -0
- data/public/images/good_status_icon.png +0 -0
- data/public/images/help_icon.png +0 -0
- data/public/images/twitter_icon.png +0 -0
- data/public/images/warn_error_icon.png +0 -0
- data/public/images/working_status_icon.gif +0 -0
- data/public/javascripts/application.js +56 -0
- data/public/javascripts/controls.js +963 -0
- data/public/javascripts/dragdrop.js +973 -0
- data/public/javascripts/effects.js +1128 -0
- data/public/javascripts/event.simulate.js +64 -0
- data/public/javascripts/fancybox.js +43 -0
- data/public/javascripts/forConnectionsForms.js +218 -0
- data/public/javascripts/forItemsForms.js +511 -0
- data/public/javascripts/itemCreatePopup.js +115 -0
- data/public/javascripts/itemTitleToName.js +119 -0
- data/public/javascripts/jquery.js +4376 -0
- data/public/javascripts/modalbox.js +502 -0
- data/public/javascripts/prototype.js +4320 -0
- data/public/javascripts/reconcileJQueryAndPrototype.js +19 -0
- data/public/robots.txt +7 -0
- data/public/stylesheets/blank.gif +0 -0
- data/public/stylesheets/fancy_close.png +0 -0
- data/public/stylesheets/fancy_loading.png +0 -0
- data/public/stylesheets/fancy_nav_left.png +0 -0
- data/public/stylesheets/fancy_nav_right.png +0 -0
- data/public/stylesheets/fancy_shadow_e.png +0 -0
- data/public/stylesheets/fancy_shadow_n.png +0 -0
- data/public/stylesheets/fancy_shadow_ne.png +0 -0
- data/public/stylesheets/fancy_shadow_nw.png +0 -0
- data/public/stylesheets/fancy_shadow_s.png +0 -0
- data/public/stylesheets/fancy_shadow_se.png +0 -0
- data/public/stylesheets/fancy_shadow_sw.png +0 -0
- data/public/stylesheets/fancy_shadow_w.png +0 -0
- data/public/stylesheets/fancy_title_left.png +0 -0
- data/public/stylesheets/fancy_title_main.png +0 -0
- data/public/stylesheets/fancy_title_over.png +0 -0
- data/public/stylesheets/fancy_title_right.png +0 -0
- data/public/stylesheets/fancybox.css +333 -0
- data/public/stylesheets/modalbox.css +110 -0
- data/public/stylesheets/scaffold.css +36 -0
- data/public/stylesheets/spinner.gif +0 -0
- data/script/about +4 -0
- data/script/console +3 -0
- data/script/cucumber +10 -0
- data/script/dbconsole +3 -0
- data/script/destroy +3 -0
- data/script/generate +3 -0
- data/script/performance/benchmarker +3 -0
- data/script/performance/profiler +3 -0
- data/script/performance/request +3 -0
- data/script/plugin +3 -0
- data/script/process/inspector +3 -0
- data/script/process/reaper +3 -0
- data/script/process/spawner +3 -0
- data/script/runner +3 -0
- data/script/server +3 -0
- data/vendor/plugins/asset_packager/CHANGELOG +122 -0
- data/vendor/plugins/asset_packager/README +178 -0
- data/vendor/plugins/asset_packager/Rakefile +22 -0
- data/vendor/plugins/asset_packager/about.yml +8 -0
- data/vendor/plugins/asset_packager/init.rb +2 -0
- data/vendor/plugins/asset_packager/install.rb +1 -0
- data/vendor/plugins/asset_packager/lib/jsmin.rb +205 -0
- data/vendor/plugins/asset_packager/lib/synthesis/asset_package.rb +212 -0
- data/vendor/plugins/asset_packager/lib/synthesis/asset_package_helper.rb +39 -0
- data/vendor/plugins/asset_packager/tasks/asset_packager_tasks.rake +23 -0
- data/vendor/plugins/asset_packager/test/asset_package_helper_development_test.rb +100 -0
- data/vendor/plugins/asset_packager/test/asset_package_helper_production_test.rb +140 -0
- data/vendor/plugins/asset_packager/test/asset_packager_test.rb +92 -0
- data/vendor/plugins/asset_packager/test/asset_packages.yml +20 -0
- data/vendor/plugins/asset_packager/test/assets/javascripts/application.js +2 -0
- data/vendor/plugins/asset_packager/test/assets/javascripts/bar.js +4 -0
- data/vendor/plugins/asset_packager/test/assets/javascripts/controls.js +815 -0
- data/vendor/plugins/asset_packager/test/assets/javascripts/dragdrop.js +913 -0
- data/vendor/plugins/asset_packager/test/assets/javascripts/effects.js +958 -0
- data/vendor/plugins/asset_packager/test/assets/javascripts/foo.js +4 -0
- data/vendor/plugins/asset_packager/test/assets/javascripts/prototype.js +2006 -0
- data/vendor/plugins/asset_packager/test/assets/stylesheets/bar.css +16 -0
- data/vendor/plugins/asset_packager/test/assets/stylesheets/foo.css +16 -0
- data/vendor/plugins/asset_packager/test/assets/stylesheets/header.css +16 -0
- data/vendor/plugins/asset_packager/test/assets/stylesheets/screen.css +16 -0
- data/vendor/plugins/asset_packager/test/assets/stylesheets/subdir/bar.css +16 -0
- data/vendor/plugins/asset_packager/test/assets/stylesheets/subdir/foo.css +16 -0
- metadata +265 -0
data/README.markdown
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
WontoMedia "README" file
|
2
|
+
Copyright (C) 2010 - Glen E. Ivey
|
3
|
+
(see the end of this file for copyright/licensing information)
|
4
|
+
|
5
|
+
|
6
|
+
## This is WontoMedia ##
|
7
|
+
|
8
|
+
WontoMedia is a Ruby-on-Rails web app for community creation of an
|
9
|
+
information classification scheme. WontoMedia is free software
|
10
|
+
(licensed under the AGPL v3), and is being developed by a dispersed
|
11
|
+
volunteer team using agile methods.
|
12
|
+
|
13
|
+
This README will be expanded as the project matures. Until that time,
|
14
|
+
you can find additional, general information in the following places:
|
15
|
+
|
16
|
+
http://wontomedia.rubyforge.org/
|
17
|
+
http://rubyforge.org/projects/wontomedia/
|
18
|
+
http://wiki.wontology.org/Main_Page
|
19
|
+
|
20
|
+
In particular, simple installation instuctions are on the last page
|
21
|
+
above, with more details at:
|
22
|
+
|
23
|
+
http://wiki.wontology.org/InstallFromScratch
|
24
|
+
http://wiki.wontology.org/SettingUpYourDevelopmentEnvironment
|
25
|
+
|
26
|
+
Once you've got WontoMedia, you can find some design and workflow
|
27
|
+
documentation in the WontoMedia source directory under the `doc`
|
28
|
+
directory. If you run the `rake doc:app` command, RDoc documentation
|
29
|
+
will be extracted and can be viewed in a browser starting from
|
30
|
+
`doc/app/index.html`.
|
31
|
+
|
32
|
+
And if you have any questions or feedback about the projet, there are
|
33
|
+
our:
|
34
|
+
|
35
|
+
forum http://rubyforge.org/forum/?group_id=7903
|
36
|
+
email list wontomedia-development at rubyforge dot org
|
37
|
+
http://rubyforge.org/mail/?group_id=7903
|
38
|
+
bug tracker http://rubyforge.org/tracker/?group_id=7903
|
39
|
+
|
40
|
+
|
41
|
+
Finally, you can also find us at:
|
42
|
+
|
43
|
+
http://github.com/gleneivey/wontomedia/tree/master
|
44
|
+
http://www.pivotaltracker.com/projects/9280/stories
|
45
|
+
http://twitter.com/wontomedia
|
46
|
+
|
47
|
+
----------------------------------------------------------------
|
48
|
+
|
49
|
+
Permission is granted to copy, distribute and/or modify this
|
50
|
+
document under the terms of the GNU Free Documentation License,
|
51
|
+
Version 1.3, published by the Free Software Foundation; with no
|
52
|
+
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
53
|
+
|
54
|
+
You should have received a copy of the GNU Free Documentation
|
55
|
+
License along with document in the file COPYING.DOCUMENTATION. If
|
56
|
+
not, see <http://www.gnu.org/licenses/>.
|
data/Rakefile
ADDED
@@ -0,0 +1,185 @@
|
|
1
|
+
# WontoMedia - a wontology web application
|
2
|
+
# Copyright (C) 2010 - Glen E. Ivey
|
3
|
+
# www.wontology.com
|
4
|
+
#
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU Affero General Public License version
|
7
|
+
# 3 as published by the Free Software Foundation.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU Affero General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU Affero General Public License
|
15
|
+
# along with this program in the file COPYING and/or LICENSE. If not,
|
16
|
+
# see <http://www.gnu.org/licenses/>.
|
17
|
+
|
18
|
+
|
19
|
+
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
|
20
|
+
|
21
|
+
require 'rake'
|
22
|
+
require 'rake/testtask'
|
23
|
+
require 'rake/rdoctask'
|
24
|
+
require 'tasks/rails'
|
25
|
+
|
26
|
+
if ENV["RAILS_ENV"].nil?
|
27
|
+
ENV["RAILS_ENV"] = RAILS_ENV = "test"
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
############################################################
|
33
|
+
# block to use Jeweler to generate our gemspec, gem, etc.
|
34
|
+
begin
|
35
|
+
require 'jeweler'
|
36
|
+
Jeweler::Tasks.new do |s|
|
37
|
+
s.name = "wontomedia"
|
38
|
+
s.rubyforge_project = "wontomedia"
|
39
|
+
s.summary = "WontoMedia is a Ruby-on-Rails web app for community creation of an information classification scheme"
|
40
|
+
s.description = <<-ENDOSTRING
|
41
|
+
WontoMedia is a Ruby-on-Rails web app for community creation of
|
42
|
+
an information classification scheme. WontoMedia is free
|
43
|
+
software (licensed under the AGPL v3), and is being developed by
|
44
|
+
a dispersed volunteer team using agile methods.
|
45
|
+
ENDOSTRING
|
46
|
+
|
47
|
+
s.email = "gleneivey@wontology.org"
|
48
|
+
s.homepage = "http://wontomedia.rubyforge.org"
|
49
|
+
s.authors = ["Glen E. Ivey"]
|
50
|
+
|
51
|
+
s.has_rdoc = true
|
52
|
+
s.extra_rdoc_files = ["README"]
|
53
|
+
|
54
|
+
s.files = FileList["[A-Z]*", "assets/wontomedia-sample.rb",
|
55
|
+
"vendor/plugins/asset_packager/**/*", "doc/*", "doc/scripts/*",
|
56
|
+
"{app,config,bin,db,default-custom,generators,lib,public,script}/**/*"].
|
57
|
+
exclude("database.yml", "wontomedia.rb",
|
58
|
+
"**/*_packaged.js", "**/*_packaged.css"
|
59
|
+
) do |maybe_exclude|
|
60
|
+
File.symlink?( maybe_exclude )
|
61
|
+
end
|
62
|
+
s.test_files = []
|
63
|
+
# Note: 1) Explicitly add any other non-testing packages under 'vendor'
|
64
|
+
# 2) Exclude all of our symbolic links
|
65
|
+
# 3)
|
66
|
+
# .autotest cucumber.yml .gitignore
|
67
|
+
# the testing directories
|
68
|
+
# deploy doc features policy test
|
69
|
+
# and the working/transitory directories
|
70
|
+
# log pkg tmp
|
71
|
+
# aren't included because developers are expected to pull from Git
|
72
|
+
|
73
|
+
s.add_dependency 'rails', '~>2.2'
|
74
|
+
end
|
75
|
+
|
76
|
+
task :build => :gemspec # don't build a gem from a stale spec
|
77
|
+
Jeweler::RubyforgeTasks.new do |rubyforge|
|
78
|
+
rubyforge.doc_task = "doc:app"
|
79
|
+
end
|
80
|
+
Jeweler::GemcutterTasks.new
|
81
|
+
rescue LoadError
|
82
|
+
puts "WARNING: Missing development dependency. 'Jeweler' and/or 'rubyforge' not available. Install them with:\n 'sudo gem install rubyforge'\n 'sudo gem install technicalpickles-jeweler -s http://gems.github.com'"
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
# documented rake_task.clear method missing?
|
87
|
+
class Rake::Task
|
88
|
+
def clear!
|
89
|
+
@actions.clear
|
90
|
+
@prerequisites.clear
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
############################################################
|
96
|
+
# update default rake tasks for our test directory structure
|
97
|
+
|
98
|
+
namespace :test do
|
99
|
+
# make test:units mean what it normally means
|
100
|
+
Rake::Task[:units].clear!
|
101
|
+
Rake::TestTask.new(:units => "db:test:prepare") do |t|
|
102
|
+
t.libs << "test"
|
103
|
+
t.pattern = 'test/unit/app/models/**/*_test.rb'
|
104
|
+
t.verbose = true
|
105
|
+
end
|
106
|
+
Rake::Task['test:units'].comment =
|
107
|
+
"Run the model tests in test/unit/app/models"
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
############################################################
|
112
|
+
# new rake tasks for our unit-like tests
|
113
|
+
|
114
|
+
namespace :test do
|
115
|
+
Rake::TestTask.new(:views => "db:test:prepare") do |t|
|
116
|
+
t.libs << "test"
|
117
|
+
t.pattern = 'test/unit/app/views/**/*_test.rb'
|
118
|
+
t.verbose = true
|
119
|
+
end
|
120
|
+
Rake::Task['test:views'].comment =
|
121
|
+
"Run the view unit tests (test/unit/app/views/**/*_test.rb)"
|
122
|
+
|
123
|
+
Rake::TestTask.new(:helpers => "db:test:prepare") do |t|
|
124
|
+
t.libs << "test"
|
125
|
+
t.pattern = 'test/unit/app/helpers/**/*_test.rb'
|
126
|
+
t.verbose = true
|
127
|
+
end
|
128
|
+
Rake::Task['test:helpers'].comment =
|
129
|
+
"Run the view-helper unit tests (test/unit/app/helpers/**/*_test.rb)"
|
130
|
+
|
131
|
+
Rake::TestTask.new(:dbunits => "db:test:prepare") do |t|
|
132
|
+
t.libs << "test"
|
133
|
+
t.pattern = 'test/unit/db/**/*_test.rb'
|
134
|
+
t.verbose = true
|
135
|
+
end
|
136
|
+
Rake::Task['test:dbunits'].comment =
|
137
|
+
"Run the database unit tests (test/unit/db/**/*_test.rb)"
|
138
|
+
|
139
|
+
# Note: migration tests using migration_test_helper disrupts
|
140
|
+
# loaded fixtures, so can't run in same Ruby process as other unit
|
141
|
+
# tests, which breaking into separate rake task accomplishes
|
142
|
+
Rake::TestTask.new(:dbmigrations => "db:test:prepare") do |t|
|
143
|
+
t.libs << "test"
|
144
|
+
t.pattern = 'test/db_migrations_test.rb'
|
145
|
+
t.verbose = true
|
146
|
+
end
|
147
|
+
Rake::Task['test:dbmigrations'].comment =
|
148
|
+
"Run the database migration unit test (test/db_migrations_test.rb)"
|
149
|
+
|
150
|
+
task :db => [ "test:dbunits", "test:dbmigrations" ]
|
151
|
+
Rake::Task['test:db'].comment =
|
152
|
+
"Run database tests (test:dbunits, test:dbmigrations)"
|
153
|
+
|
154
|
+
|
155
|
+
############################################################
|
156
|
+
# now some new "umbrella" test tasks
|
157
|
+
|
158
|
+
desc "Execute all development tests in test/unit."
|
159
|
+
Rake::TestTask.new(:dev => "db:test:prepare") do |t|
|
160
|
+
t.libs << "test"
|
161
|
+
t.pattern = 'test/unit/**/*_test.rb'
|
162
|
+
t.verbose = true
|
163
|
+
end
|
164
|
+
|
165
|
+
desc "Execute all project-policy audit tests."
|
166
|
+
task :policies do
|
167
|
+
ruby File.join( "policy", "ckFilesUtils", "buildLinksIgnoreFile.rb" )
|
168
|
+
ruby File.join( "policy", "ckFilesUtils", "ckForTabs.rb" )
|
169
|
+
ruby File.join( "policy", "ckFilesUtils", "ckCopyrightNotices.rb" )
|
170
|
+
ruby File.join( "policy", "ckFilesUtils", "ckCustomizationFilesPresent.rb" )
|
171
|
+
end
|
172
|
+
|
173
|
+
desc "Execute all the tests for Ruby code."
|
174
|
+
task :ruby => [ "test:dev", "test:dbmigrations", "test:functionals",
|
175
|
+
"test:integration", "build", "cucumber:static_ok"]
|
176
|
+
end # namespace :test
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
# redefine Rail's basic test task so that we get a reasonable execution order
|
181
|
+
Rake::Task[:test].clear!
|
182
|
+
desc 'Run all unit, functional, integration, and policy checks'
|
183
|
+
task :test => [ "test:policies", "asset:packager:build_all", "test:dev",
|
184
|
+
"test:dbmigrations", "test:functionals", "test:javascripts",
|
185
|
+
"test:integration", "build", "cucumber:ok" ]
|
data/VERSION.yml
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
#--
|
2
|
+
# WontoMedia - a wontology web application
|
3
|
+
# Copyright (C) 2010 - Glen E. Ivey
|
4
|
+
# www.wontology.com
|
5
|
+
#
|
6
|
+
# This program is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU Affero General Public License version
|
8
|
+
# 3 as published by the Free Software Foundation.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Affero General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Affero General Public License
|
16
|
+
# along with this program in the file COPYING and/or LICENSE. If not,
|
17
|
+
# see <http://www.gnu.org/licenses/>.
|
18
|
+
#++
|
19
|
+
|
20
|
+
|
21
|
+
require 'yaml'
|
22
|
+
|
23
|
+
# There is no model matching this controller. It is intended to
|
24
|
+
# provide access to and processing of pages used to administer a
|
25
|
+
# WontoMedia installation.
|
26
|
+
class AdminController < ApplicationController
|
27
|
+
|
28
|
+
# GET /admin/
|
29
|
+
#
|
30
|
+
# This action renders the primary administration page. This page
|
31
|
+
# includes links to <tt>/items.yaml</tt> and
|
32
|
+
# <tt>/connections.n3</tt> so that an administrator can download the
|
33
|
+
# complete content of a wontology for backup. It also includes form
|
34
|
+
# controls for uploading <tt>.yaml</tt> files of Item records and
|
35
|
+
# <tt>.n3</tt> files of Connection records to be added to the
|
36
|
+
# installation's database.
|
37
|
+
def index
|
38
|
+
@this_is_non_information_page = true
|
39
|
+
end
|
40
|
+
|
41
|
+
# POST /admin/item_up
|
42
|
+
#
|
43
|
+
# This is a form processing action supporting a file-upload control
|
44
|
+
# for <tt>.yaml</tt> files of Items.
|
45
|
+
def item_up
|
46
|
+
@this_is_non_information_page = true
|
47
|
+
count = 0
|
48
|
+
flash[:error] ||= ""
|
49
|
+
YAML::load(params[:item_upload][:itemfile]).each do |item|
|
50
|
+
|
51
|
+
if item.is_a? Item
|
52
|
+
# need to create a new item object so that it saves to db as "new"
|
53
|
+
item_hash = ItemHelper.item_to_hash(item)
|
54
|
+
name = item.name
|
55
|
+
elsif item.is_a? YAML::Object
|
56
|
+
# this is magic dependent on the internals of the YAML::Object class
|
57
|
+
item_hash = item.instance_eval { @ivars }['attributes']
|
58
|
+
name = item_hash['name'] || item_hash[:name]
|
59
|
+
else
|
60
|
+
flash[:error] <<
|
61
|
+
"YAML parser generated an object of type '#{item.class}'.\n"
|
62
|
+
redirect_to :action => 'index'
|
63
|
+
return
|
64
|
+
end
|
65
|
+
|
66
|
+
n = ItemHelper.new_typed_item(
|
67
|
+
item_hash['sti_type'] || item_hash[:sti_type] )
|
68
|
+
if n.nil?
|
69
|
+
err_str = "No/bad sti_type for item '#{name}', " +
|
70
|
+
"tried to create '#{item_hash.inspect}'.\n"
|
71
|
+
logger.error(err_str)
|
72
|
+
flash[:error] << err_str
|
73
|
+
else
|
74
|
+
# even if ID present, don't copy; let db assign a new value
|
75
|
+
n.name = name
|
76
|
+
n.title = item_hash['title'] || item_hash[:title]
|
77
|
+
n.description = item_hash['description'] || item_hash[:description]
|
78
|
+
n.flags = item_hash['flags'] || item_hash[:flags]
|
79
|
+
if n.flags.nil?
|
80
|
+
n.flags = 0
|
81
|
+
end
|
82
|
+
|
83
|
+
if n.save
|
84
|
+
count += 1
|
85
|
+
else
|
86
|
+
err_str = "Could not save item named 'n.name': #{n.errors.inspect}\n"
|
87
|
+
logger.error(err_str)
|
88
|
+
flash[:error] << err_str
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
flash[:notice] = "Created #{count} new items."
|
94
|
+
redirect_to :action => 'index'
|
95
|
+
end
|
96
|
+
|
97
|
+
# POST /admin/connection_up
|
98
|
+
#
|
99
|
+
# This is a form processing action supporting a file-upload control
|
100
|
+
# for <tt>.n3</tt> files of Connections. <b>Note</b> that
|
101
|
+
# WontoMedia currently uses a <em>trivial, fragile</em> N3 processor
|
102
|
+
# that is unlikely to process N3 files other than those that
|
103
|
+
# WontoMedia produces.
|
104
|
+
def connection_up
|
105
|
+
@this_is_non_information_page = true
|
106
|
+
count = unparsed = 0
|
107
|
+
flash[:error] =""
|
108
|
+
|
109
|
+
params[:connection_upload][:connectionfile].readlines.each do |n3line|
|
110
|
+
# this is a really, *really* bad N3 parser. Almost certainly won't
|
111
|
+
# handly any but the most trivial input (like what we export :-)
|
112
|
+
if n3line =~ /<#([^>]+)>[^<]+<#([^>]+)>[^<]+<#([^>]+)>[^.]+\./
|
113
|
+
e = Connection.new(
|
114
|
+
:subject => Item.find_by_name($1),
|
115
|
+
:predicate => Item.find_by_name($2),
|
116
|
+
:obj => Item.find_by_name($3),
|
117
|
+
:flags => 0
|
118
|
+
)
|
119
|
+
if e.nil?
|
120
|
+
err_stry = "Couldn't create connection for #{$1} #{$2} #{$3}.\n"
|
121
|
+
logger.error(err_str)
|
122
|
+
flash[:error] << err_str
|
123
|
+
else
|
124
|
+
if e.save
|
125
|
+
count += 1
|
126
|
+
else
|
127
|
+
err_stry = "Couldn't save connection for #{$1} #{$2} #{$3}.\n"
|
128
|
+
logger.error(err_str)
|
129
|
+
flash[:error] << err_str
|
130
|
+
end
|
131
|
+
end
|
132
|
+
else
|
133
|
+
unparsed += 1
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
flash[:notice] = "Created #{count} new connections."
|
138
|
+
if unparsed > 0
|
139
|
+
flash[:notice] <<
|
140
|
+
"(Discarded #{unparsed} non-connection lines from input file)"
|
141
|
+
end
|
142
|
+
redirect_to :action => 'index'
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#--
|
2
|
+
# WontoMedia - a wontology web application
|
3
|
+
# Copyright (C) 2010 - Glen E. Ivey
|
4
|
+
# www.wontology.com
|
5
|
+
#
|
6
|
+
# This program is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU Affero General Public License version
|
8
|
+
# 3 as published by the Free Software Foundation.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Affero General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Affero General Public License
|
16
|
+
# along with this program in the file COPYING and/or LICENSE. If not,
|
17
|
+
# see <http://www.gnu.org/licenses/>.
|
18
|
+
#++
|
19
|
+
|
20
|
+
|
21
|
+
# This is the Rails-standard ApplicationController class, which
|
22
|
+
# inherits from <tt>ActionController::Base</tt> and is the base class
|
23
|
+
# for all of WontoMedia's controller classes. See the source for
|
24
|
+
# WontoMedia's global controller configuration.
|
25
|
+
class ApplicationController < ActionController::Base
|
26
|
+
helper :all # include all helpers, all the time
|
27
|
+
protect_from_forgery
|
28
|
+
filter_parameter_logging :password
|
29
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
#--
|
2
|
+
# WontoMedia - a wontology web application
|
3
|
+
# Copyright (C) 2010 - Glen E. Ivey
|
4
|
+
# www.wontology.com
|
5
|
+
#
|
6
|
+
# This program is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU Affero General Public License version
|
8
|
+
# 3 as published by the Free Software Foundation.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Affero General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Affero General Public License
|
16
|
+
# along with this program in the file COPYING and/or LICENSE. If not,
|
17
|
+
# see <http://www.gnu.org/licenses/>.
|
18
|
+
#++
|
19
|
+
|
20
|
+
|
21
|
+
require Rails.root.join( 'lib', 'helpers', 'connection_helper')
|
22
|
+
|
23
|
+
# See also the matching model Connection
|
24
|
+
class ConnectionsController < ApplicationController
|
25
|
+
Mime::Type.register "application/x-n3", :n3
|
26
|
+
|
27
|
+
|
28
|
+
# GET /connections
|
29
|
+
#
|
30
|
+
# Note that +index+ is capable of rendering in multiple
|
31
|
+
# formats. <tt>/connections</tt> and <tt>/connections.html</tt>
|
32
|
+
# yield a human-readable page in HTML markup.
|
33
|
+
# <tt>/connections.n3</tt> renders all Connections in the database
|
34
|
+
# as N3-format text, with no additional prose or links intended for
|
35
|
+
# users. For more information on N3 (Notation3) see
|
36
|
+
# http://en.wikipedia.org/wiki/Notation3. Note that, in order to
|
37
|
+
# support this, this controller registers the MIME type
|
38
|
+
# <tt>application/x-n3</tt> with Rails, and associates it with the
|
39
|
+
# <tt>.n3</tt> file extension.
|
40
|
+
def index
|
41
|
+
@connections = Connection.all.reverse
|
42
|
+
respond_to do |wants|
|
43
|
+
wants.html
|
44
|
+
wants.n3 do
|
45
|
+
con = @connections.reject { |connection|
|
46
|
+
(connection.flags & Connection::DATA_IS_UNALTERABLE) != 0 }
|
47
|
+
render :text => ConnectionHelper.connection_array_to_n3(con)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# GET /connections/new
|
53
|
+
def new
|
54
|
+
@this_is_non_information_page = true
|
55
|
+
@connection = Connection.new
|
56
|
+
populate_for_new_update
|
57
|
+
end
|
58
|
+
|
59
|
+
# POST /connections
|
60
|
+
def create
|
61
|
+
@connection = Connection.new(params[:connection])
|
62
|
+
@connection.flags = 0
|
63
|
+
|
64
|
+
if @connection.save
|
65
|
+
flash[:notice] = 'Connection was successfully created.'
|
66
|
+
redirect_to(@connection)
|
67
|
+
else
|
68
|
+
populate_for_new_update
|
69
|
+
@this_is_non_information_page = true
|
70
|
+
render :action => "new"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# GET /connections/1
|
75
|
+
def show
|
76
|
+
# set @connection for view to use for link building
|
77
|
+
begin
|
78
|
+
@connection = Connection.find(params[:id])
|
79
|
+
rescue
|
80
|
+
render :file => "#{RAILS_ROOT}/public/404.html", :status => 404
|
81
|
+
return
|
82
|
+
end
|
83
|
+
|
84
|
+
# populate these here because I didn't want view causing db queries
|
85
|
+
@subject = @connection.subject
|
86
|
+
@predicate = @connection.predicate
|
87
|
+
@obj = @connection.obj
|
88
|
+
@connection_desc = @connection.connection_desc
|
89
|
+
end
|
90
|
+
|
91
|
+
# GET /connections/1/edit
|
92
|
+
def edit
|
93
|
+
begin
|
94
|
+
@this_is_non_information_page = true
|
95
|
+
@connection = Connection.find(params[:id])
|
96
|
+
rescue
|
97
|
+
render :file => "#{RAILS_ROOT}/public/404.html", :status => 404
|
98
|
+
return
|
99
|
+
end
|
100
|
+
|
101
|
+
populate_for_new_update
|
102
|
+
end
|
103
|
+
|
104
|
+
# PUT /connections/1
|
105
|
+
def update
|
106
|
+
begin
|
107
|
+
@connection = Connection.find(params[:id])
|
108
|
+
rescue
|
109
|
+
render :file => "#{RAILS_ROOT}/public/404.html", :status => 404
|
110
|
+
return
|
111
|
+
end
|
112
|
+
|
113
|
+
if (@connection.flags & Connection::DATA_IS_UNALTERABLE) != 0
|
114
|
+
flash[:error] = 'This Connection cannot be altered.'
|
115
|
+
redirect_to connection_path(@connection)
|
116
|
+
elsif !@connection.update_attributes(params[:connection])
|
117
|
+
populate_for_new_update
|
118
|
+
@this_is_non_information_page = true
|
119
|
+
render :action => "edit"
|
120
|
+
else
|
121
|
+
flash[:notice] = 'Connection was successfully updated.'
|
122
|
+
redirect_to connection_path(@connection)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
# DELETE /connections/1
|
127
|
+
def destroy
|
128
|
+
begin
|
129
|
+
@connection = Connection.find(params[:id])
|
130
|
+
rescue
|
131
|
+
render :file => "#{RAILS_ROOT}/public/404.html", :status => 404
|
132
|
+
return
|
133
|
+
end
|
134
|
+
|
135
|
+
if (@connection.flags & Connection::DATA_IS_UNALTERABLE) != 0
|
136
|
+
flash[:error] = 'This Connection cannot be altered.'
|
137
|
+
redirect_to connection_path(@connection)
|
138
|
+
else
|
139
|
+
@connection.destroy
|
140
|
+
redirect_to connections_url
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
private
|
145
|
+
|
146
|
+
def populate_for_new_update
|
147
|
+
@items = ItemHelper.not_qualified
|
148
|
+
@verbs = PropertyItem.all
|
149
|
+
end
|
150
|
+
end
|