inkling 0.0.3a

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/README.txt +194 -0
  2. data/app/controllers/inkling/admin/base_controller.rb +5 -0
  3. data/app/controllers/inkling/admin/content_types_controller.rb +4 -0
  4. data/app/controllers/inkling/admin/permissions_controller.rb +4 -0
  5. data/app/controllers/inkling/admin/roles_controller.rb +4 -0
  6. data/app/controllers/inkling/admin/users_controller.rb +4 -0
  7. data/app/controllers/inkling/base_controller.rb +9 -0
  8. data/app/controllers/inkling/content_controller.rb +6 -0
  9. data/app/controllers/inkling/home_controller.rb +44 -0
  10. data/app/controllers/inkling/paths_controller.rb +31 -0
  11. data/app/controllers/inkling/proxying_controller.rb +19 -0
  12. data/app/controllers/inkling/themes_controller.rb +4 -0
  13. data/app/controllers/inkling/users/confirmations_controller.rb +3 -0
  14. data/app/controllers/inkling/users/passwords_controller.rb +1 -0
  15. data/app/controllers/inkling/users/sessions_controller.rb +5 -0
  16. data/app/models/inkling/can_can_action.rb +5 -0
  17. data/app/models/inkling/log.rb +3 -0
  18. data/app/models/inkling/path.rb +54 -0
  19. data/app/models/inkling/permission.rb +7 -0
  20. data/app/models/inkling/role.rb +10 -0
  21. data/app/models/inkling/role_membership.rb +8 -0
  22. data/app/models/inkling/theme.rb +74 -0
  23. data/app/models/inkling/type.rb +4 -0
  24. data/app/models/inkling/user.rb +16 -0
  25. data/app/views/inkling/admin/permissions/_form.html.erb +15 -0
  26. data/app/views/inkling/admin/permissions/edit.html.erb +1 -0
  27. data/app/views/inkling/admin/permissions/index.html.erb +26 -0
  28. data/app/views/inkling/admin/permissions/new.html.erb +1 -0
  29. data/app/views/inkling/admin/permissions/show.html.erb +11 -0
  30. data/app/views/inkling/admin/roles/index.html.erb +3 -0
  31. data/app/views/inkling/admin/sites/index.html.erb +1 -0
  32. data/app/views/inkling/admin/types/index.html.erb +12 -0
  33. data/app/views/inkling/admin/users/_form.html.erb +16 -0
  34. data/app/views/inkling/admin/users/edit.html.erb +1 -0
  35. data/app/views/inkling/admin/users/index.html.erb +18 -0
  36. data/app/views/inkling/admin/users/new.html.erb +1 -0
  37. data/app/views/inkling/admin/users/show.html.erb +11 -0
  38. data/app/views/inkling/home/_dashboard.html.erb +29 -0
  39. data/app/views/inkling/home/dashboard.html.erb +13 -0
  40. data/app/views/inkling/paths/_content_form.html.erb +7 -0
  41. data/app/views/inkling/paths/_path.html.erb +17 -0
  42. data/app/views/inkling/paths/index.html.erb +14 -0
  43. data/app/views/inkling/paths/update_tree.js.erb +2 -0
  44. data/app/views/inkling/themes/_form.html.erb +17 -0
  45. data/app/views/inkling/themes/edit.html.erb +1 -0
  46. data/app/views/inkling/themes/index.html.erb +11 -0
  47. data/app/views/inkling/themes/new.html.erb +1 -0
  48. data/app/views/inkling/themes/show.html.erb +1 -0
  49. data/app/views/inkling/users/confirmations/new.html.erb +12 -0
  50. data/app/views/inkling/users/mailer/confirmation_instructions.html.erb +5 -0
  51. data/app/views/inkling/users/mailer/reset_password_instructions.html.erb +8 -0
  52. data/app/views/inkling/users/mailer/unlock_instructions.html.erb +7 -0
  53. data/app/views/inkling/users/passwords/edit.html.erb +16 -0
  54. data/app/views/inkling/users/passwords/new.html.erb +12 -0
  55. data/app/views/inkling/users/registrations/edit.html.erb +25 -0
  56. data/app/views/inkling/users/registrations/new.html.erb +18 -0
  57. data/app/views/inkling/users/sessions/new.html.erb +17 -0
  58. data/app/views/inkling/users/shared/_links.erb +19 -0
  59. data/app/views/inkling/users/unlocks/new.html.erb +12 -0
  60. data/app/views/layouts/inkling/admin.html.erb +43 -0
  61. data/app/views/layouts/inkling/manage.html.erb +43 -0
  62. data/bin/inkling +3 -0
  63. data/config/initializers/init.rb +4 -0
  64. data/config/initializers/rspec_generator.rb +6 -0
  65. data/config/routes.rb +18 -0
  66. data/lib/generators/inkling_generator.rb +19 -0
  67. data/lib/generators/templates/create_inkling_tables.rb +73 -0
  68. data/lib/inkling/ability.rb +21 -0
  69. data/lib/inkling/commands/generator.rb +66 -0
  70. data/lib/inkling/commands.rb +12 -0
  71. data/lib/inkling/engine.rb +35 -0
  72. data/lib/inkling/routing.rb +26 -0
  73. data/lib/inkling/slugs.rb +17 -0
  74. data/lib/inkling/types.rb +61 -0
  75. data/lib/inkling/util/migration_helpers.rb +22 -0
  76. data/lib/inkling/version.rb +3 -0
  77. data/lib/inkling.rb +3 -0
  78. data/lib/tasks/cucumber.rake +53 -0
  79. data/lib/tasks/inkling.rake +48 -0
  80. data/lib/tasks/rspec.rake +68 -0
  81. data/spec/controllers/inkling/proxying_spec.rb +9 -0
  82. data/spec/models/path_spec.rb +13 -0
  83. data/spec/models/permission_spec.rb +29 -0
  84. data/spec/models/theme_spec.rb +66 -0
  85. data/spec/spec_helper.rb +26 -0
  86. data/spec/support/devise.rb +3 -0
  87. data/spec/support/inkling_spec_helper.rb +1 -0
  88. metadata +222 -0
