transit 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. data/Gemfile +24 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +1 -0
  4. data/Rakefile +2 -0
  5. data/app/assets/stylesheets/includes/_compat.scss +24 -0
  6. data/app/assets/stylesheets/includes/_defaults.scss +99 -0
  7. data/app/assets/stylesheets/includes/_global.scss +16 -0
  8. data/app/assets/stylesheets/includes/_imports.scss +27 -0
  9. data/app/assets/stylesheets/includes/_mixins.scss +38 -0
  10. data/app/assets/stylesheets/includes/_setup.scss +85 -0
  11. data/app/assets/stylesheets/layout.css.scss +29 -0
  12. data/app/assets/stylesheets/transit.css +3 -0
  13. data/app/controllers/application_controller.rb +5 -0
  14. data/app/controllers/transit/contexts_controller.rb +20 -0
  15. data/app/controllers/transit/index_controller.rb +7 -0
  16. data/app/controllers/transit/packages_controller.rb +64 -0
  17. data/app/controllers/transit/transit_controller.rb +4 -0
  18. data/app/helpers/routing_helpers.rb +7 -0
  19. data/app/models/audio.rb +4 -0
  20. data/app/models/package_asset.rb +11 -0
  21. data/app/models/text.rb +2 -0
  22. data/app/models/video.rb +8 -0
  23. data/app/views/contexts/_audio.html.erb +1 -0
  24. data/app/views/contexts/_text.html.erb +1 -0
  25. data/app/views/contexts/_video.html.erb +1 -0
  26. data/app/views/layouts/transit.html.erb +31 -0
  27. data/app/views/transit/index/index.html.erb +0 -0
  28. data/config/routes.rb +5 -0
  29. data/lib/transit/context.rb +28 -0
  30. data/lib/transit/errors/invalid_context.rb +6 -0
  31. data/lib/transit/helpers/controller_helpers.rb +40 -0
  32. data/lib/transit/helpers/model_helpers.rb +26 -0
  33. data/lib/transit/package/base.rb +49 -0
  34. data/lib/transit/package/page.rb +18 -0
  35. data/lib/transit/package/post.rb +43 -0
  36. data/lib/transit/package.rb +25 -0
  37. data/lib/transit/rails/engine.rb +22 -0
  38. data/lib/transit/rails/routing.rb +14 -0
  39. data/lib/transit/version.rb +3 -0
  40. data/lib/transit.rb +43 -0
  41. metadata +194 -0
