aura 0.0.1.pre10
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/.travis.yml +3 -0
- data/Gemfile +2 -0
- data/HISTORY.md +95 -0
- data/README.md +53 -0
- data/Rakefile +27 -0
- data/Scribefile +8 -0
- data/app/css/_utilities.scss +88 -0
- data/app/css/admin.scss +21 -0
- data/app/css/admin/_settings.scss +136 -0
- data/app/css/admin/chrome.scss +208 -0
- data/app/css/admin/common.scss +78 -0
- data/app/css/admin/forms.scss +342 -0
- data/app/css/admin/jquery_wysiwyg.scss +96 -0
- data/app/css/admin/loading.scss +18 -0
- data/app/css/admin/meta.scss +42 -0
- data/app/css/admin/reset.scss +46 -0
- data/app/css/admin/sections.scss +79 -0
- data/app/css/admin/setup.scss +22 -0
- data/app/css/admin/sidebar.scss +136 -0
- data/app/css/admin/slug.scss +78 -0
- data/app/css/admin/uiscreen.scss +22 -0
- data/app/css/admin/wysiwyg_field.scss +11 -0
- data/app/css/admin_watermark.scss +23 -0
- data/app/css/default_home_page.scss +13 -0
- data/app/css/login.scss +47 -0
- data/app/helpers/admin_helpers.rb +59 -0
- data/app/helpers/flash_helpers.rb +86 -0
- data/app/helpers/form_builder_helpers.rb +9 -0
- data/app/helpers/html_helpers.rb +27 -0
- data/app/helpers/jquery_helpers.rb +26 -0
- data/app/helpers/main_helpers.rb +67 -0
- data/app/helpers/page_helpers.rb +92 -0
- data/app/helpers/template_helpers.rb +94 -0
- data/app/helpers/user_helpers.rb +45 -0
- data/app/init/admin.rb +34 -0
- data/app/init/extensions.rb +18 -0
- data/app/init/pistol.rb +11 -0
- data/app/init/sequel.rb +11 -0
- data/app/main.rb +106 -0
- data/app/migrations/page.rb +29 -0
- data/app/migrations/settings.rb +11 -0
- data/app/migrations/user.rb +13 -0
- data/app/models/page.rb +116 -0
- data/app/models/page_seed.rb +47 -0
- data/app/models/settings.rb +59 -0
- data/app/models/user.rb +60 -0
- data/app/routes/admin.rb +44 -0
- data/app/routes/css_js.rb +53 -0
- data/app/routes/design_tests.rb +15 -0
- data/app/routes/editor.rb +152 -0
- data/app/routes/site.rb +33 -0
- data/app/routes/user.rb +48 -0
- data/app/views/admin/_back_to_dashboard.haml +3 -0
- data/app/views/admin/dashboard.haml +46 -0
- data/app/views/admin/layout.haml +73 -0
- data/app/views/admin/settings.haml +40 -0
- data/app/views/admin/settings/database.haml +42 -0
- data/app/views/base/crumbs.haml +50 -0
- data/app/views/base/delete.haml +19 -0
- data/app/views/base/edit.haml +61 -0
- data/app/views/base/errors.haml +10 -0
- data/app/views/base/form.haml +11 -0
- data/app/views/base/list.haml +14 -0
- data/app/views/base/list_actions.haml +4 -0
- data/app/views/base/list_item.haml +7 -0
- data/app/views/base/nav.haml +36 -0
- data/app/views/base/new.haml +36 -0
- data/app/views/base/preview.haml +28 -0
- data/app/views/base/tabs.haml +12 -0
- data/app/views/default_home_page.haml +15 -0
- data/app/views/design_tests/admin_styles.haml +58 -0
- data/app/views/form_builder/builder.haml +29 -0
- data/app/views/page/edit.haml +29 -0
- data/app/views/page/form.haml +22 -0
- data/app/views/page/meta_form.haml +22 -0
- data/app/views/page/new.haml +26 -0
- data/app/views/user/edit.haml +52 -0
- data/app/views/user/form.haml +43 -0
- data/app/views/user/list.haml +11 -0
- data/app/views/user/login.haml +33 -0
- data/app/views/user/new.haml +25 -0
- data/app/views/user/welcome.haml +29 -0
- data/app/views/watermark/watermark.haml +16 -0
- data/aura.gemspec +36 -0
- data/bin/aura +8 -0
- data/config/database.rb +12 -0
- data/config/extensions.rb +5 -0
- data/config/scss.rb +14 -0
- data/config/user.rb +10 -0
- data/default/.gitignore +6 -0
- data/default/Gemfile +11 -0
- data/default/README.md +24 -0
- data/default/Rakefile +8 -0
- data/default/app/README +3 -0
- data/default/app/css/.gitignore +0 -0
- data/default/app/helpers/helpers.rb.example +9 -0
- data/default/app/js/.gitignore +0 -0
- data/default/app/migrations/model.rb.example +20 -0
- data/default/app/models/model.rb.example +11 -0
- data/default/app/models/page-ext.rb.example +17 -0
- data/default/app/routes/site.rb.example +5 -0
- data/default/app/views/hello.haml.example +1 -0
- data/default/config.ru +3 -0
- data/default/config/.gitignore +0 -0
- data/default/config/database.rb.example +30 -0
- data/default/config/extensions.rb +5 -0
- data/default/config/user.rb.example +10 -0
- data/default/db/.gitignore +0 -0
- data/default/init.rb +15 -0
- data/default/public/.gitignore +0 -0
- data/extensions/contact_form/migrations/contact_form.rb +13 -0
- data/extensions/contact_form/models/contact_form.rb +13 -0
- data/extensions/contact_form/routes/contact_form.rb +11 -0
- data/extensions/contact_form/views/contact_form/edit.haml +8 -0
- data/extensions/contact_form/views/contact_form/form.haml +3 -0
- data/extensions/contact_form/views/contact_form/nav.haml +42 -0
- data/extensions/contact_form/views/contact_form/responses.haml +20 -0
- data/extensions/contact_form/views/contact_form/tabs.haml +8 -0
- data/extensions/default_theme/css/theme/_settings.scss +3 -0
- data/extensions/default_theme/css/theme/chrome.scss +66 -0
- data/extensions/default_theme/css/theme/reset.scss +34 -0
- data/extensions/default_theme/css/theme/style.scss +3 -0
- data/extensions/default_theme/info.yml +2 -0
- data/extensions/default_theme/public/browse.png +0 -0
- data/extensions/default_theme/views/base/id_portfolio.haml +32 -0
- data/extensions/default_theme/views/base/show.haml +31 -0
- data/extensions/default_theme/views/errors/error.haml +9 -0
- data/extensions/default_theme/views/errors/not_found.haml +11 -0
- data/extensions/default_theme/views/layout.haml +33 -0
- data/lib/aura.rb +315 -0
- data/lib/aura/admin.rb +41 -0
- data/lib/aura/app.rb +4 -0
- data/lib/aura/cli.rb +19 -0
- data/lib/aura/cli/base.rb +89 -0
- data/lib/aura/cli/helpers.rb +32 -0
- data/lib/aura/editor.rb +30 -0
- data/lib/aura/extension.rb +189 -0
- data/lib/aura/files.rb +38 -0
- data/lib/aura/menu.rb +142 -0
- data/lib/aura/models.rb +80 -0
- data/lib/aura/public.rb +68 -0
- data/lib/aura/rendering.rb +134 -0
- data/lib/aura/seeder.rb +38 -0
- data/lib/aura/slugs.rb +87 -0
- data/lib/aura/subtype.rb +48 -0
- data/lib/aura/tasks.rb +24 -0
- data/lib/aura/tasks/common.rb +17 -0
- data/lib/aura/tasks/db.rake +54 -0
- data/lib/aura/utils.rb +81 -0
- data/lib/aura/version.rb +25 -0
- data/lib/core/hasharray.rb +65 -0
- data/lib/core/object_ext.rb +9 -0
- data/lib/sequel/plugins/aura_custom.rb +16 -0
- data/lib/sequel/plugins/aura_editable.rb +39 -0
- data/lib/sequel/plugins/aura_hierarchy.rb +82 -0
- data/lib/sequel/plugins/aura_model.rb +271 -0
- data/lib/sequel/plugins/aura_renderable.rb +42 -0
- data/lib/sequel/plugins/aura_sluggable.rb +103 -0
- data/lib/sequel/plugins/aura_subtyped.rb +83 -0
- data/lib/terra.rb +185 -0
- data/lib/terra/ext.rb +16 -0
- data/lib/terra/field.rb +98 -0
- data/lib/terra/fields.rb +122 -0
- data/lib/terra/fieldset.rb +93 -0
- data/lib/terra/form.rb +111 -0
- data/manual/configuration.md +42 -0
- data/manual/extensions.md +45 -0
- data/manual/files.md +70 -0
- data/manual/helpers.md +39 -0
- data/manual/index.md +65 -0
- data/manual/models.md +58 -0
- data/manual/recipes.md +38 -0
- data/manual/recipes/bundling_sample_data.md +30 -0
- data/manual/recipes/creating_themes.md +10 -0
- data/manual/recipes/using_markdown_or_textile.md +24 -0
- data/manual/routes.md +39 -0
- data/manual/theming.md +55 -0
- data/manual/views.md +128 -0
- data/public/hi.html +0 -0
- data/public/images/admin/back.png +0 -0
- data/public/images/admin/browse.png +0 -0
- data/public/images/admin/mock-bg.png +0 -0
- data/public/images/admin/top-loader.gif +0 -0
- data/public/images/admin/uiscreen-loader.gif +0 -0
- data/public/images/admin_icons/add.png +0 -0
- data/public/images/admin_icons/contact.png +0 -0
- data/public/images/admin_icons/dashboard.png +0 -0
- data/public/images/admin_icons/generic.png +0 -0
- data/public/images/admin_icons/home-12.png +0 -0
- data/public/images/admin_icons/page.png +0 -0
- data/public/images/admin_icons/settings.png +0 -0
- data/public/images/jquery.wysiwyg.gif +0 -0
- data/public/js/admin.form_builder.js +15 -0
- data/public/js/admin.js +62 -0
- data/public/js/admin.layout.js +53 -0
- data/public/js/admin.nav.js +241 -0
- data/public/js/admin.slug.js +46 -0
- data/public/js/admin.subpage.js +15 -0
- data/public/js/jquery.hashlisten.js +85 -0
- data/public/js/jquery.js +166 -0
- data/public/js/jquery.livenavigate.js +58 -0
- data/public/js/jquery.livequery.js +226 -0
- data/public/js/jquery.quickvalidate.js +164 -0
- data/public/js/jquery.tmpl.js +486 -0
- data/public/js/jquery.uiscreen.js +150 -0
- data/public/js/jquery.wysiwyg.js +2339 -0
- data/public/js/jqueryui.js +766 -0
- data/public/js/lib.dirty.js +11 -0
- data/public/js/lib.loading.js +23 -0
- data/public/js/lib.wysiwyg.js +155 -0
- data/public/js/underscore-1.1.7.js +27 -0
- data/test/app/app/css/test_raw.css +1 -0
- data/test/app/app/css/test_sass.sass +3 -0
- data/test/app/app/damogram.txt +1 -0
- data/test/app/app/js/test_coffee.coffee +4 -0
- data/test/app/app/js/test_javascript.js +4 -0
- data/test/app/init.rb +5 -0
- data/test/stories/admin_css_story.rb +18 -0
- data/test/stories/css_js_story.rb +29 -0
- data/test/stories/first_login_story.rb +29 -0
- data/test/stories/visit_story.rb +39 -0
- data/test/stories_helper.rb +58 -0
- data/test/test_cli_helper.rb +31 -0
- data/test/test_helper.rb +111 -0
- data/test/test_temp_helper.rb +9 -0
- data/test/unit/cli_test.rb +38 -0
- data/test/unit/dump_test.rb +14 -0
- data/test/unit/extensions_test.rb +18 -0
- data/test/unit/files_test.rb +14 -0
- data/test/unit/flash_helper_test.rb +36 -0
- data/test/unit/html_helper_test.rb +29 -0
- data/test/unit/jquery_helper_test.rb +18 -0
- data/test/unit/model_test.rb +34 -0
- data/test/unit/page_helpers_test.rb +36 -0
- data/test/unit/seeder_test.rb +15 -0
- data/test/unit/settings_test.rb +29 -0
- data/test/unit/slug_test.rb +39 -0
- data/test/unit/ss_migration_test.rb +14 -0
- data/test/unit/terra_test.rb +125 -0
- data/test/unit/utils_test.rb +11 -0
- data/vendor/sinatra-sequel/.gitignore +3 -0
- data/vendor/sinatra-sequel/COPYING +18 -0
- data/vendor/sinatra-sequel/README.md +84 -0
- data/vendor/sinatra-sequel/Rakefile +67 -0
- data/vendor/sinatra-sequel/lib/sinatra/sequel.rb +73 -0
- data/vendor/sinatra-sequel/sinatra-sequel.gemspec +39 -0
- data/vendor/sinatra-sequel/spec/spec_sinatra_sequel.rb +70 -0
- metadata +536 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
-# Either parent or model will be given
|
2
|
+
- parent ||= nil
|
3
|
+
- model ||= nil
|
4
|
+
- items ||= nil
|
5
|
+
|
6
|
+
-# If home page
|
7
|
+
- unless items.nil?
|
8
|
+
%nav
|
9
|
+
%h3
|
10
|
+
%ul
|
11
|
+
- model.all.each do |item|
|
12
|
+
%li.browse
|
13
|
+
!= link_to item.path(:responses) do
|
14
|
+
!= admin_icon 'contact'
|
15
|
+
= item.to_s
|
16
|
+
|
17
|
+
%li.add
|
18
|
+
!= link_to model.path(:new) do
|
19
|
+
!= admin_icon('add')
|
20
|
+
= "New #{model.title.downcase}"
|
21
|
+
|
22
|
+
- else
|
23
|
+
|
24
|
+
!= admin_back_to_dashboard
|
25
|
+
|
26
|
+
%nav.crumbs
|
27
|
+
!= link_to parent.path(:responses) do
|
28
|
+
!= admin_icon 'contact'
|
29
|
+
= parent.to_s
|
30
|
+
|
31
|
+
%nav
|
32
|
+
%ul
|
33
|
+
%li
|
34
|
+
!= link_to parent.path(:edit) do
|
35
|
+
!= admin_icon 'generic'
|
36
|
+
= "Options"
|
37
|
+
|
38
|
+
%nav
|
39
|
+
%h3 Recent responses
|
40
|
+
%ul
|
41
|
+
%li.blank
|
42
|
+
No responses yet.
|
@@ -0,0 +1,20 @@
|
|
1
|
+
-# Inherit
|
2
|
+
!= partial :'base/edit', :item => item, :action => ''
|
3
|
+
|
4
|
+
- title "%s - Responses" % [ item.to_s ]
|
5
|
+
|
6
|
+
- content_for! :nav do
|
7
|
+
!= partial item, :nav, :parent => item, :model => item.class
|
8
|
+
|
9
|
+
- content_for! :title do
|
10
|
+
%h1
|
11
|
+
= item.to_s
|
12
|
+
%em Responses
|
13
|
+
|
14
|
+
- content_for! :toolbar do
|
15
|
+
!= ""
|
16
|
+
|
17
|
+
- content_for! :body do
|
18
|
+
.fixed
|
19
|
+
%div.dialog
|
20
|
+
There are no responses yet.
|
@@ -0,0 +1,66 @@
|
|
1
|
+
body { background: #7bd * 0.8; color: #eee; text-shadow: 1px 1px 0 $shadow10; }
|
2
|
+
|
3
|
+
#top,
|
4
|
+
#content { width: 760px; margin: 0 auto; }
|
5
|
+
|
6
|
+
#top {
|
7
|
+
border-bottom: solid 1px $hilite20; padding: 20px 0 10px 0; overflow: hidden;
|
8
|
+
|
9
|
+
h3 { margin: 0; padding: 0; float: left; }
|
10
|
+
h3 strong { display: block; color: #d8a; text-shadow: 1px 1px 0 $hilite20; }
|
11
|
+
h3 small { font-weight: normal; display: block; color: #cde; font-size: 8pt; }
|
12
|
+
|
13
|
+
nav {
|
14
|
+
float: right; margin-top: 10px;
|
15
|
+
ul { @include horiz-list; }
|
16
|
+
a {
|
17
|
+
display: block; margin-left: 12px; color: #adf * 1.2; padding: 1px 8px;
|
18
|
+
background: $hilite10;
|
19
|
+
@include border-radius(4px); @include shadow(1px 1px 0 $shadow10);
|
20
|
+
}
|
21
|
+
li.active a,
|
22
|
+
a:hover { background: #ddd; color: #333; text-shadow: 1px 1px 0 $shadow20; text-decoration: none; }
|
23
|
+
li a:hover { background: #eee; }
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
#content {
|
28
|
+
@include clearfix;
|
29
|
+
|
30
|
+
p { border-top: solid 1px $hilite20; padding-top: 10px; }
|
31
|
+
.back { width: 15%; float: left; }
|
32
|
+
.body { width: 50%; float: left; }
|
33
|
+
.nav { width: 30%; float: right; }
|
34
|
+
h1 { font-size: 23pt; margin: 50px 0 10px 0; }
|
35
|
+
h1.level-1 { font-size: 40pt; margin: 100px 0 30px 0; }
|
36
|
+
}
|
37
|
+
|
38
|
+
#content .back {
|
39
|
+
border-top: solid 1px $hilite20;
|
40
|
+
padding: 10px 0;
|
41
|
+
margin-top: 12px;
|
42
|
+
margin-right: 15px;
|
43
|
+
|
44
|
+
a {
|
45
|
+
color: #adf * 1.2; font-weight: normal;
|
46
|
+
span { display: block; font-size: 2em; margin: -3px 0 5px 0; }
|
47
|
+
&:hover { text-decoration: none; }
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
#content .crumbs {
|
52
|
+
border-bottom: solid 1px $hilite20;
|
53
|
+
|
54
|
+
ul { @include horiz-list; }
|
55
|
+
ul li:after { content: ' > '; float: left; display: block; padding: 10px 0; color: #7bd; }
|
56
|
+
a { padding: 10px; display: block; color: #adf * 1.2; float: left; font-weight: normal; }
|
57
|
+
ul li:first-child a { padding-left: 0; }
|
58
|
+
ul li:last-child:after { content: ''; }
|
59
|
+
ul li.active a { color: white; font-weight: bold; }
|
60
|
+
}
|
61
|
+
|
62
|
+
#content .nav {
|
63
|
+
ul { @include non-list; margin-top: 12px; }
|
64
|
+
a { border-top: solid 1px $hilite20; padding: 10px 0; color: #adf * 1.2; display: block; text-align: left; }
|
65
|
+
}
|
66
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
/* Reset */
|
2
|
+
div, dl, dt, dd, ul, ol, li, form, fieldset, input, blockquote, th, td, legend { margin: 0; padding: 0; }
|
3
|
+
|
4
|
+
#content {
|
5
|
+
pre, p, blockquote,
|
6
|
+
h1, h2, h3, h4, h5, h6 { margin: 1em 0 1em 0; }
|
7
|
+
blockquote { border-left: solid 2px #ccc; padding: 0 1em; margin-left: 0.2em; color: #888; }
|
8
|
+
h1 { font-size: 1.4em; }
|
9
|
+
h2 { font-size: 1.3em; }
|
10
|
+
h3 { font-size: 1.2em; }
|
11
|
+
h4 { font-size: 1.1em; }
|
12
|
+
h5 { font-size: 0.9em; }
|
13
|
+
h6 { font-size: 0.9em; }
|
14
|
+
ol, ul { margin-left: 2em; }
|
15
|
+
}
|
16
|
+
|
17
|
+
/* Body & wrapper */
|
18
|
+
html, body { margin: 0; padding: 0; }
|
19
|
+
body, td, input, textarea { font-family: arial, helvetica, sans-serif; font-size: 1em; }
|
20
|
+
body { font-size: 0.75em; line-height: 1.5; background: white; color: #333; }
|
21
|
+
#all { margin: 0 auto; width: auto; position: relative; }
|
22
|
+
|
23
|
+
input, textarea { line-height: 1.4; }
|
24
|
+
|
25
|
+
/* Links */
|
26
|
+
a { color: #379; text-decoration: none; font-weight: bold; padding: 1px; }
|
27
|
+
a:visited { color: #379; }
|
28
|
+
a:hover { color: #379; text-decoration: underline; }
|
29
|
+
a img { border: 0; }
|
30
|
+
|
31
|
+
button { cursor: pointer; }
|
32
|
+
|
33
|
+
/* HTML5 */
|
34
|
+
header, footer, aside, section, article, nav { display: block; }
|
Binary file
|
@@ -0,0 +1,32 @@
|
|
1
|
+
- layout 'layout'
|
2
|
+
- title item.to_s
|
3
|
+
|
4
|
+
#content
|
5
|
+
.crumbs
|
6
|
+
%ul
|
7
|
+
%li
|
8
|
+
%a{:href => '/'}!= "♥"
|
9
|
+
- item.crumbs.each do |p|
|
10
|
+
%li{:class => ('active' if @item == p)}
|
11
|
+
%a{:href => p.path}= p
|
12
|
+
|
13
|
+
%h1{:class => 'level-3' }
|
14
|
+
Porfolio:
|
15
|
+
= item.to_s
|
16
|
+
|
17
|
+
.back
|
18
|
+
- if item.parent?
|
19
|
+
%a{:href => item.parent.path}
|
20
|
+
%span!= "«"
|
21
|
+
Back to
|
22
|
+
%br
|
23
|
+
%strong= item.parent
|
24
|
+
|
25
|
+
.body
|
26
|
+
!= item.body if item.respond_to?(:body)
|
27
|
+
.nav
|
28
|
+
%ul
|
29
|
+
- item.children.each do |p|
|
30
|
+
- next unless p.try(:renderable?)
|
31
|
+
%li
|
32
|
+
%a{:href => p.path}= p
|
@@ -0,0 +1,31 @@
|
|
1
|
+
- layout 'layout'
|
2
|
+
- title item.to_s
|
3
|
+
|
4
|
+
#content
|
5
|
+
.crumbs
|
6
|
+
%ul
|
7
|
+
%li
|
8
|
+
%a{:href => '/'}!= "♥"
|
9
|
+
- item.crumbs.each do |p|
|
10
|
+
%li{:class => ('active' if @item == p)}
|
11
|
+
%a{:href => p.path}= p
|
12
|
+
|
13
|
+
%h1{:class => 'level-%i' % [ item.crumbs.size ] }
|
14
|
+
= item.to_s
|
15
|
+
|
16
|
+
.back
|
17
|
+
- if item.parent?
|
18
|
+
%a{:href => item.parent.path}
|
19
|
+
%span!= "«"
|
20
|
+
Back to
|
21
|
+
%br
|
22
|
+
%strong= item.parent
|
23
|
+
|
24
|
+
.body
|
25
|
+
!= html(item.body) if item.respond_to?(:body)
|
26
|
+
.nav
|
27
|
+
%ul
|
28
|
+
- item.submenu.each do |p|
|
29
|
+
- next unless p.try(:renderable?)
|
30
|
+
%li
|
31
|
+
%a{:href => p.path}= p.menu_title
|
@@ -0,0 +1,33 @@
|
|
1
|
+
!!! 5
|
2
|
+
%html{:class => browser.body_class}
|
3
|
+
%head
|
4
|
+
%meta(charset='UTF-8')
|
5
|
+
%title!= title ? "#{title} — Aura" : "Aura"
|
6
|
+
%link(rel='stylesheet' media='screen' type='text/css' href='/css/theme/reset.css')
|
7
|
+
%link(rel='stylesheet' media='screen' type='text/css' href='/css/theme/style.css')
|
8
|
+
|
9
|
+
- if @item.try(:meta_keywords)
|
10
|
+
%meta{:name => 'keywords', :value => @item.meta_keywords}
|
11
|
+
- if @item.try(:meta_description)
|
12
|
+
%meta{:name => 'description', :value => @item.meta_description}
|
13
|
+
|
14
|
+
%body{:class => body_class}
|
15
|
+
|
16
|
+
%header#top
|
17
|
+
%h3
|
18
|
+
%strong This is my site
|
19
|
+
%small Yes it is, and it's very very nice
|
20
|
+
|
21
|
+
%nav
|
22
|
+
%ul
|
23
|
+
- Aura.menu.each do |p|
|
24
|
+
- next unless p.try(:renderable?)
|
25
|
+
%li{:class => ('active' if !@item.nil? and @item.crumbs.include?(p))}
|
26
|
+
%a{:href => p.path}= p.menu_title
|
27
|
+
|
28
|
+
#all
|
29
|
+
- if content_for?(:content)
|
30
|
+
!= yield_content(:content)
|
31
|
+
!= yield
|
32
|
+
|
33
|
+
!= admin_watermark
|
data/lib/aura.rb
ADDED
@@ -0,0 +1,315 @@
|
|
1
|
+
ENV['AURA_ROOT'] ||= File.expand_path('../../', __FILE__)
|
2
|
+
|
3
|
+
if ENV['APP_FILE']
|
4
|
+
ENV['APP_ROOT'] ||= File.dirname(ENV['APP_FILE'])
|
5
|
+
else
|
6
|
+
ENV['APP_ROOT'] ||= ENV['AURA_ROOT']
|
7
|
+
ENV['APP_FILE'] ||= __FILE__
|
8
|
+
end
|
9
|
+
|
10
|
+
require "sequel"
|
11
|
+
|
12
|
+
# Class: Aura
|
13
|
+
# The main class.
|
14
|
+
#
|
15
|
+
# #### Paths
|
16
|
+
#
|
17
|
+
# Aura.root #=> "~/myapp/root"
|
18
|
+
# Aura.gem_root #=> "/usr/lib/ruby/gems.../aura-0.0.1"
|
19
|
+
#
|
20
|
+
# #### Files
|
21
|
+
#
|
22
|
+
# Aura.files['models/book.rb'] #=> "~/myapp/app/models/book.rb"
|
23
|
+
# Aura.files.glob('css/**/*') #=> #<Array>
|
24
|
+
#
|
25
|
+
# #### Settings
|
26
|
+
#
|
27
|
+
# Aura.set 'site.name', 'Othello'
|
28
|
+
# Aura.get('site.name') #=> "Othello"
|
29
|
+
#
|
30
|
+
# # Attempts to set the default site.name, but fails because it was
|
31
|
+
# # already set previously.
|
32
|
+
# Aura.default 'site.name', 'Talamasca'
|
33
|
+
# puts Aura.get('site.name').inspect
|
34
|
+
# #=> "Othello"
|
35
|
+
#
|
36
|
+
class Aura
|
37
|
+
PREFIX = File.dirname(__FILE__)
|
38
|
+
|
39
|
+
# Class method: gem_root (Aura)
|
40
|
+
# Usage: Aura.gem_root([args])
|
41
|
+
# Returns the root path of the Aura gem.
|
42
|
+
#
|
43
|
+
def self.gem_root(*a)
|
44
|
+
File.join(ENV['AURA_ROOT'], *a)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Class method: root (Aura)
|
48
|
+
# Usage: Aura.root([args])
|
49
|
+
# Returns the root path of the application.
|
50
|
+
#
|
51
|
+
# ## Example
|
52
|
+
# Aura.root #=> "~/myapp"
|
53
|
+
# Aura.root('init.rb') #=> "~/myapp/init.rb"
|
54
|
+
#
|
55
|
+
def self.root(*a)
|
56
|
+
File.join(ENV['APP_ROOT'], *a)
|
57
|
+
end
|
58
|
+
|
59
|
+
autoload :Extension, gem_root("lib/aura/extension")
|
60
|
+
autoload :ExtensionNotFound, gem_root("lib/aura/extension")
|
61
|
+
autoload :CLI, gem_root("lib/aura/cli")
|
62
|
+
autoload :Menu, gem_root("lib/aura/menu")
|
63
|
+
autoload :Models, gem_root("lib/aura/models")
|
64
|
+
autoload :Slugs, gem_root("lib/aura/slugs")
|
65
|
+
autoload :Subtype, gem_root("lib/aura/subtype")
|
66
|
+
autoload :Seeder, gem_root("lib/aura/seeder")
|
67
|
+
autoload :Utils, gem_root("lib/aura/utils")
|
68
|
+
autoload :Editor, gem_root("lib/aura/editor")
|
69
|
+
autoload :Public, gem_root("lib/aura/public")
|
70
|
+
autoload :Rendering, gem_root("lib/aura/rendering")
|
71
|
+
autoload :Files, gem_root("lib/aura/files")
|
72
|
+
autoload :Admin, gem_root("lib/aura/admin")
|
73
|
+
autoload :App, gem_root("app/main")
|
74
|
+
|
75
|
+
require "#{PREFIX}/aura/version"
|
76
|
+
|
77
|
+
# Alias for Setting.get.
|
78
|
+
# See Setting.get for an example.
|
79
|
+
def self.get(key)
|
80
|
+
Setting.get key
|
81
|
+
end
|
82
|
+
|
83
|
+
# Alias for Setting.set.
|
84
|
+
# See Setting.get for an example.
|
85
|
+
def self.set(key, value)
|
86
|
+
Setting.set key, value
|
87
|
+
end
|
88
|
+
|
89
|
+
# Alias for Setting.default.
|
90
|
+
# See Setting.get for an example.
|
91
|
+
def self.default(key, value)
|
92
|
+
Setting.default key, value
|
93
|
+
end
|
94
|
+
|
95
|
+
# Alias for Setting.delete.
|
96
|
+
# See Setting.get for an example.
|
97
|
+
def self.del(key)
|
98
|
+
Setting.del key
|
99
|
+
end
|
100
|
+
|
101
|
+
# Class method: db_dump (Aura)
|
102
|
+
# Returns the database backup as a hash.
|
103
|
+
#
|
104
|
+
# @see db_dump_yaml
|
105
|
+
#
|
106
|
+
# ## Example
|
107
|
+
#
|
108
|
+
# data = Aura.db_dump
|
109
|
+
# yml_data = YAML::dump(data) # also see db_dump_yaml.
|
110
|
+
# File.open('backup.yml', 'w') { |f| f << yml_data }
|
111
|
+
# puts yml_data.inspect
|
112
|
+
#
|
113
|
+
# # Sample output:
|
114
|
+
# # pages:
|
115
|
+
# # - title: Hello.
|
116
|
+
# # body: Good day everyone!
|
117
|
+
# # - title: Cheers!
|
118
|
+
# # body: What's going on?
|
119
|
+
# # settings:
|
120
|
+
# # - ...
|
121
|
+
#
|
122
|
+
def self.db_dump
|
123
|
+
db = models.all.first.db
|
124
|
+
|
125
|
+
models.all.inject({}) { |hash, model|
|
126
|
+
table = model.table_name
|
127
|
+
hash[table] = db[table].all
|
128
|
+
hash
|
129
|
+
}
|
130
|
+
end
|
131
|
+
|
132
|
+
# Class method: db_restore (Aura)
|
133
|
+
# Restores a previous output of db_dump.
|
134
|
+
#
|
135
|
+
# This function takes in the parameter `hash`, which is a hash table
|
136
|
+
# with the keys as the table names, and it's values are arrays of
|
137
|
+
# records.
|
138
|
+
#
|
139
|
+
# See #db_dump for an example of the hash that #db_restore expects.
|
140
|
+
#
|
141
|
+
# ## Example
|
142
|
+
#
|
143
|
+
# # Load a previously saved copy of the hash, as spitted out
|
144
|
+
# # by db_dump.
|
145
|
+
# yaml_data = YAML::load_file 'backup.yml'
|
146
|
+
#
|
147
|
+
# # Load it.
|
148
|
+
# Aura.db_restore(yaml_data)
|
149
|
+
#
|
150
|
+
def self.db_restore(hash)
|
151
|
+
# Hash format:
|
152
|
+
# { :table_name => [ array of hashes of rows ], ... }
|
153
|
+
|
154
|
+
# Bring the DB back to the state where we have tables ready.
|
155
|
+
Main.flush!
|
156
|
+
Aura.run_migrations!
|
157
|
+
db = models.all.first.db
|
158
|
+
|
159
|
+
hash.each do |table, entries|
|
160
|
+
entries.each do |entry|
|
161
|
+
db[table] << entry
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
# Class method: db_dump_yaml (Aura)
|
167
|
+
# Returns the database backup as a YAML document.
|
168
|
+
#
|
169
|
+
def self.db_dump_yaml
|
170
|
+
require 'yaml'
|
171
|
+
YAML::dump db_dump
|
172
|
+
end
|
173
|
+
|
174
|
+
# Class method: site_empty? (Aura)
|
175
|
+
# Checks if the site is empty.
|
176
|
+
#
|
177
|
+
# All content models are queried to see if there are any records available.
|
178
|
+
# Content models are determined by checking if the model classes respond
|
179
|
+
# #content? as `true`.
|
180
|
+
#
|
181
|
+
# ## Example
|
182
|
+
#
|
183
|
+
# if Aura.site_empty?
|
184
|
+
# page = Page.new :title => "Hello"
|
185
|
+
# page.save
|
186
|
+
# assert Aura.site_empty? == false
|
187
|
+
# end
|
188
|
+
#
|
189
|
+
def self.site_empty?
|
190
|
+
! models.all.select { |m| m.content? }.detect { |m| m.any? }
|
191
|
+
end
|
192
|
+
|
193
|
+
# Class method: find (Aura)
|
194
|
+
# Finds a record that corresponds to a path.
|
195
|
+
#
|
196
|
+
# ## Example
|
197
|
+
#
|
198
|
+
# products = Page.new :slug => 'products'
|
199
|
+
# products.save
|
200
|
+
#
|
201
|
+
# boots = Page.new :parent => 'products', :slug => 'boots'
|
202
|
+
# boots.save
|
203
|
+
#
|
204
|
+
# foo = Aura.find('/products/boots')
|
205
|
+
# assert foo == boots
|
206
|
+
#
|
207
|
+
def self.find(path)
|
208
|
+
Slugs.find path
|
209
|
+
end
|
210
|
+
|
211
|
+
# Class method: roots (Aura)
|
212
|
+
# Returns all model records without parents.
|
213
|
+
#
|
214
|
+
# Records are considered without parents when they respond to #parent
|
215
|
+
# with `nil`.
|
216
|
+
#
|
217
|
+
def self.roots
|
218
|
+
models.all.inject([]) { |a, m| a += m.roots.try(:all) }
|
219
|
+
end
|
220
|
+
|
221
|
+
# Class method: menu (Aura)
|
222
|
+
# Returns the menu items, sorted properly.
|
223
|
+
#
|
224
|
+
# ## Example
|
225
|
+
#
|
226
|
+
# - Aura.menu.each do |item|
|
227
|
+
# %li
|
228
|
+
# %a{:href => item.path}= item.menu_title
|
229
|
+
#
|
230
|
+
def self.menu
|
231
|
+
roots.select { |item| item.shown_in_menu? }.sort
|
232
|
+
end
|
233
|
+
|
234
|
+
# Class method: run_migrations! (Aura)
|
235
|
+
# Runs migrations for everything.
|
236
|
+
def self.run_migrations!
|
237
|
+
Aura.files.glob('migrations/**/*.rb').each { |f| load f }
|
238
|
+
|
239
|
+
# Reload models to ensure they get the right schemae.
|
240
|
+
Aura.models.reload!
|
241
|
+
end
|
242
|
+
|
243
|
+
# Class method: models (Aura)
|
244
|
+
# Returns a list of models.
|
245
|
+
#
|
246
|
+
# ## Description
|
247
|
+
# This returns a {Aura::Models} instance. See the class
|
248
|
+
# documentation for more info.
|
249
|
+
#
|
250
|
+
def self.models
|
251
|
+
Aura::Models.new
|
252
|
+
end
|
253
|
+
|
254
|
+
# Class method: slugs (Aura)
|
255
|
+
# Returns the Slugs module.
|
256
|
+
#
|
257
|
+
# ## Description
|
258
|
+
# Returns {Aura::Slugs} where you can access methods that
|
259
|
+
# deal with URL slugs.
|
260
|
+
#
|
261
|
+
# ## Example
|
262
|
+
# Aura.slugs.find('/boots')
|
263
|
+
#
|
264
|
+
def self.slugs
|
265
|
+
Slugs
|
266
|
+
end
|
267
|
+
|
268
|
+
# Class method: editor (Aura)
|
269
|
+
# Usage: Aura.editor
|
270
|
+
#
|
271
|
+
# Returns the Editor module.
|
272
|
+
#
|
273
|
+
# ## Description
|
274
|
+
# Returns {Aura::Editor} where you can access methods that
|
275
|
+
# deal with the editor.
|
276
|
+
#
|
277
|
+
# ## Example
|
278
|
+
# Aura.editor.roots
|
279
|
+
#
|
280
|
+
def self.editor
|
281
|
+
Editor
|
282
|
+
end
|
283
|
+
|
284
|
+
# Class method: files (Aura)
|
285
|
+
# Usage: Aura.files
|
286
|
+
#
|
287
|
+
# Returns the Files module.
|
288
|
+
#
|
289
|
+
# ## Description
|
290
|
+
# Returns {Aura::Files} where you can access methods that
|
291
|
+
# deal with files.
|
292
|
+
#
|
293
|
+
# ## Example
|
294
|
+
# Aura.files['models/page.rb']
|
295
|
+
#
|
296
|
+
def self.files
|
297
|
+
Files
|
298
|
+
end
|
299
|
+
|
300
|
+
# Class method: admin (Aura)
|
301
|
+
# Usage: Aura.admin
|
302
|
+
#
|
303
|
+
# Returns the Admin module.
|
304
|
+
#
|
305
|
+
# ## Description
|
306
|
+
# Returns {Aura::Admin} where you can access methods that
|
307
|
+
# deal with files.
|
308
|
+
#
|
309
|
+
# ## Example
|
310
|
+
# Aura.admin.menu
|
311
|
+
#
|
312
|
+
def self.admin
|
313
|
+
Admin
|
314
|
+
end
|
315
|
+
end
|