data/README.txt ADDED
@@ -0,0 +1,194 @@
1
+ Inkling is a DSL and framework for Rails 3 providing for defining your own knowledge management system.
2
+
3
+ Feature Overview
4
+ ----------------
5
+
6
+ Types:
7
+
8
+ ActiveRecord objects can be adopted by the framework. Define your ActiveRecord with 'act_as_inkling' and it will be included in the system with menuing, security, routing, workflows.
9
+
10
+ Namespacing:
11
+
12
+ All tables are namespaced - e.g. inkling_users - to avoid collision with other tables - e.g. the user table of an ecommerce app..
13
+
14
+ Dashboard:
15
+
16
+ Create a partial (_.+*_dashboard.+*) in your app and it will be automatically included in the dashboard. So you can extend the interface for your own users and integrate whatever you like.
17
+
18
+ Tree:
19
+
20
+ A tree UI presents the arrangement of all types in the system, letting users drag and drop inklings, create news ones, edit them, etc..
21
+
22
+ Permissioning:
23
+
24
+ There's one default role, the administrator, that can do everything. But you can create others, and give them permissions (to, say, create but not delete images). You can also create new permissions and new roles for your own extensions. (Inkling uses CanCan)
25
+
26
+ Devise Authentication:
27
+
28
+ The authentication system can be turned on or off (you would turn it off to integrate it within your own app's authentication). It uses Devise (see http://github.com/plataformatec/devise)
29
+
30
+ Workflow API: (coming)
31
+
32
+ A simple default Workflow - draft -> publish - is included for most objects, but you can define your own and attach them to any inkling type.
33
+
34
+
35
+
36
+
37
+ For more see the Development Guide (http://wiki.github.com/biv/inkling/developers-guide) and the Roadmap (http://wiki.github.com/biv/inkling/roadmap).
38
+
39
+
40
+ The documentation below is a work in progress and will be revised at some point. The Installing advice is current.
41
+
42
+ Installing
43
+ ----------
44
+
45
+ Some quick instructions for setting up Inkling and Inkling-CMS to get an idea of what's being built.
46
+
47
+ Clone inkling.
48
+
49
+ Go into inkling, run 'bundle install' (you'll need Ruby 1.9.x).
50
+
51
+ cd testapp
52
+
53
+ Configure your config/database.yml with a database for the test app.
54
+
55
+ rake install
56
+
57
+ rake inkling:bootstrap
58
+
59
+
60
+ Implementing your own System
61
+ ----------------------------
62
+
63
+ 1) Define themes.
64
+
65
+ The administrator account will always be able to see the Inkling administrator layout, which contains configuration information. To implement a system, you must define two themes:
66
+
67
+ The management theme - this is the layout backend users will see when they use your system.
68
+ The content theme - this is the theme public visitors will see when they look at content.
69
+
70
+
71
+
72
+ Running The Tests
73
+ -----------------
74
+ Inkling is an engine and needs a Rails application to execute its tests against. Tests (rspec examples and cucumber features) are kept in the top level engine directory, and symlinked into the testapp/spec and testapp/featured directories.
75
+
76
+ To run the tests:
77
+
78
+ cd testapp
79
+
80
+ rake inkling:megatest #(a custom task which runs the environment, rspec, then features)
81
+
82
+
83
+ EXTENDING INKLING
84
+ -----------------
85
+
86
+
87
+ Content Type
88
+ ------------
89
+ �For an example of a content type, see inkling-cms or Inkling::Foo (in this project).
90
+
91
+ A generator for content types will be built at some stage, in the meantime, CTs follow some norms in Rails.
92
+
93
+ To create a Content Type:
94
+
95
+ * the model should act_as_content
96
+
97
+ class Acme::Mp3 < ActiveRecord::Base
98
+ acts_as_content 'mp3'
99
+ end
100
+
101
+ The string arg. is optional, but provides a friendly name to use in the admin UI - a content creator will have the option to create an
102
+ 'mp3'and not an 'Acme::Mp3'.
103
+
104
+ * the model should have a name field, preferably a String. This is used to make it addressable in a URL by site categorization.
105
+
106
+ Two controllers are presumed to exist, one to let permitted users manage the object (CRUD):
107
+
108
+ class Inkling::ContentTypes::Mp3sController < Inkling::BaseController
109
+ end
110
+
111
+ And another with a show method capable of rendering it:
112
+
113
+ class Inkling::Mp3sController < Inkling::BaseController; end
114
+
115
+ These namespaces are presumed to exist, although options may appear later for other namespaces.
116
+
117
+ The admin controller presumes CRUD methods (and routes) available for the model. The other controller is simply in charge
118
+ of rendering, and relies upon the 'show' method being implemented. When Inkling receives a request for an mp3 which is situated
119
+ in a folder somewhere in its site, it will call to the show method with an id.
120
+
121
+ Your content type is automatically included in the Content Tree. If you wish to restrict what types of content can be placed directly beneath it,
122
+ implement the restricts method on your content object.
123
+
124
+ For example,
125
+
126
+ class Acme::Mp3 < ActiveRecord::Base
127
+ acts_as_inkling 'mp3'
128
+
129
+ def restricts(content)
130
+ unless content.is_a? Acme::MusicVideo
131
+ [true, "MP3s can only include Music Videos."]
132
+ end
133
+ end
134
+ end
135
+
136
+
137
+ Roles
138
+ -----
139
+
140
+ Inkling only specifies one role - administrator. The hosting app. is able to create more.
141
+
142
+ Roles & Authentication & Landing Page
143
+ -------------------------------------
144
+
145
+ Inkling uses Devise, which searches for a user_root_path and then defaults a root_path, in that order. Inkling defines a inkling_user_root route (run 'rake routes') to reach the Inkling dashboard. If you want authenticating users to land here, map user_root or root to this:
146
+
147
+ match 'home', :to => 'admin/inkling/home#dashboard', :as => "user_root"
148
+
149
+
150
+
151
+ Integrated Dashboard
152
+ --------------------
153
+
154
+ Each user lands on the dashboard - app/views/inkling/users/home#dashboard. Inkling scans all engines for this directory, looking for files with _dashboard. and rendering them as partials. Thus, if you want your engine to add its own section to the dashboard, create a partial.
155
+
156
+ For example, if you have written a blog content type, and want to offer blog links create app/views/inkling/users/home/_blog_dashboard.html.erb (or haml, etc.). This will be rendered within the dashboard.
157
+
158
+ Contributors
159
+ ------------
160
+
161
+ Thanks to
162
+ * Clifford Heath (contributing installation docs + the command line binary that will be used to generate Content Type engines). May, 2010.
163
+
164
+ Copyright Notice
165
+ ----------------
166
+ COPYRIGHT (c) 2010 Nicholas Faiz, Tree Falling In The Woods Pty Ltd.
167
+
168
+
169
+ Inkling code is copyrighted to Tree Falling In The Woods, Pty Ltd. and available under the MIT License.
170
+ It includes software from other projects, other people, listed below, all available through the MIT license.
171
+
172
+ * Ruby on Rails - http://rubyonrails.org - David Heinemeier Hansson, etc..
173
+ * Enki - http://www.enkiblog.com/ - Xavier Shay.
174
+
175
+ The MIT License
176
+
177
+ Permission is hereby granted, free of charge, to any person obtaining a copy
178
+ of this software and associated documentation files (the "Software"), to deal
179
+ in the Software without restriction, including without limitation the rights
180
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
181
+ copies of the Software, and to permit persons to whom the Software is
182
+ furnished to do so, subject to the following conditions:
183
+
184
+ The above copyright notice and this permission notice shall be included in
185
+ all copies or substantial portions of the Software.
186
+
187
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
188
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
189
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
190
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
191
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
192
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
193
+ THE SOFTWARE
194
+
@@ -0,0 +1,5 @@
1
+ class Inkling::Admin::BaseController < ApplicationController
2
+
3
+ layout 'inkling/manage'
4
+
5
+ end
@@ -0,0 +1,4 @@
1
+ class Inkling::Admin::ContentTypesController < Inkling::Admin::BaseController
2
+
3
+ def index; end
4
+ end
@@ -0,0 +1,4 @@
1
+ class Inkling::Admin::PermissionsController < Inkling::Admin::BaseController
2
+ inherit_resources
3
+ defaults :resource_class => Inkling::Permission, :instance_name => 'inkling_permission'
4
+ end
@@ -0,0 +1,4 @@
1
+ class Inkling::Admin::RolesController < Inkling::Admin::BaseController
2
+ inherit_resources
3
+ defaults :resource_class => Inkling::Role, :instance_name => 'role'
4
+ end
@@ -0,0 +1,4 @@
1
+ class Inkling::Admin::UsersController < Inkling::Admin::BaseController
2
+ inherit_resources
3
+ defaults :resource_class => Inkling::User, :instance_name => 'inkling_admin_user'
4
+ end
@@ -0,0 +1,9 @@
1
+ class Inkling::BaseController < ApplicationController
2
+
3
+ alias current_user current_inkling_user
4
+ helper_method :current_user
5
+ before_filter :authenticate_inkling_user!
6
+
7
+ layout 'inkling/manage'
8
+
9
+ end
@@ -0,0 +1,6 @@
1
+ class Inkling::ContentController < ApplicationController
2
+
3
+ layout 'content' #this file is created by the Theme functionality in admin, and written out to tmp/inkling/themes/layouts
4
+ alias current_user current_inkling_user
5
+ helper_method :current_user
6
+ end
@@ -0,0 +1,44 @@
1
+ class Inkling::HomeController < Inkling::BaseController
2
+
3
+ layout 'inkling/manage'
4
+ helper_method :dashboard_partials
5
+
6
+ # protected
7
+ #these methods would be better in a helper, but it seems helpers have issues loading from engines.
8
+ def render_dashboard_partials
9
+ for file in dashboard_partials
10
+ render(:file => file)
11
+ end
12
+ end
13
+
14
+
15
+ def dashboard_partials
16
+ partials = []
17
+
18
+ for engine in Rails.application.railties.engines
19
+ dashboard_partials = scan_path_for_dashboard_partial(engine)
20
+ partials += dashboard_partials if dashboard_partials.any?
21
+ end
22
+
23
+ partials += scan_path_for_dashboard_partial(Rails.application)
24
+
25
+ partials
26
+ end
27
+
28
+ def scan_path_for_dashboard_partial(application)
29
+ partials = []
30
+ for path in application.paths.app.views
31
+ if path =~ /views/
32
+ if File.exist?("#{path}/inkling/home/")
33
+ for entry in Dir.entries("#{path}/inkling/home/")
34
+ if entry =~ /_dashboard\./
35
+ partials << "#{path}/inkling/home/#{entry}"
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ partials
43
+ end
44
+ end
@@ -0,0 +1,31 @@
1
+ class Inkling::PathsController < Inkling::BaseController
2
+ # load_and_authorize_resource
3
+
4
+ before_filter :get_root
5
+
6
+ def index
7
+ @content_types = Inkling::Content::Types.listed
8
+ @content_types ||= []
9
+ @path = Inkling::Path.new
10
+ end
11
+
12
+ def update_tree
13
+ new_parent_id = params[:new_parent]
14
+ child_id = params[:child]
15
+ new_parent = Inkling::Path.find(new_parent_id)
16
+ child = Inkling::Path.find(child_id)
17
+ restriction = new_parent.restricts?(child)
18
+ if restriction[0]
19
+ @msg = restriction[1]
20
+ else
21
+ child.move_to_child_of new_parent
22
+ child.save
23
+ @msg = "Ok."
24
+ end
25
+ end
26
+
27
+ private
28
+ def get_root
29
+ @roots = Inkling::Path.find_all_by_parent_id(nil)
30
+ end
31
+ end
@@ -0,0 +1,19 @@
1
+ class Inkling::ProxyingController < Inkling::BaseController
2
+
3
+ def new
4
+ content_type = params[:content_type]
5
+ bits = content_type.split("::")
6
+ model_name = bits.last
7
+ @proxy_path = "new_inkling_content_types_#{model_name}_path".downcase
8
+ redirect_to eval(@proxy_path)
9
+ end
10
+
11
+ def edit
12
+ debugger
13
+ content_type = params[:content_type]
14
+ bits = content_type.split("::")
15
+ model_name = bits.last
16
+ @proxy_path = "new_inkling_content_types_#{model_name}_path".downcase
17
+ redirect_to eval(@proxy_path)
18
+ end
19
+ end
@@ -0,0 +1,4 @@
1
+ class Inkling::ThemesController < Inkling::BaseController
2
+ inherit_resources
3
+ defaults :resource_class => Inkling::Theme, :instance_name => 'inkling_theme'
4
+ end
@@ -0,0 +1,3 @@
1
+ class Inkling::Users::ConfirmationsController < Devise::ConfirmationsController
2
+ layout 'inkling/content'
3
+ end
@@ -0,0 +1 @@
1
+ class Inkling::Users::PasswordsController < Devise::PasswordsController ; end
@@ -0,0 +1,5 @@
1
+ class Inkling::Users::SessionsController < Devise::SessionsController
2
+
3
+ layout nil
4
+
5
+ end
@@ -0,0 +1,5 @@
1
+ class Inkling::CanCanAction < ActiveRecord::Base
2
+ set_table_name "inkling_can_can_actions"
3
+ has_one :permission
4
+
5
+ end
@@ -0,0 +1,3 @@
1
+ class Inkling::Log < ActiveRecord::Base
2
+
3
+ end
@@ -0,0 +1,54 @@
1
+
2
+ module Inkling
3
+ #an associated object which tracks all the relative URL paths to content in the system
4
+
5
+ class Path < ActiveRecord::Base
6
+ set_table_name :inkling_paths
7
+
8
+ belongs_to :content, :polymorphic => true
9
+ has_many :permissions
10
+ belongs_to :parent, :class_name => "Path"
11
+ has_many :children, :class_name => "Path", :foreign_key => "parent_id"
12
+
13
+ before_validation :update_slug!
14
+ validate :slug_unique?
15
+
16
+
17
+ #called before adding a new child path to see if the content object restricts what it's path should nest
18
+ #if there isn't a restricts() impl. on the content object, false is returned, allowing anything to be nested
19
+ def restricts?(sub_path)
20
+ if self.content
21
+ self.content.restricts?(sub_path.content) if self.content.respond_to? :restricts?
22
+ else
23
+ false
24
+ end
25
+ end
26
+
27
+ def update_slug!
28
+ slug = self.parent ? "#{self.parent.slug}/" : "/"
29
+ slug += "#{self.content.title}"
30
+ self.slug = sluggerize(slug)
31
+ end
32
+
33
+ #stolen from enki
34
+ def sluggerize(slug)
35
+ slug.downcase!
36
+ slug.gsub!(/&(\d)+;/, '') # Ditch Entities
37
+ slug.gsub!('&', 'and') # Replace & with 'and'
38
+ slug.gsub!(/['"]/, '') # replace quotes by nothing
39
+ slug.gsub!(/\ +/, '-') # replace all white space sections with a dash
40
+ slug.gsub!(/(-)$/, '') # trim dashes
41
+ slug.gsub!(/^(-)/, '') # trim dashes
42
+ slug.gsub!(/[^\/a-zA-Z0-9\-]/, '-') # Get rid of anything we don't like
43
+ slug
44
+ end
45
+
46
+ def slug_unique?
47
+ pre_existing = Inkling::Path.find_by_slug(self.slug)
48
+
49
+ if pre_existing and (self.new_record? or (pre_existing.id != self.id))
50
+ self.errors.add("path (#{self.slug}) already taken by another object in this website ")
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,7 @@
1
+ class Inkling::Permission < ActiveRecord::Base
2
+ set_table_name 'inkling_permissions'
3
+
4
+ belongs_to :role
5
+ belongs_to :can_can_action
6
+ belongs_to :type
7
+ end
@@ -0,0 +1,10 @@
1
+ module Inkling
2
+ class Role < ActiveRecord::Base
3
+ set_table_name 'inkling_roles'
4
+ has_many :role_memberships
5
+ has_many :users, :through => :role_memberships
6
+ has_many :permissions
7
+
8
+ ADMIN = "administrator"
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ module Inkling
2
+ class RoleMembership < ActiveRecord::Base
3
+ set_table_name 'inkling_role_memberships'
4
+
5
+ belongs_to :user, :class_name => "Inkling::User", :foreign_key => :user_id
6
+ belongs_to :role, :class_name => "Inkling::Role", :foreign_key => :role_id
7
+ end
8
+ end
@@ -0,0 +1,74 @@
1
+ #maintain one record which will theme the entire site for now
2
+
3
+ class Inkling::Theme < ActiveRecord::Base
4
+ include FileUtils
5
+ set_table_name "inkling_themes"
6
+
7
+ validates_uniqueness_of :name
8
+
9
+ after_save :check_init
10
+ after_save :write_file
11
+ after_destroy :delete_file
12
+
13
+ @@default_content = <<-DEFAULT
14
+ <html>
15
+ <head>
16
+ <title>Your Inkling CMS</title>
17
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
18
+ <meta name="keywords" content="" />
19
+ <meta name="description" content="" />
20
+ </head>
21
+ <body>
22
+
23
+ This is the default theme for public users to view content on your site. <br/>
24
+
25
+ An administrator should log into Inkling Administration and configure the 'content' theme. <br/>
26
+
27
+ <div class="notice"><%= notice %></div>
28
+ <div class="alert"><%= alert %></div>
29
+
30
+ <div id="page">
31
+ <div id="main">
32
+ <%= yield %>
33
+ </div>
34
+ </div>
35
+
36
+ <div id="footer">
37
+ <span id="version" align='center'>Inkling version <%= Inkling::VERSION %></span>
38
+ </div>
39
+
40
+
41
+ </body>
42
+ </html>
43
+ DEFAULT
44
+
45
+ def self.content
46
+ if Inkling::Theme.find_by_name("content").nil?
47
+ self.create!(:name => "content", :body => @@default_content)
48
+ end
49
+
50
+ Inkling::Theme.find_by_name("content")
51
+ end
52
+
53
+ def self.site_theme_file
54
+ "#{Inkling::THEME_LAYOUTS_DIR}#{self.site.file_name}"
55
+ end
56
+
57
+ def write_file
58
+ File.open("#{Inkling::THEME_LAYOUTS_DIR}#{self.file_name}", "w") {|f| f.write(self.body)}
59
+ end
60
+
61
+ def check_init
62
+ mkdir(Inkling::TMP_DIR) unless File.exist?(Inkling::TMP_DIR)
63
+ mkdir("#{Inkling::THEMES_DIR}") unless File.exist?("#{Inkling::THEMES_DIR}")
64
+ mkdir("#{Inkling::THEME_LAYOUTS_DIR}") unless File.exist?("#{Inkling::THEME_LAYOUTS_DIR}")
65
+ end
66
+
67
+ def delete_file
68
+ rm("#{Inkling::THEME_LAYOUTS_DIR}#{self.file_name}")
69
+ end
70
+
71
+ def file_name
72
+ "#{self.name}#{self.extension}"
73
+ end
74
+ end
@@ -0,0 +1,4 @@
1
+ class Inkling::Type < ActiveRecord::Base
2
+ set_table_name "inkling_types"
3
+ has_one :permission
4
+ end
@@ -0,0 +1,16 @@
1
+ class Inkling::User < ActiveRecord::Base
2
+
3
+ set_table_name 'inkling_users'
4
+ has_many :role_memberships
5
+ has_many :roles, :through => :role_memberships
6
+
7
+ devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable
8
+
9
+ # Setup accessible (or protected) attributes for your model
10
+ attr_accessible :email, :password, :password_confirmation, :remember_me
11
+
12
+ def has_role?(role)
13
+ role = role.to_s
14
+ self.roles.find_by_name(role)
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ <% if @inkling_admin_permission.errors.any? %>
2
+ <h2><%= pluralize(@inkling_admin_permission.errors.count, "error") %> prohibited this permission from being saved:</h2>
3
+ <ul>
4
+ <% @inkling_admin_permission.errors.full_messages.each do |msg| %>
5
+ <li><%= msg %></li>
6
+ <% end %>
7
+ </ul>
8
+ <% end %>
9
+
10
+ <% semantic_form_for [@inkling_admin_permission] do |form| %>
11
+
12
+ <% form.buttons do %>
13
+ <%= form.commit_button %>
14
+ <% end %>
15
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= render(:partial => "form") %>
@@ -0,0 +1,26 @@
1
+ <%= semantic_form_for @inkling_admin_permission do |f| %>
2
+ <%= f.input :role, :as => :select %>
3
+ <%= f.input :content_type, :as => :select %>
4
+
5
+ <% form.buttons do %>
6
+ <%= form.commit_button %>
7
+ <% end %>
8
+ <% end %>
9
+
10
+
11
+ <p/>
12
+ <table id="permissions-table">
13
+ <tr>
14
+ <th>Action</th>
15
+ <th>Type</th>
16
+ <th>Role</th>
17
+ </tr>
18
+ <% for permission in @permissions %>
19
+ <tr>
20
+ <td><%= permission.action %></td>
21
+ <td><%= permission.content_type %></td>
22
+ <td><%= permission.role.name %></td>
23
+ </tr>
24
+ <% end %>
25
+ </table>
26
+
@@ -0,0 +1 @@
1
+ <%= render(:partial => "form") %>
@@ -0,0 +1,11 @@
1
+ <table>
2
+ <% @inkling_admin_permission.attributes.each do |a| %>
3
+ <tr>
4
+ <th><%= a[0] %></th>
5
+ <td><%= a[1] %></td>
6
+ </tr>
7
+ <% end %>
8
+ </table>
9
+
10
+ <p><%= link_to "Edit", edit_polymorphic_path(@inkling_admin_permission) %></p>
11
+ <p><%= link_to "Back", polymorphic_path(@inkling_admin_permission) %></p>
@@ -0,0 +1,3 @@
1
+ <% for role in @roles %>
2
+ <%= role.name %> <br/>
3
+ <% end %>
@@ -0,0 +1 @@
1
+ index of sites
@@ -0,0 +1,12 @@
1
+ Content Types installed: <%= Inkling::Types::Register.listed.size %>
2
+ <p>
3
+
4
+ <% for type in Inkling::Types::Register.listed %>
5
+ <%= type.friendly_name %> - <%= type %> <br/>
6
+ <% end %>
7
+
8
+ <p>
9
+
10
+ Paths: <%= Inkling::Path.all.size %>
11
+
12
+ <p>
@@ -0,0 +1,16 @@
1
+ <% if @inkling_admin_user.errors.any? %>
2
+ <h2><%= pluralize(@inkling_admin_user.errors.count, "error") %> prohibited this user from being saved:</h2>
3
+ <ul>
4
+ <% @inkling_admin_user.errors.full_messages.each do |msg| %>
5
+ <li><%= msg %></li>
6
+ <% end %>
7
+ </ul>
8
+ <% end %>
9
+
10
+ <% semantic_form_for [@inkling_admin_user] do |form| %>
11
+ <%= form.input :email %>
12
+
13
+ <% form.buttons do %>
14
+ <%= form.commit_button %>
15
+ <% end %>
16
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= render(:partial => "form") %>