aura 0.0.1.pre10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (249) hide show
  1. data/.gitignore +6 -0
  2. data/.travis.yml +3 -0
  3. data/Gemfile +2 -0
  4. data/HISTORY.md +95 -0
  5. data/README.md +53 -0
  6. data/Rakefile +27 -0
  7. data/Scribefile +8 -0
  8. data/app/css/_utilities.scss +88 -0
  9. data/app/css/admin.scss +21 -0
  10. data/app/css/admin/_settings.scss +136 -0
  11. data/app/css/admin/chrome.scss +208 -0
  12. data/app/css/admin/common.scss +78 -0
  13. data/app/css/admin/forms.scss +342 -0
  14. data/app/css/admin/jquery_wysiwyg.scss +96 -0
  15. data/app/css/admin/loading.scss +18 -0
  16. data/app/css/admin/meta.scss +42 -0
  17. data/app/css/admin/reset.scss +46 -0
  18. data/app/css/admin/sections.scss +79 -0
  19. data/app/css/admin/setup.scss +22 -0
  20. data/app/css/admin/sidebar.scss +136 -0
  21. data/app/css/admin/slug.scss +78 -0
  22. data/app/css/admin/uiscreen.scss +22 -0
  23. data/app/css/admin/wysiwyg_field.scss +11 -0
  24. data/app/css/admin_watermark.scss +23 -0
  25. data/app/css/default_home_page.scss +13 -0
  26. data/app/css/login.scss +47 -0
  27. data/app/helpers/admin_helpers.rb +59 -0
  28. data/app/helpers/flash_helpers.rb +86 -0
  29. data/app/helpers/form_builder_helpers.rb +9 -0
  30. data/app/helpers/html_helpers.rb +27 -0
  31. data/app/helpers/jquery_helpers.rb +26 -0
  32. data/app/helpers/main_helpers.rb +67 -0
  33. data/app/helpers/page_helpers.rb +92 -0
  34. data/app/helpers/template_helpers.rb +94 -0
  35. data/app/helpers/user_helpers.rb +45 -0
  36. data/app/init/admin.rb +34 -0
  37. data/app/init/extensions.rb +18 -0
  38. data/app/init/pistol.rb +11 -0
  39. data/app/init/sequel.rb +11 -0
  40. data/app/main.rb +106 -0
  41. data/app/migrations/page.rb +29 -0
  42. data/app/migrations/settings.rb +11 -0
  43. data/app/migrations/user.rb +13 -0
  44. data/app/models/page.rb +116 -0
  45. data/app/models/page_seed.rb +47 -0
  46. data/app/models/settings.rb +59 -0
  47. data/app/models/user.rb +60 -0
  48. data/app/routes/admin.rb +44 -0
  49. data/app/routes/css_js.rb +53 -0
  50. data/app/routes/design_tests.rb +15 -0
  51. data/app/routes/editor.rb +152 -0
  52. data/app/routes/site.rb +33 -0
  53. data/app/routes/user.rb +48 -0
  54. data/app/views/admin/_back_to_dashboard.haml +3 -0
  55. data/app/views/admin/dashboard.haml +46 -0
  56. data/app/views/admin/layout.haml +73 -0
  57. data/app/views/admin/settings.haml +40 -0
  58. data/app/views/admin/settings/database.haml +42 -0
  59. data/app/views/base/crumbs.haml +50 -0
  60. data/app/views/base/delete.haml +19 -0
  61. data/app/views/base/edit.haml +61 -0
  62. data/app/views/base/errors.haml +10 -0
  63. data/app/views/base/form.haml +11 -0
  64. data/app/views/base/list.haml +14 -0
  65. data/app/views/base/list_actions.haml +4 -0
  66. data/app/views/base/list_item.haml +7 -0
  67. data/app/views/base/nav.haml +36 -0
  68. data/app/views/base/new.haml +36 -0
  69. data/app/views/base/preview.haml +28 -0
  70. data/app/views/base/tabs.haml +12 -0
  71. data/app/views/default_home_page.haml +15 -0
  72. data/app/views/design_tests/admin_styles.haml +58 -0
  73. data/app/views/form_builder/builder.haml +29 -0
  74. data/app/views/page/edit.haml +29 -0
  75. data/app/views/page/form.haml +22 -0
  76. data/app/views/page/meta_form.haml +22 -0
  77. data/app/views/page/new.haml +26 -0
  78. data/app/views/user/edit.haml +52 -0
  79. data/app/views/user/form.haml +43 -0
  80. data/app/views/user/list.haml +11 -0
  81. data/app/views/user/login.haml +33 -0
  82. data/app/views/user/new.haml +25 -0
  83. data/app/views/user/welcome.haml +29 -0
  84. data/app/views/watermark/watermark.haml +16 -0
  85. data/aura.gemspec +36 -0
  86. data/bin/aura +8 -0
  87. data/config/database.rb +12 -0
  88. data/config/extensions.rb +5 -0
  89. data/config/scss.rb +14 -0
  90. data/config/user.rb +10 -0
  91. data/default/.gitignore +6 -0
  92. data/default/Gemfile +11 -0
  93. data/default/README.md +24 -0
  94. data/default/Rakefile +8 -0
  95. data/default/app/README +3 -0
  96. data/default/app/css/.gitignore +0 -0
  97. data/default/app/helpers/helpers.rb.example +9 -0
  98. data/default/app/js/.gitignore +0 -0
  99. data/default/app/migrations/model.rb.example +20 -0
  100. data/default/app/models/model.rb.example +11 -0
  101. data/default/app/models/page-ext.rb.example +17 -0
  102. data/default/app/routes/site.rb.example +5 -0
  103. data/default/app/views/hello.haml.example +1 -0
  104. data/default/config.ru +3 -0
  105. data/default/config/.gitignore +0 -0
  106. data/default/config/database.rb.example +30 -0
  107. data/default/config/extensions.rb +5 -0
  108. data/default/config/user.rb.example +10 -0
  109. data/default/db/.gitignore +0 -0
  110. data/default/init.rb +15 -0
  111. data/default/public/.gitignore +0 -0
  112. data/extensions/contact_form/migrations/contact_form.rb +13 -0
  113. data/extensions/contact_form/models/contact_form.rb +13 -0
  114. data/extensions/contact_form/routes/contact_form.rb +11 -0
  115. data/extensions/contact_form/views/contact_form/edit.haml +8 -0
  116. data/extensions/contact_form/views/contact_form/form.haml +3 -0
  117. data/extensions/contact_form/views/contact_form/nav.haml +42 -0
  118. data/extensions/contact_form/views/contact_form/responses.haml +20 -0
  119. data/extensions/contact_form/views/contact_form/tabs.haml +8 -0
  120. data/extensions/default_theme/css/theme/_settings.scss +3 -0
  121. data/extensions/default_theme/css/theme/chrome.scss +66 -0
  122. data/extensions/default_theme/css/theme/reset.scss +34 -0
  123. data/extensions/default_theme/css/theme/style.scss +3 -0
  124. data/extensions/default_theme/info.yml +2 -0
  125. data/extensions/default_theme/public/browse.png +0 -0
  126. data/extensions/default_theme/views/base/id_portfolio.haml +32 -0
  127. data/extensions/default_theme/views/base/show.haml +31 -0
  128. data/extensions/default_theme/views/errors/error.haml +9 -0
  129. data/extensions/default_theme/views/errors/not_found.haml +11 -0
  130. data/extensions/default_theme/views/layout.haml +33 -0
  131. data/lib/aura.rb +315 -0
  132. data/lib/aura/admin.rb +41 -0
  133. data/lib/aura/app.rb +4 -0
  134. data/lib/aura/cli.rb +19 -0
  135. data/lib/aura/cli/base.rb +89 -0
  136. data/lib/aura/cli/helpers.rb +32 -0
  137. data/lib/aura/editor.rb +30 -0
  138. data/lib/aura/extension.rb +189 -0
  139. data/lib/aura/files.rb +38 -0
  140. data/lib/aura/menu.rb +142 -0
  141. data/lib/aura/models.rb +80 -0
  142. data/lib/aura/public.rb +68 -0
  143. data/lib/aura/rendering.rb +134 -0
  144. data/lib/aura/seeder.rb +38 -0
  145. data/lib/aura/slugs.rb +87 -0
  146. data/lib/aura/subtype.rb +48 -0
  147. data/lib/aura/tasks.rb +24 -0
  148. data/lib/aura/tasks/common.rb +17 -0
  149. data/lib/aura/tasks/db.rake +54 -0
  150. data/lib/aura/utils.rb +81 -0
  151. data/lib/aura/version.rb +25 -0
  152. data/lib/core/hasharray.rb +65 -0
  153. data/lib/core/object_ext.rb +9 -0
  154. data/lib/sequel/plugins/aura_custom.rb +16 -0
  155. data/lib/sequel/plugins/aura_editable.rb +39 -0
  156. data/lib/sequel/plugins/aura_hierarchy.rb +82 -0
  157. data/lib/sequel/plugins/aura_model.rb +271 -0
  158. data/lib/sequel/plugins/aura_renderable.rb +42 -0
  159. data/lib/sequel/plugins/aura_sluggable.rb +103 -0
  160. data/lib/sequel/plugins/aura_subtyped.rb +83 -0
  161. data/lib/terra.rb +185 -0
  162. data/lib/terra/ext.rb +16 -0
  163. data/lib/terra/field.rb +98 -0
  164. data/lib/terra/fields.rb +122 -0
  165. data/lib/terra/fieldset.rb +93 -0
  166. data/lib/terra/form.rb +111 -0
  167. data/manual/configuration.md +42 -0
  168. data/manual/extensions.md +45 -0
  169. data/manual/files.md +70 -0
  170. data/manual/helpers.md +39 -0
  171. data/manual/index.md +65 -0
  172. data/manual/models.md +58 -0
  173. data/manual/recipes.md +38 -0
  174. data/manual/recipes/bundling_sample_data.md +30 -0
  175. data/manual/recipes/creating_themes.md +10 -0
  176. data/manual/recipes/using_markdown_or_textile.md +24 -0
  177. data/manual/routes.md +39 -0
  178. data/manual/theming.md +55 -0
  179. data/manual/views.md +128 -0
  180. data/public/hi.html +0 -0
  181. data/public/images/admin/back.png +0 -0
  182. data/public/images/admin/browse.png +0 -0
  183. data/public/images/admin/mock-bg.png +0 -0
  184. data/public/images/admin/top-loader.gif +0 -0
  185. data/public/images/admin/uiscreen-loader.gif +0 -0
  186. data/public/images/admin_icons/add.png +0 -0
  187. data/public/images/admin_icons/contact.png +0 -0
  188. data/public/images/admin_icons/dashboard.png +0 -0
  189. data/public/images/admin_icons/generic.png +0 -0
  190. data/public/images/admin_icons/home-12.png +0 -0
  191. data/public/images/admin_icons/page.png +0 -0
  192. data/public/images/admin_icons/settings.png +0 -0
  193. data/public/images/jquery.wysiwyg.gif +0 -0
  194. data/public/js/admin.form_builder.js +15 -0
  195. data/public/js/admin.js +62 -0
  196. data/public/js/admin.layout.js +53 -0
  197. data/public/js/admin.nav.js +241 -0
  198. data/public/js/admin.slug.js +46 -0
  199. data/public/js/admin.subpage.js +15 -0
  200. data/public/js/jquery.hashlisten.js +85 -0
  201. data/public/js/jquery.js +166 -0
  202. data/public/js/jquery.livenavigate.js +58 -0
  203. data/public/js/jquery.livequery.js +226 -0
  204. data/public/js/jquery.quickvalidate.js +164 -0
  205. data/public/js/jquery.tmpl.js +486 -0
  206. data/public/js/jquery.uiscreen.js +150 -0
  207. data/public/js/jquery.wysiwyg.js +2339 -0
  208. data/public/js/jqueryui.js +766 -0
  209. data/public/js/lib.dirty.js +11 -0
  210. data/public/js/lib.loading.js +23 -0
  211. data/public/js/lib.wysiwyg.js +155 -0
  212. data/public/js/underscore-1.1.7.js +27 -0
  213. data/test/app/app/css/test_raw.css +1 -0
  214. data/test/app/app/css/test_sass.sass +3 -0
  215. data/test/app/app/damogram.txt +1 -0
  216. data/test/app/app/js/test_coffee.coffee +4 -0
  217. data/test/app/app/js/test_javascript.js +4 -0
  218. data/test/app/init.rb +5 -0
  219. data/test/stories/admin_css_story.rb +18 -0
  220. data/test/stories/css_js_story.rb +29 -0
  221. data/test/stories/first_login_story.rb +29 -0
  222. data/test/stories/visit_story.rb +39 -0
  223. data/test/stories_helper.rb +58 -0
  224. data/test/test_cli_helper.rb +31 -0
  225. data/test/test_helper.rb +111 -0
  226. data/test/test_temp_helper.rb +9 -0
  227. data/test/unit/cli_test.rb +38 -0
  228. data/test/unit/dump_test.rb +14 -0
  229. data/test/unit/extensions_test.rb +18 -0
  230. data/test/unit/files_test.rb +14 -0
  231. data/test/unit/flash_helper_test.rb +36 -0
  232. data/test/unit/html_helper_test.rb +29 -0
  233. data/test/unit/jquery_helper_test.rb +18 -0
  234. data/test/unit/model_test.rb +34 -0
  235. data/test/unit/page_helpers_test.rb +36 -0
  236. data/test/unit/seeder_test.rb +15 -0
  237. data/test/unit/settings_test.rb +29 -0
  238. data/test/unit/slug_test.rb +39 -0
  239. data/test/unit/ss_migration_test.rb +14 -0
  240. data/test/unit/terra_test.rb +125 -0
  241. data/test/unit/utils_test.rb +11 -0
  242. data/vendor/sinatra-sequel/.gitignore +3 -0
  243. data/vendor/sinatra-sequel/COPYING +18 -0
  244. data/vendor/sinatra-sequel/README.md +84 -0
  245. data/vendor/sinatra-sequel/Rakefile +67 -0
  246. data/vendor/sinatra-sequel/lib/sinatra/sequel.rb +73 -0
  247. data/vendor/sinatra-sequel/sinatra-sequel.gemspec +39 -0
  248. data/vendor/sinatra-sequel/spec/spec_sinatra_sequel.rb +70 -0
  249. metadata +536 -0