data/Gemfile ADDED
@@ -0,0 +1,24 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "rails", "3.1.0.rc1"
4
+ gem "rspec-rails"
5
+ gem 'mongoid-rspec'
6
+ gem 'mongo', '~> 1.3'
7
+ gem 'bson_ext', '~> 1.3'
8
+ gem 'mongoid', '~> 2.0'
9
+ gem "devise", "~> 1.3"
10
+ gem "paperclip", "~> 2.3"
11
+ gem 'rack-raw-upload', '0.1.1'
12
+ gem 'will_paginate', '3.0.pre2'
13
+ gem "motr", '0.0.9'
14
+
15
+ group :test do
16
+ gem "mocha","0.9.12"
17
+ gem 'guard'
18
+ gem 'guard-rspec'
19
+ gem 'growl'
20
+ gem 'fabrication'
21
+ gem 'ffaker'
22
+ gem "capybara", ">= 0.4.0"
23
+ end
24
+
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2011 Brent Kirby / kurb media, llc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1 @@
1
+ = Transit
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,24 @@
1
+ /*
2
+ Include browser-specific css here. This file should be included in the main css file as well as ie.css.
3
+ This way PIE can apply itself to any css3 items that have been used.
4
+ add @import pie_option; to allow SASS to toggle it on for IE and off for everyone else.
5
+ */
6
+
7
+
8
+ ///////////////////////////////////////////////
9
+ // Setup buttons
10
+ ///////////////////////////////////////////////
11
+
12
+
13
+ @import "blueprint/buttons";
14
+ $blueprint-button-font-family: $blueprint-font-family;
15
+
16
+ a.button{ @include anchor-button; }
17
+ button.button{ @include button-button; }
18
+
19
+ .button{ @include border-radius(5px); @include pie_option; padding:0px 1.5em; margin:0px; text-decoration:none;
20
+ @include button-colors; @include button-active-colors; @include button-hover-colors;
21
+ &:hover{ }
22
+ &:active{ }
23
+ }
24
+ a.button, button.button{ @extend .button; }
@@ -0,0 +1,99 @@
1
+ /*
2
+ A few layout defaults. Sets up buttons, forms, flash/notification messages and reset. This file should only be
3
+ imported into the main css file.
4
+ */
5
+
6
+ // Reset
7
+ @import "blueprint/reset";
8
+
9
+ ///////////////////////////////////////////////
10
+ // Setup typography
11
+ ///////////////////////////////////////////////
12
+
13
+ @include blueprint-typography;
14
+
15
+ ///////////////////////////////////////////////
16
+ // Setup forms
17
+ ///////////////////////////////////////////////
18
+
19
+ form{ @include blueprint-form-borders;
20
+ @include blueprint-form-layout;
21
+
22
+ ol.split{ display:block; clear:both; margin:-.5em 0px; @include pie-clearfix;
23
+ li{
24
+ float:left;
25
+ margin:0px 1em 0px 0px;
26
+ vertical-align:middle;
27
+
28
+ label,
29
+ input[type=text],
30
+ input[type=password],
31
+ input[type=email]{ display:block; }
32
+ select{ margin:.75em 0px; }
33
+ }
34
+ }
35
+
36
+ ol{ list-style-type:none !important; margin:0px; padding:0px; padding-right:10px;
37
+ li{ padding:.5em 0px;
38
+ &.clear{ clear:both; }
39
+ &.buttons{ clear:both; padding:.25em 0px 0px 0px; }
40
+ &.inline label{ display:inline !important; }
41
+ &.multifield{
42
+ input, select{ display:inline !important; }
43
+ }
44
+
45
+ ol{ @extend ol.split; }
46
+ }
47
+
48
+ label{ display:block; }
49
+ }
50
+
51
+ ol.inline li.label{ display:inline !important; }
52
+ label abbr{ outline:none; border:none; color:red; }
53
+ input[type=text],
54
+ input[type=password],
55
+ input[type=email],
56
+ textarea{
57
+ @include border-radius(2px); padding:.65em;
58
+ &:focus{ outline:none; border-color:#333; }
59
+ }
60
+ select{ border-style:solid !important;
61
+ &:focus{ outline:none; }
62
+ }
63
+ select[multiple=multiple]{
64
+ @include border-radius(2px); border-color:#ccc;
65
+ }
66
+ input[type=checkbox],
67
+ input[type=radio]{
68
+ display:inline; margin-right:1em; vertical-align:baseline; width:auto; }
69
+
70
+ span.field_with_errors{ padding:0px; line-height:1; margin:0px; position:relative;
71
+ input[type=text],
72
+ input[type=password],
73
+ input[type=email],
74
+ textarea{
75
+ border:1px solid $error-border-color; background:$error-bg-color; margin-bottom:0px;
76
+ }
77
+ span.error_for_field{
78
+ line-height:.75em; font-size:.9em; font-style:italic; color:$error-color; display:block;
79
+ }
80
+ }
81
+ }
82
+
83
+
84
+ ////////////////////////////////////
85
+ // Notifications
86
+ ////////////////////////////////////
87
+ div.error, div.notice, div.success, div.alert{ padding: .8em; margin-bottom: 1em; border-width:.17em; border-style:solid; position:relative; }
88
+ .error, .alert { background-color:$error-bg-color; border-color:$error-border-color; color:$error-color; }
89
+ .notice { background-color:$info-bg-color; border-color:$info-border-color; color:$info-color; }
90
+ .success { background-color:$success-bg-color; border-color:$success-border-color; color:$success-color; }
91
+
92
+ /*div.flash_message{ @include border-radius(5px); background-repeat:no-repeat; background-position:10px 45%; padding-left:35px;
93
+ text-align:left;
94
+ span{ position:absolute; top:30%; right:1em; cursor:pointer; cursor:hand; }
95
+ }*/
96
+ div.flash_message{ position:fixed; top:0; left:0; height:40px; line-height:45px; font-size:1.3em; border-left:none; border-right:none; border-top:none;
97
+ width:100%; z-index:2000; padding:0 !important; text-align:center; border-bottom-width:2px; cursor:pointer; cursor:hand;
98
+ span{ font-size:.8em; font-style:italic; padding-left:1em; }
99
+ }
@@ -0,0 +1,16 @@
1
+ /*
2
+ Include this file within each SCSS file to have access to libraries and variables. By itself this import adds
3
+ no additional css so it can be included cleanly.
4
+ */
5
+
6
+ // Debug enables grids
7
+ $debug: false !default;
8
+ $cdn: "https://s3.amazonaws.com/cdn.kurbmedia.com/transit";
9
+
10
+ ////////////////////////////////////////////////
11
+ // Import libraries
12
+ ////////////////////////////////////////////////
13
+ @import "imports";
14
+ @import "setup";
15
+ @import "mixins";
16
+ ////////////////////////////////////////////////
@@ -0,0 +1,27 @@
1
+ /*
2
+ Sets up any compass/blueprint imports. This file adds no CSS and can be included in every file.
3
+ */
4
+
5
+ ////////////////////////////////////////////////
6
+ // Import Blueprint defaults
7
+ ////////////////////////////////////////////////
8
+ @import "blueprint/grid";
9
+ @import "blueprint/typography";
10
+ @import "blueprint/form";
11
+ @import "blueprint/interaction";
12
+ @import "blueprint/debug";
13
+
14
+ /////////////////////////////////////////////////
15
+ // Import CSS3 Goodness
16
+ /////////////////////////////////////////////////
17
+ @import "compass/utilities/sprites";
18
+ @import "compass/css3/text-shadow";
19
+ @import "compass/css3/box-shadow";
20
+ @import "compass/css3/border-radius";
21
+ @import "compass/css3/gradient";
22
+ @import "compass/css3/font-face";
23
+ @import "compass/css3/pie";
24
+ @import "compass/css3/opacity";
25
+ @import "compass/utilities/general/min";
26
+ @import "compass/utilities/lists";
27
+ @import "compass/typography/vertical_rhythm";
@@ -0,0 +1,38 @@
1
+ /*
2
+ Some useful mixins
3
+ */
4
+
5
+ @mixin pie_option{
6
+ @if $experimental-support-for-pie{ @include pie; }
7
+ }
8
+
9
+ @mixin gradient($start:$blue, $end:false, $darken:6%){
10
+ @if not $end{ $end:darken($start, $darken); }
11
+ @include background-image(linear-gradient($start, $end));
12
+ }
13
+
14
+
15
+ @mixin gradient($start:$blue, $end:false, $darken:6%){
16
+ @if not $end{ $end:darken($start, $darken); }
17
+ @include background-image(linear-gradient($start, $end));
18
+ }
19
+
20
+ // Creates CSS3 gradient buttons
21
+ @mixin gradient_button($start:$blue, $end:false, $darken:6%){
22
+ @if not $end{ $end:darken($start, $darken); }
23
+ @include gradient($start, $end, $darken); @include single-text-shadow(darken($end, ($darken*2)));
24
+ &:active{
25
+ background:darken($end, 10%) !important; @include single-text-shadow(darken($start, ($darken*2)));
26
+ }
27
+ &:hover{
28
+ $start:lighten($start, 7%);
29
+ $end:lighten($end, 7%);
30
+ @include gradient($start, $end, $darken); @include single-text-shadow(darken($end, ($darken*2)));
31
+ }
32
+ @include pie_option;
33
+ }
34
+
35
+ @mixin heading_font($bold:false){
36
+ @if $bold{ font-family:'1451DinerSemiBold'; }
37
+ @else{ font-family:'1451DinerRegular'; }
38
+ }
@@ -0,0 +1,85 @@
1
+ ////////////////////////////////////////////////
2
+ // Blueprint grid setup.
3
+ ////////////////////////////////////////////////
4
+
5
+ $blueprint-container-size: 970px;
6
+ $blueprint-grid-margin: 10px;
7
+ $blueprint-grid-width:30px;
8
+ //$blueprint-grid-columns: 24;
9
+ //$blueprint-container-size: 960px;
10
+ //$blueprint-grid-margin: 10px;
11
+ //$blueprint-grid-width: 30;//($blueprint-container-size + $blueprint-grid-margin) / $blueprint-grid-columns - $blueprint-grid-margin;
12
+
13
+ // Grid image generation
14
+ @import 'compass/layout/grid-background';
15
+ $grid-background-column-color:#eef2f9;
16
+ $grid-background-baseline-color:rgba(0,0,0,0.15);
17
+ $grid-background-gutter-color:#fff;
18
+ $grid-background-offset:10px;
19
+
20
+ ////////////////////////////////////////////////
21
+ // IE Support (enable in IE.scss)
22
+ ////////////////////////////////////////////////
23
+ $experimental-support-for-pie: false;
24
+ $legacy-support-for-ie6: false;
25
+
26
+ ////////////////////////////////////////////////
27
+ // CSS3 Text Shadow
28
+ ////////////////////////////////////////////////
29
+ $default-text-shadow-color: black;
30
+ $default-text-shadow-h-offset: 1px;
31
+ $default-text-shadow-v-offset: 1px;
32
+ $default-text-shadow-blur: 1px;
33
+ $default-border-radius: 10px;
34
+
35
+ ////////////////////////////////////////////////
36
+ // Blueprint typography setup.
37
+ ////////////////////////////////////////////////
38
+ $font-color: #333333;
39
+ $blue:#2a8ebf !default;
40
+ $red:#e64a13;
41
+ $ltblue:lighten($blue, 20%);
42
+ $darkblue:darken($blue, 20%);
43
+ $blue_tint:lighten($ltblue, 20%);
44
+
45
+ // Links
46
+ $link-color: $blue;
47
+ $link-hover-color: lighten($blue, 20%);
48
+ $link-focus-color: $link-hover-color;
49
+ $link-active-color: $red;
50
+ $link-visited-color: darken($link-color, 10%);
51
+
52
+ // Notifications
53
+ $feedback-border-color: #dddddd;
54
+ $success-color: #3e5a3d;
55
+ $success-bg-color: #ddf5c4;
56
+ $success-border-color: #a7da74;
57
+ $notice-color: #514721;
58
+ $notice-bg-color: #fff6bf;
59
+ $notice-border-color: #ffd324;
60
+ $info-color: #be9109;
61
+ $info-bg-color: #fbf1d2;
62
+ $info-border-color: #ffcc33;
63
+ $error-color: #bd132a;
64
+ $error-bg-color: #fde0e4;
65
+ $error-border-color: #E41D38;
66
+
67
+ ////////////////////////////////////////////////
68
+ // Blueprint table setup.
69
+ ////////////////////////////////////////////////
70
+ $blueprint-table-header-color: #c3d9ff;
71
+ $blueprint-table-stripe-color: #e5ecf9;
72
+
73
+ ////////////////////////////////////////////////
74
+ // Blueprint button setup.
75
+ ////////////////////////////////////////////////
76
+ $blueprint-button-font-family:$blueprint-font-family;
77
+ $blueprint-button-background-color:#333;
78
+ $blueprint-button-border-color:darken($blueprint-button-background-color, 10%);
79
+ $blueprint-button-font-color:#fff;
80
+ $blueprint-button-hover-background-color:#555;
81
+ $blueprint-button-hover-border-color:darken($blueprint-button-hover-background-color, 10%);
82
+ $blueprint-button-hover-font-color:$blueprint-button-font-color;
83
+ $blueprint-button-active-background-color:#444;
84
+ $blueprint-button-active-border-color:darken($blueprint-button-active-background-color, 10%);
85
+ $blueprint-button-active-font-color:white;
@@ -0,0 +1,29 @@
1
+ @import 'includes/global';
2
+ @import 'includes/compat';
3
+ @import 'includes/defaults';
4
+ $debug: false;
5
+ $grid-background-baseline-height:18px;
6
+ @if($debug){
7
+ #wrapper{ @include grid-background; }
8
+ }@else{ #maincontent{ background:white; } }
9
+
10
+ $base-font-size:$blueprint-font-size;
11
+ $base-line-height:18px;
12
+
13
+ @include establish-baseline;
14
+ html{ background:#333 url("#{$cdn}/footer.png"); }
15
+ body{ border-top:5px solid #333; background:white url('#{$cdn}/top.png') 0px -173px repeat-x; }
16
+ #wrapper{ @include container; @include min-height(400px); position:relative; }
17
+ #homelink{ display:block; width:200px; height:35px; text-indent:-9999em; background:url("#{$cdn}/logo_white.png") no-repeat;
18
+ position:relative; top:rhythm(1);
19
+ }
20
+ #headline{ position:absolute; top:1.75em; right:0; color:white; @include heading_font(true); font-size:1.25em; @include single-text-shadow($darkblue); }
21
+
22
+ #footer{ background:#333 url("#{$cdn}/footer.png"); padding:2em 0; border-top:5px solid #212121;
23
+ div{ @include container; color:white; }
24
+ p.current_date{ font-size:3.5em; text-align:center; width:75px; height:70px; color:#ccc; @include single-text-shadow(black); text-transform:uppercase;
25
+ line-height:1; font-weight:bold; position:relative; padding:.25em 0; background:transparentize(#444, 0.5);
26
+ span{ display:block; font-size:.4em; }
27
+ strong{ font-size:.2em; display:block; width:100%; padding-top:.25em; }
28
+ }
29
+ }
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require layout
3
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ def ensure_authenticated!
3
+ true
4
+ end
5
+ end
@@ -0,0 +1,20 @@
1
+ class Transit::ContextsController < Transit::TransitController
2
+ include Transit::Helpers::ControllerHelpers
3
+ unloadable
4
+ respond_to :js
5
+
6
+ def new
7
+ @package = scope_class.find(params["#{scope_name}"])
8
+ @context = params[:type].classify.constantize.new
9
+ respond_with(@context)
10
+ end
11
+
12
+ def destroy
13
+ @package = scope_class.find(params["#{scope_name}"])
14
+ @context = scope_class.find(params[:id])
15
+ @field.destroy
16
+ flash[:success] = "The selected field has been removed."
17
+ respond_with(@field)
18
+ end
19
+
20
+ end
@@ -0,0 +1,7 @@
1
+ class Transit::IndexController < Transit::TransitController
2
+ unloadable
3
+
4
+ def index
5
+ end
6
+
7
+ end
@@ -0,0 +1,64 @@
1
+ class Transit::PackagesController < Transit::TransitController
2
+ include Transit::Helpers::ControllerHelpers
3
+ unloadable
4
+
5
+ respond_to :html, :js
6
+
7
+ def index
8
+ @packages = scope_class.all
9
+ set_instance_var(@packages)
10
+ respond_with(get_instance_var) do |format|
11
+ format.js{ render :partial => 'table' }
12
+ format.any
13
+ end
14
+ end
15
+
16
+ def show
17
+ @package = scope_class.find(params[:id])
18
+ set_instance_var(@package)
19
+ respond_with(get_instance_var)
20
+ end
21
+
22
+ def new
23
+ @package = scope_class.new
24
+ set_instance_var(@package)
25
+ respond_with(get_instance_var)
26
+ end
27
+
28
+ def create
29
+ @package = scope_class.new(params["#{scope_name}"])
30
+ unless @package.save
31
+ flash.now[:error] = "Oops! Looks like you missed a couple fields."
32
+ render :action => :new and return
33
+ end
34
+ set_instance_var(@package)
35
+ flash[:success] = "'#{package.title}' has been created."
36
+ respond_with(get_instance_var, :location => edit_polymorphic_path(@package))
37
+ end
38
+
39
+ def edit
40
+ @package = scope_class.find(params[:id])
41
+ set_instance_var(@package)
42
+ respond_with(@package)
43
+ end
44
+
45
+ def update
46
+ @package = scope_class.find(params[:id])
47
+ unless @package.update_attributes(params["#{scope_name}"])
48
+ flash.now[:error] = "Looks like you were missing a few fields!"
49
+ render :action => :edit and return
50
+ end
51
+ flash[:success] = "'#{@package.title}' has been updated."
52
+ set_instance_var(@package)
53
+ respond_with(get_instance_var, :location => edit_polymorphic_path(@package))
54
+ end
55
+
56
+ def destroy
57
+ @package = scope_class.find(params[:id])
58
+ @package.destroy
59
+ set_instance_var(@package)
60
+ flash[:success] = "'#{@package.title}' has been deleted."
61
+ respond_with(get_instance_var, :location => polymorphic_path(@package))
62
+ end
63
+
64
+ end
@@ -0,0 +1,4 @@
1
+ class Transit::TransitController < ApplicationController
2
+ unloadable
3
+ layout 'transit'
4
+ end
@@ -0,0 +1,7 @@
1
+ module RoutingHelpers
2
+ unloadable
3
+
4
+ def packages_path
5
+ puts "adlaskdsldkad"
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ class Audio < Transit::Context
2
+ alias_attribute :source, :body
3
+
4
+ end
@@ -0,0 +1,11 @@
1
+ class PackageAsset
2
+
3
+ include Mongoid::Document
4
+ include Mongoid::Timestamps
5
+
6
+ field :name, :type => String
7
+ field :meta, :type => Hash
8
+
9
+ has_and_belongs_to_many :packages, polymorphic: true
10
+
11
+ end
@@ -0,0 +1,2 @@
1
+ class Text < Transit::Context
2
+ end
@@ -0,0 +1,8 @@
1
+ class Video < Transit::Context
2
+ alias_attribute :source, :body
3
+
4
+ def self.sources
5
+ ['Uploaded Video', 'YouTube', 'Vimeo', 'Ted'].collect{ |src| [src, src.underscore ] }
6
+ end
7
+
8
+ end
@@ -0,0 +1 @@
1
+ <%= content_tag(:div, "", :data => { audio_source: context.body, id: "audio_player_#{context.id}" }, :class => 'audio_player') %>
@@ -0,0 +1 @@
1
+ <%= context.body.html_safe %>
@@ -0,0 +1 @@
1
+ <%= content_tag(:div, "", :data => { video_source: context.body, id: "video_player_#{context.id}" }, :class => 'video_player') %>
@@ -0,0 +1,31 @@
1
+ <!DOCTYPE html>
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
5
+ <title><%= page_title %></title>
6
+ <meta name="keywords" content=""/>
7
+ <meta name="description" content=""/>
8
+ <link rel="stylesheet" href="https://s3.amazonaws.com/cdn.kurbmedia.com/assets/fonts.css" type="text/css" media="screen" charset="utf-8" />
9
+ <%= stylesheet_link_tag 'transit' %>
10
+ <!--[if lte IE 8]>
11
+ <![endif]-->
12
+ <!--[if IE 8]>
13
+ <![endif]-->
14
+ </head>
15
+ <body>
16
+ <div id="wrapper">
17
+ <%= link_to 'Return home', root_path, :id => 'homelink' %>
18
+ <span id="headline">transit v<%= Transit::VERSION %></span>
19
+ <%= yield %>
20
+ </div>
21
+ <div id="footer">
22
+ <div>
23
+ <p class='current_date'>
24
+ <span><%= Date.today.strftime('%b') %></span>
25
+ <%= Date.today.strftime('%d') %>
26
+ <strong><%= Date.today.strftime('%A') %></strong>
27
+ </p>
28
+ </div>
29
+ </div>
30
+ </body>
31
+ </html>
File without changes
data/config/routes.rb ADDED
@@ -0,0 +1,5 @@
1
+ Transit::Engine.routes.draw do
2
+ match "packages/:scope_name/:scope_id/contexts/new" => 'contexts#new', :as => :new_package_context, :via => [:get]
3
+ match "packages/:scope_name/:scope_id/contexts/:id" => 'contexts#destroy', :as => :package_context, :via => [:delete]
4
+ root :to => 'index#index'
5
+ end
@@ -0,0 +1,28 @@
1
+ module Transit
2
+ class Context
3
+ include Mongoid::Document
4
+ field :name, :type => String
5
+ field :meta, :type => Hash, :default => {}
6
+ field :body, :type => String
7
+ field :position, :type => Integer
8
+
9
+ before_save :ensure_context_position_value
10
+ embedded_in :package, polymorphic: true
11
+
12
+ def ensure_context_position_value
13
+ return true unless self.position.nil?
14
+ self.position = _parent.send(:contexts).count + 1
15
+ end
16
+
17
+ # Sets up an "identifier" for the particular context
18
+ def shortname
19
+ self.class.to_s.underscore
20
+ end
21
+
22
+ # Sets up a default name field to be used in form helpers
23
+ def field_name
24
+ (self.name.to_s.blank? ? self.class.to_s : self.name)
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,6 @@
1
+ module Transit
2
+ module Errors
3
+ class InvalidContext < StandardError
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,40 @@
1
+ module Transit
2
+ module Helpers
3
+
4
+ module ControllerHelpers
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ helper_method :scope_name, :scope_class, :resource, :collection
9
+ end
10
+
11
+ def scope_name
12
+ (action_name.to_s === 'index' ? scope_class.to_s.pluralize : scope_class.to_s).underscore
13
+ end
14
+
15
+ def scope_class
16
+ return @_scope_class unless @_scope_class.nil?
17
+ @_scope_class = self.class.to_s.split("::").last.gsub(/controller/i, '').singularize.constantize
18
+ end
19
+
20
+ def collection
21
+ [get_instance_var].flatten
22
+ end
23
+
24
+ def resource
25
+ get_instance_var
26
+ end
27
+
28
+ private
29
+
30
+ def get_instance_var
31
+ instance_variable_get("@#{scope_name}")
32
+ end
33
+
34
+ def set_instance_var(obj)
35
+ instance_variable_set("@#{scope_name}", obj)
36
+ end
37
+
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,26 @@
1
+ module Transit
2
+ module Helpers
3
+
4
+ module ModelHelpers
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ field :uid, :type => Integer
9
+ # Increment the sql_id each time to have a sql (auto_increment) style id for each post.
10
+ before_create :generate_uid, :on => :create
11
+ end
12
+
13
+ def generate_uid
14
+ return true unless self.uid.nil?
15
+ ref = self.class.collection.name.singularize.classify.constantize
16
+ self.uid = ref.max(:uid).to_i + 1
17
+ end
18
+
19
+ def timestamp
20
+ return "" if self.created_at.nil?
21
+ self.created_at.strftime("%B %d, %Y")
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,49 @@
1
+ module Transit
2
+ module Package
3
+
4
+ module Base
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ class_attribute :transit_config, :instance_writer => false
9
+ self.transit_config ||= {}
10
+
11
+ include Mongoid::Timestamps
12
+ include Mongoid::MultiParameterAttributes
13
+ include Transit::Helpers::ModelHelpers
14
+
15
+ field :published, :type => Boolean, :default => false
16
+
17
+ embeds_many :contexts, as: :package, class_name: 'Transit::Context'
18
+ accepts_nested_attributes_for :contexts, :allow_destroy => true
19
+ alias :contexts_attributes= :process_context_attributes=
20
+ end
21
+
22
+ def process_context_attributes=(hash)
23
+ hash.each_pair do |pos, attrs|
24
+ attrs.stringify_keys!
25
+ field = self.contexts.all.detect{ |cf| cf.id.to_s == attrs['id'] } || self.contexts.build({ }, attrs['_type'].classify.constantize)
26
+ field.attributes = attrs
27
+ end
28
+ end
29
+
30
+ module ClassMethods
31
+
32
+ def configure_transit_package!
33
+ conf = self.transit_config
34
+
35
+ if add_assets = conf[:assets]
36
+ has_and_belongs_to_many :package_assets, as: :package if add_assets
37
+ end
38
+ unless conf.key?(:controller) && conf[:controller] === false
39
+ Transit.add_controller(self)
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+
46
+ end
47
+
48
+ end
49
+ end
@@ -0,0 +1,18 @@
1
+ module Transit
2
+ module Package
3
+
4
+ module Page
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ field :name, :type => String
9
+ field :url, :type => String
10
+ field :keywords, :type => Array
11
+ field :description, :type => String
12
+
13
+ scope :published, where(:published => true)
14
+ end
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,43 @@
1
+ module Transit
2
+ module Package
3
+
4
+ module Post
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+
9
+ field :title, :type => String
10
+ field :post_date, :type => Date
11
+ field :slug, :type => String
12
+ field :teaser, :type => String
13
+
14
+ validates :title, :presence => true
15
+ validates :slug, :presence => { :allow_blank => false },
16
+ :uniqueness => { :scope => :_type, :message => "A post already exists with this exact title." }
17
+
18
+ scope :published, where(:published => true, :post_date.lte => Date.today)
19
+ modded_with :sluggable, :fields => :title, :as => :slug
20
+ alias :timestamp_method :post_date
21
+ end
22
+
23
+ # Grab the previous post for a previous > next link list
24
+ #
25
+ def previous_post
26
+ @previous_post ||= self.class.only(:title, :slug).where(:post_date.lt => self.post_date).descending(:post_date).first
27
+ end
28
+
29
+ # Grab the next post for a previous > next link list
30
+ #
31
+ def next_post
32
+ @next_post ||= self.class.only(:title, :slug).where(:post_date.gt => self.post_date).ascending(:post_date).first
33
+ end
34
+
35
+ def timestamp
36
+ return "" if self.post_date.nil?
37
+ self.post_date.strftime("%B %d, %Y")
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,25 @@
1
+ module Transit
2
+ module Package
3
+ autoload :Base, 'transit/package/base'
4
+ autoload :Post, 'transit/package/post'
5
+ autoload :Page, 'transit/package/page'
6
+
7
+ module Hook
8
+ def transit(template, options = {})
9
+
10
+ include Transit::Package::Base
11
+ self.transit_config.merge!(options)
12
+ configure_transit_package!
13
+
14
+ include Transit::Package.const_get(template.to_s.classify)
15
+ Transit.track(self, template.to_sym)
16
+
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+
23
+ Mongoid::Document::ClassMethods.class_eval do
24
+ include Transit::Package::Hook
25
+ end
@@ -0,0 +1,22 @@
1
+ require 'rails'
2
+ require 'transit'
3
+
4
+ module Transit
5
+ class Engine < Rails::Engine
6
+ isolate_namespace Transit
7
+
8
+ ActiveSupport.on_load(:after_initialize) do
9
+ Transit::CONTROLLERS.dup.uniq.each do |klass|
10
+ controller_klass = "#{klass.classify.pluralize}Controller"
11
+ unless Transit.const_defined?(controller_klass)
12
+ Transit.const_set(controller_klass, Class.new(Transit::PackagesController))
13
+ end
14
+ end
15
+ end
16
+
17
+ ActiveSupport.on_load(:action_controller) do
18
+ helper Transit::Engine.helpers
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,14 @@
1
+ module ActionDispatch::Routing
2
+ class Mapper
3
+ def transit(*models)
4
+ options = models.extract_options!
5
+ Transit::Engine.routes.draw do
6
+ models.map(&:to_s).map(&:pluralize).each do |mod|
7
+ resources mod, :controller => "#{mod}"
8
+ end
9
+ end
10
+ mount Transit::Engine => (options[:mount_on] || "/transit")
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module Transit
2
+ VERSION = "0.0.1"
3
+ end
data/lib/transit.rb ADDED
@@ -0,0 +1,43 @@
1
+ require 'rails'
2
+ require 'active_support'
3
+ require 'mongoid'
4
+
5
+ module Transit
6
+
7
+ autoload :Package, 'transit/package'
8
+ autoload :Context, 'transit/context'
9
+
10
+ module Helpers
11
+ autoload :ControllerHelpers, 'transit/helpers/controller_helpers'
12
+ autoload :ModelHelpers, 'transit/helpers/model_helpers'
13
+ end
14
+
15
+ module Errors
16
+ autoload :InvalidContext, 'transit/errors/invalid_context'
17
+ end
18
+
19
+ DESCRIPTIONS = {}
20
+ CONTROLLERS = []
21
+
22
+ def self.add_controller(klass)
23
+ CONTROLLERS << klass.to_s.classify.pluralize
24
+ end
25
+
26
+ def self.contexts
27
+ Transit::Context.subclasses.map(&:to_s).uniq
28
+ end
29
+
30
+ def self.track(klass, template)
31
+ DESCRIPTIONS[template] ||= []
32
+ DESCRIPTIONS[template] |= [klass.to_s]
33
+ end
34
+
35
+ def self.lookup(template)
36
+ DESCRIPTIONS[template] ||= []
37
+ end
38
+
39
+ end
40
+
41
+ require 'transit/package'
42
+ require 'transit/rails/engine'
43
+ require 'transit/rails/routing'
metadata ADDED
@@ -0,0 +1,194 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: transit
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Brent Kirby / kurb media llc
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-05-26 00:00:00 -04:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: mocha
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - "="
23
+ - !ruby/object:Gem::Version
24
+ version: 0.9.12
25
+ type: :development
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: capybara
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - "="
34
+ - !ruby/object:Gem::Version
35
+ version: 0.4.0
36
+ type: :development
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: fabrication
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: 0.9.5
47
+ type: :development
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: ffaker
51
+ prerelease: false
52
+ requirement: &id004 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ version: "1.7"
58
+ type: :development
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: mongoid
62
+ prerelease: false
63
+ requirement: &id005 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: "2.0"
69
+ type: :development
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: mongo
73
+ prerelease: false
74
+ requirement: &id006 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ version: "1.3"
80
+ type: :development
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: bson_ext
84
+ prerelease: false
85
+ requirement: &id007 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: "1.3"
91
+ type: :development
92
+ version_requirements: *id007
93
+ - !ruby/object:Gem::Dependency
94
+ name: nokogiri
95
+ prerelease: false
96
+ requirement: &id008 !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: "1.4"
102
+ type: :runtime
103
+ version_requirements: *id008
104
+ - !ruby/object:Gem::Dependency
105
+ name: motr
106
+ prerelease: false
107
+ requirement: &id009 !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 0.0.9
113
+ type: :runtime
114
+ version_requirements: *id009
115
+ description: Transit is a content management and delivery engine designed for use with Rails 3.1+ MongoDB and Mongoid
116
+ email:
117
+ - dev@kurbmedia.com
118
+ executables: []
119
+
120
+ extensions: []
121
+
122
+ extra_rdoc_files: []
123
+
124
+ files:
125
+ - app/assets/stylesheets/includes/_compat.scss
126
+ - app/assets/stylesheets/includes/_defaults.scss
127
+ - app/assets/stylesheets/includes/_global.scss
128
+ - app/assets/stylesheets/includes/_imports.scss
129
+ - app/assets/stylesheets/includes/_mixins.scss
130
+ - app/assets/stylesheets/includes/_setup.scss
131
+ - app/assets/stylesheets/layout.css.scss
132
+ - app/assets/stylesheets/transit.css
133
+ - app/controllers/application_controller.rb
134
+ - app/controllers/transit/contexts_controller.rb
135
+ - app/controllers/transit/index_controller.rb
136
+ - app/controllers/transit/packages_controller.rb
137
+ - app/controllers/transit/transit_controller.rb
138
+ - app/helpers/routing_helpers.rb
139
+ - app/models/audio.rb
140
+ - app/models/package_asset.rb
141
+ - app/models/text.rb
142
+ - app/models/video.rb
143
+ - app/views/contexts/_audio.html.erb
144
+ - app/views/contexts/_text.html.erb
145
+ - app/views/contexts/_video.html.erb
146
+ - app/views/layouts/transit.html.erb
147
+ - app/views/transit/index/index.html.erb
148
+ - lib/transit/context.rb
149
+ - lib/transit/errors/invalid_context.rb
150
+ - lib/transit/helpers/controller_helpers.rb
151
+ - lib/transit/helpers/model_helpers.rb
152
+ - lib/transit/package/base.rb
153
+ - lib/transit/package/page.rb
154
+ - lib/transit/package/post.rb
155
+ - lib/transit/package.rb
156
+ - lib/transit/rails/engine.rb
157
+ - lib/transit/rails/routing.rb
158
+ - lib/transit/version.rb
159
+ - lib/transit.rb
160
+ - config/routes.rb
161
+ - MIT-LICENSE
162
+ - Rakefile
163
+ - Gemfile
164
+ - README.rdoc
165
+ has_rdoc: true
166
+ homepage: https://github.com/kurbmedia/transit
167
+ licenses: []
168
+
169
+ post_install_message:
170
+ rdoc_options: []
171
+
172
+ require_paths:
173
+ - lib
174
+ required_ruby_version: !ruby/object:Gem::Requirement
175
+ none: false
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: "0"
180
+ required_rubygems_version: !ruby/object:Gem::Requirement
181
+ none: false
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ version: "0"
186
+ requirements: []
187
+
188
+ rubyforge_project: transit
189
+ rubygems_version: 1.6.2
190
+ signing_key:
191
+ specification_version: 3
192
+ summary: Transit is a Rails 3.1+ MongoDB/Mongoid based content management engine
193
+ test_files: []
194
+