@@ -0,0 +1,41 @@
1
+ # Module: Admin (Aura)
2
+ # Admin stuff.
3
+ #
4
+ # ## Description
5
+ # This is accessible via {Aura.admin}.
6
+ #
7
+ class Aura
8
+ module Admin
9
+ extend self
10
+
11
+ # Class method: menu (Aura::Admin)
12
+ # Usage: Aura.admin.menu
13
+ #
14
+ # Returns admin menu items.
15
+ #
16
+ def menu
17
+ @menu ||= Menu.new
18
+ end
19
+
20
+ # Class method: css (Aura::Admin)
21
+ # Usage: Aura.admin.css
22
+ #
23
+ # Returns the list of CSS files.
24
+ #
25
+ # ## Description
26
+ # This allows you to customize the admin interface by adding your
27
+ # own CSS files.
28
+ #
29
+ # #### Example
30
+ # This example adds a CSS file to the admin. This should be in your
31
+ # project's `app/init/`.
32
+ #
33
+ # [/app/init/admin.rb (rb)]
34
+ # Aura.admin.css << {:href => '/css/admin-ext.css', :media => 'screen'}
35
+ #
36
+ def css
37
+ @css ||= Array.new([ { :href => '/css/admin.css', :media => 'screen' } ])
38
+ end
39
+ end
40
+ end
41
+
@@ -0,0 +1,4 @@
1
+ # Summon Aura::App aka Main
2
+ require File.expand_path('../../aura', __FILE__)
3
+ require Aura.gem_root('app/main')
4
+ Aura::App
@@ -0,0 +1,19 @@
1
+ require 'shake'
2
+
3
+ # Class: CLI (Aura)
4
+ # The CLI runner.
5
+ #
6
+ # ## Description
7
+ # This is a runner based on the [Shake
8
+ # gem](http://github.com/rstacruz/shake).
9
+ #
10
+ class Aura
11
+ class CLI < Shake
12
+ autoload :Helpers, File.expand_path('../cli/helpers', __FILE__)
13
+
14
+ include Shake::Defaults
15
+ extend Helpers
16
+ end
17
+ end
18
+
19
+ require File.expand_path('../cli/base', __FILE__)
@@ -0,0 +1,89 @@
1
+ class Aura::CLI
2
+ # TODO This looks stupid, refactor later
3
+ task :new do
4
+ require 'fileutils'
5
+ require 'aura/version'
6
+
7
+ if params.empty?
8
+ err "Usage: #{$0} new PROJECT_NAME"
9
+ pass
10
+ end
11
+
12
+ name = params.first
13
+ path = File.join(ENV['AURA_ROOT'], 'default')
14
+
15
+ if File.exists?(name)
16
+ err "That path already exists."
17
+ pass
18
+ end
19
+
20
+ FileUtils.mkdir name
21
+
22
+ # Copy everything over
23
+ Dir["#{path}/**/{.*,*}"].sort.each do |from|
24
+ base = from.gsub(path, '')
25
+ fn = File.basename(from)
26
+ target = File.join(name, base)
27
+
28
+ next if ['Gemfile.lock', '.rvmrc'].include?(fn)
29
+
30
+ if File.file?(from)
31
+ FileUtils.mkdir_p File.dirname(target)
32
+ FileUtils.cp from, target
33
+ end
34
+ end
35
+
36
+ # Edit the Gemfile
37
+ gemfile = File.read(File.join(name, 'Gemfile'))
38
+ version = Aura.prerelease? ? Aura.version : "~> #{Aura.version}"
39
+ gemfile.gsub!("AURA_GEM_VERSION", version)
40
+
41
+ File.open(File.join(name, 'Gemfile'), 'w') { |f| f.write gemfile }
42
+
43
+ show_tree name
44
+
45
+ puts ""
46
+ puts "Done! Get started now:"
47
+ puts ""
48
+ puts " $ cd #{name}"
49
+ puts " $ bundle install"
50
+ puts ""
51
+ puts "Then start it as a Rack app."
52
+ puts ""
53
+ puts " $ rackup"
54
+ puts ""
55
+ end
56
+
57
+ task.description = "Starts a new project"
58
+ task.usage = "new NAME"
59
+
60
+ task :help do
61
+ err "Usage: #{executable} <command>"
62
+ err
63
+ err "Options:"
64
+ err " -v, [--version] Shows the Aura version number and quits"
65
+ err
66
+ err "Commands:"
67
+ tasks.each { |name, task| err " %-20s %s" % [ name, task.description ] }
68
+ err
69
+ err "Description:"
70
+ err " The '#{executable} new' command creates a new Aura application with"
71
+ err " the default directory structure."
72
+ err
73
+ err "Example:"
74
+ err " # This generates a new project in ./my_project."
75
+ err " $ #{executable} new my_project"
76
+ err
77
+ end
78
+ task.description = "Shows this help screen"
79
+
80
+ def self.run(*a)
81
+ if %w(-v --version).include?(a.join(' '))
82
+ require 'aura/version'
83
+
84
+ puts "Aura #{Aura.version}"
85
+ else
86
+ super *a
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,32 @@
1
+ module Aura::CLI::Helpers
2
+ def color(what, n=32)
3
+ "\033[0;#{n}m#{what}\033[0;m"
4
+ end
5
+
6
+ def status(what, message)
7
+ puts "%s %s" % [ color("%12s" % [what], 32), message ]
8
+ end
9
+
10
+ def show_tree(path, what=:create)
11
+ explore = lambda { |*a| #path, depth=0
12
+ path, depth = a
13
+ depth ||= 0
14
+
15
+ files = Dir["#{path}/{.*,*}"]
16
+
17
+ dirs = files.select { |f| File.directory?(f) && !%w(. ..).include?(File.basename(f)) }
18
+ files = files.select { |f| File.file?(f) }
19
+
20
+ dirname = File.basename(path)
21
+ status :create, path + '/'
22
+
23
+ files.each { |f|
24
+ status '', (path + '/' + color(File.basename(f), 30))
25
+ }
26
+
27
+ dirs.each { |d| explore[d, depth+1] }
28
+ }
29
+
30
+ explore[path]
31
+ end
32
+ end
@@ -0,0 +1,30 @@
1
+ # Module: Editor (Aura)
2
+ # Editor stuff.
3
+ #
4
+ # ## Description
5
+ # This is accessible via {Aura.editor}.
6
+ #
7
+ class Aura
8
+ module Editor
9
+ # Class method: roots (Aura::Editor)
10
+ # Returns the root nodes to be shown on the editor sidebar.
11
+ #
12
+ # ## Usage
13
+ # Aura.editor.roots
14
+ #
15
+ # ## Description
16
+ # Returns instances of `Sequel::Model` as an array of hashes
17
+ # (HashArray).
18
+ #
19
+ def roots
20
+ models = Aura.models.all.select { |m| m.try(:editable?) }
21
+
22
+ models.inject(HashArray.new) do |hash, model|
23
+ hash << { model => model.roots }
24
+ hash
25
+ end
26
+ end
27
+
28
+ module_function :roots
29
+ end
30
+ end
@@ -0,0 +1,189 @@
1
+ require 'yaml'
2
+ require 'ostruct'
3
+
4
+ class Aura
5
+ ExtensionNotFound = Class.new(StandardError)
6
+
7
+ # Class: Extension (Aura)
8
+ # A class representing an extension in Aura.
9
+ #
10
+ # #### Lookup
11
+ # Get an Extension instance by passing an extension name.
12
+ #
13
+ # ext = Aura::Extension['base']
14
+ #
15
+ # #### Loading extensions
16
+ #
17
+ # ext.active? #=> false (probably)
18
+ # ext.load!
19
+ # ext.active? #=> true
20
+ #
21
+ # #### Getting extension info
22
+ # These are loaded from an extension's YAML file.
23
+ #
24
+ # ext.info #=> #<OStruct>
25
+ # ext.info.author
26
+ #
27
+ # #### Getting paths
28
+ # Use {Aura::Extension#path}.
29
+ #
30
+ # ext.path #=> ~/aura/extensions/base
31
+ # ext.path('init.rb') #=> ~/aura/extensions/base/init.rb
32
+ #
33
+ # Aura::Extension.active # Active extensions (Array of #<Extension>)
34
+ # Aura::Extension.all # All extensions (Array of #<Extension>)
35
+ #
36
+ # #### Manual instanciation
37
+ # You can pass a path to the constructor.
38
+ #
39
+ # ext = Aura::Extension.new('/path/to/ext')
40
+ #
41
+ class Extension
42
+ attr_reader :name
43
+
44
+ # Returns an extension with the given ext name/path.
45
+ # Returns nil if it's not found.
46
+ def self.[](name)
47
+ self.new(name)
48
+ rescue ExtensionNotFound
49
+ nil
50
+ end
51
+
52
+ # Returns an extension with the given ext name/path.
53
+ # Raises ExtensionNotFound if it's not found.
54
+ def initialize(name)
55
+ @path, @name = nil
56
+
57
+ if File.directory?(name)
58
+ @path, @name = name, File.basename(name)
59
+
60
+ elsif Main.respond_to?(:extensions_path)
61
+ @name = name
62
+ [Main.extensions_path].flatten.each do |dir|
63
+ next unless @path.nil?
64
+ @path = File.join(dir, name)
65
+ @path = nil unless File.directory?(@path)
66
+ end
67
+ end
68
+
69
+ raise ExtensionNotFound unless File.directory?(@path.to_s)
70
+ end
71
+
72
+ # Method: path (Aura::Extension)
73
+ # Returns the path of the extension.
74
+ #
75
+ # ## Description
76
+ # If arguments are given, they are joined into the extension's path.
77
+ # nil will be returned if the path does not exist.
78
+ #
79
+ # ## Example
80
+ #
81
+ # Aura::Extension['base'].path #=> ~/aura/extensions/base
82
+ # Aura::Extension['base'].path('init.rb') #=> ~/aura/extensions/base/init.rb
83
+ #
84
+ def path(*a)
85
+ return @path if a.empty?
86
+ ret = File.join(@path, *(a.map { |arg| arg.to_s }))
87
+ ret = File.expand_path(ret) # Try to fix some heroku issues (?)
88
+ File.exists?(ret) ? ret : nil
89
+ end
90
+
91
+ # Method: load! (Aura::Extension)
92
+ # Loads an extension.
93
+ #
94
+ def load!
95
+ # TODO Don't load a module that's already loaded
96
+
97
+ # Load the main file
98
+ fname = path("#{name}.rb")
99
+ require fname unless fname.nil?
100
+
101
+ # Load the basic things usually autoloaded.
102
+ Dir["#{@path}/{init,models,routes,helpers}/*.rb"].each { |f| require f }
103
+
104
+ # Ensure public/ works
105
+ public_path = path(:public)
106
+ Main.add_public(public_path) unless public_path.nil?
107
+
108
+ # Add the view path, if it has
109
+ if path(:views)
110
+ paths = [path(:views)]
111
+ paths += Main.multi_views if Main.respond_to?(:multi_views)
112
+ Main.set :multi_views, paths
113
+ end
114
+ end
115
+
116
+ # Method: active? (Aura::Extension)
117
+ # Determines if the given extension is currently active in the config.
118
+ #
119
+ def active?
120
+ self.class.active_names.include?(@name)
121
+ end
122
+
123
+ # Initializes an extension after it's already loaded.
124
+ # This is done after all extensions are loaded.
125
+ #
126
+ def init
127
+ fname = path("init.rb")
128
+ load fname unless fname.nil?
129
+ end
130
+
131
+ # Method: info (Aura::Extension)
132
+ # Returns an OpenStruct of information on the extension.
133
+ #
134
+ # ## Example
135
+ #
136
+ # Aura::Extension['default_theme'].info
137
+ # Aura::Extension['default_theme'].info.author
138
+ #
139
+ def info
140
+ return @info unless @info.nil?
141
+
142
+ fname = path('info.yml')
143
+ return nil if fname.nil?
144
+
145
+ @info ||= OpenStruct.new(YAML::load_file(fname).merge({:path => @path}))
146
+ end
147
+
148
+ alias to_s name
149
+
150
+ # Class method: active (Aura::Extension)
151
+ # Returns all the extensions that are loaded in the config.
152
+ #
153
+ # ## See also
154
+ # * {Aura::Extension.all}
155
+ #
156
+ def self.active
157
+ self.active_names.map { |ext| self[ext] }.compact
158
+ end
159
+
160
+ # Class method: active_names (Aura::Extension)
161
+ # Returns all names of the extensions that are loaded in the config.
162
+ #
163
+ # ## Description
164
+ # Returns an array of strings.
165
+ #
166
+ def self.active_names
167
+ exts = Array.new
168
+ exts += Main.additional_extensions if Main.respond_to?(:additional_extensions)
169
+ exts
170
+ end
171
+
172
+ # Class method: all (Aura::Extension)
173
+ # Returns all extensions (not just the ones loaded).
174
+ #
175
+ # ## Description
176
+ # Returns an array of {Aura::Extension} instances.
177
+ #
178
+ # ## See also
179
+ # * {Aura::Extension.active}
180
+ #
181
+ def self.all
182
+ return @all unless @all.nil?
183
+
184
+ paths = Main.extensions_path.map { |path| Dir["#{path}/*"] }.flatten
185
+
186
+ @all ||= paths.uniq.map { |path| self.new(path) }.compact
187
+ end
188
+ end
189
+ end
@@ -0,0 +1,38 @@
1
+ # Module: Files (Aura)
2
+ # Files stuff.
3
+ #
4
+ # ## Description
5
+ # This is accessible via {Aura.files}.
6
+ #
7
+ # These functions checks for files in:
8
+ #
9
+ # * Aura's default app stuff (`(aura gem)/app/`)
10
+ # * Each of the active extensions's folders (`(extension)/`)
11
+ # * Your applications (`(application)/app/`)
12
+ #
13
+ class Aura
14
+ module Files
15
+ # Method [] (Aura::Files)
16
+ # Finds a file's path.
17
+ #
18
+ def self.[](fname)
19
+ try = lambda { |f| f if File.exists?(f) }
20
+
21
+ re = try[Aura.gem_root("app/#{fname}")]
22
+ Extension.active.each { |e| re ||= try["#{e.path}/#{fname}"] }
23
+ re ||= try[Aura.root("app/#{fname}")]
24
+ end
25
+
26
+ # Method: glob (Aura::Files)
27
+ # Finds files with the given spec.
28
+ #
29
+ def self.glob(spec)
30
+ paths = Array.new
31
+ paths << Aura.gem_root("app/#{spec}")
32
+ paths += Extension.active.map { |e| "#{e.path}/#{spec}" }
33
+ paths << Aura.root("app/#{spec}")
34
+
35
+ paths.compact.map { |spec| Dir[spec].sort }.flatten.uniq
36
+ end
37
+ end
38
+ end