a4nt 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +40 -0
  4. data/app/assets/javascripts/a4nt/announcements.js +2 -0
  5. data/app/assets/javascripts/a4nt/application.js +15 -0
  6. data/app/assets/stylesheets/a4nt/announcements.css +4 -0
  7. data/app/assets/stylesheets/a4nt/application.css +13 -0
  8. data/app/assets/stylesheets/scaffold.css +56 -0
  9. data/app/controllers/a4nt/announcements_controller.rb +87 -0
  10. data/app/controllers/a4nt/application_controller.rb +4 -0
  11. data/app/helpers/a4nt/announcements_helper.rb +4 -0
  12. data/app/helpers/a4nt/application_helper.rb +4 -0
  13. data/app/models/a4nt/announcement.rb +7 -0
  14. data/app/views/a4nt/announcements/_form.html.erb +37 -0
  15. data/app/views/a4nt/announcements/edit.html.erb +6 -0
  16. data/app/views/a4nt/announcements/index.html.erb +31 -0
  17. data/app/views/a4nt/announcements/new.html.erb +5 -0
  18. data/app/views/a4nt/announcements/show.html.erb +30 -0
  19. data/app/views/layouts/a4nt/application.html.erb +14 -0
  20. data/config/routes.rb +5 -0
  21. data/db/migrate/20130314151144_create_a4nt_announcements.rb +13 -0
  22. data/lib/a4nt.rb +4 -0
  23. data/lib/a4nt/engine.rb +5 -0
  24. data/lib/a4nt/version.rb +3 -0
  25. data/lib/tasks/a4nt_tasks.rake +4 -0
  26. data/test/a4nt_test.rb +7 -0
  27. data/test/dummy/README.rdoc +261 -0
  28. data/test/dummy/Rakefile +7 -0
  29. data/test/dummy/app/assets/javascripts/application.js +15 -0
  30. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  31. data/test/dummy/app/controllers/application_controller.rb +3 -0
  32. data/test/dummy/app/helpers/application_helper.rb +2 -0
  33. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  34. data/test/dummy/config.ru +4 -0
  35. data/test/dummy/config/application.rb +59 -0
  36. data/test/dummy/config/boot.rb +10 -0
  37. data/test/dummy/config/database.yml +25 -0
  38. data/test/dummy/config/environment.rb +5 -0
  39. data/test/dummy/config/environments/development.rb +37 -0
  40. data/test/dummy/config/environments/production.rb +67 -0
  41. data/test/dummy/config/environments/test.rb +37 -0
  42. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  43. data/test/dummy/config/initializers/inflections.rb +15 -0
  44. data/test/dummy/config/initializers/mime_types.rb +5 -0
  45. data/test/dummy/config/initializers/secret_token.rb +7 -0
  46. data/test/dummy/config/initializers/session_store.rb +8 -0
  47. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  48. data/test/dummy/config/locales/en.yml +5 -0
  49. data/test/dummy/config/routes.rb +4 -0
  50. data/test/dummy/db/development.sqlite3 +0 -0
  51. data/test/dummy/db/schema.rb +26 -0
  52. data/test/dummy/log/development.log +543 -0
  53. data/test/dummy/public/404.html +26 -0
  54. data/test/dummy/public/422.html +26 -0
  55. data/test/dummy/public/500.html +25 -0
  56. data/test/dummy/public/favicon.ico +0 -0
  57. data/test/dummy/script/rails +6 -0
  58. data/test/dummy/tmp/cache/assets/C74/D00/sprockets%2F35a3e1d53221b566385d55604b1f2f81 +0 -0
  59. data/test/dummy/tmp/cache/assets/CD0/410/sprockets%2F4610e3716682bd81225d1af060dec17e +0 -0
  60. data/test/dummy/tmp/cache/assets/CD1/7A0/sprockets%2F1c8986854dbe744776f98066ddea5148 +0 -0
  61. data/test/dummy/tmp/cache/assets/D68/870/sprockets%2F00945d57ebe03c366903bdea3f280fdd +0 -0
  62. data/test/dummy/tmp/cache/assets/D98/1A0/sprockets%2F21fba9c5cba0584b66f4a9f314abe196 +0 -0
  63. data/test/dummy/tmp/cache/assets/DA4/5F0/sprockets%2Fea2842a158fbf3838d6c08ccceee4833 +0 -0
  64. data/test/dummy/tmp/cache/assets/DA5/880/sprockets%2F933c4e72c3d556f7f7225ddbde1d1c7e +0 -0
  65. data/test/dummy/tmp/cache/assets/DAA/E90/sprockets%2Fdc903ff3b8bd770c927bcb4e7bb48387 +0 -0
  66. data/test/dummy/tmp/cache/assets/DC0/880/sprockets%2Fc14ba2e3509e7ab8b1a33d276ed4d5dc +0 -0
  67. data/test/dummy/tmp/cache/assets/DCF/230/sprockets%2F1748fda09da1ed4f51ad565fc7df5a52 +0 -0
  68. data/test/dummy/tmp/cache/assets/E16/A70/sprockets%2Fd3cc19a7697edd9efe18d8f92f0efe30 +0 -0
  69. data/test/dummy/tmp/cache/assets/E39/E90/sprockets%2Fe9e458ddec5a8f3dcbe083bf77b923ab +0 -0
  70. data/test/dummy/tmp/cache/assets/E95/420/sprockets%2Fd6ce1bdc5f9e8e55a7dae3b2fcf82ed2 +0 -0
  71. data/test/dummy/tmp/cache/assets/EC3/660/sprockets%2F6dfdc90eece35f8b7e00fdd21b9ecfcd +0 -0
  72. data/test/fixtures/a4nt/announcements.yml +15 -0
  73. data/test/functional/a4nt/announcements_controller_test.rb +51 -0
  74. data/test/integration/navigation_test.rb +10 -0
  75. data/test/test_helper.rb +15 -0
  76. data/test/unit/a4nt/announcement_test.rb +9 -0
  77. data/test/unit/helpers/a4nt/announcements_helper_test.rb +6 -0
  78. metadata +212 -0
@@ -0,0 +1,20 @@
1
+ Copyright 2013 YOURNAME
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.
@@ -0,0 +1,3 @@
1
+ = A4nt
2
+
3
+ This project rocks and uses MIT-LICENSE.
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'A4nt'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+
28
+ Bundler::GemHelper.install_tasks
29
+
30
+ require 'rake/testtask'
31
+
32
+ Rake::TestTask.new(:test) do |t|
33
+ t.libs << 'lib'
34
+ t.libs << 'test'
35
+ t.pattern = 'test/**/*_test.rb'
36
+ t.verbose = false
37
+ end
38
+
39
+
40
+ task :default => :test
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,56 @@
1
+ body { background-color: #fff; color: #333; }
2
+
3
+ body, p, ol, ul, td {
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ pre {
10
+ background-color: #eee;
11
+ padding: 10px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ a { color: #000; }
16
+ a:visited { color: #666; }
17
+ a:hover { color: #fff; background-color:#000; }
18
+
19
+ div.field, div.actions {
20
+ margin-bottom: 10px;
21
+ }
22
+
23
+ #notice {
24
+ color: green;
25
+ }
26
+
27
+ .field_with_errors {
28
+ padding: 2px;
29
+ background-color: red;
30
+ display: table;
31
+ }
32
+
33
+ #error_explanation {
34
+ width: 450px;
35
+ border: 2px solid red;
36
+ padding: 7px;
37
+ padding-bottom: 0;
38
+ margin-bottom: 20px;
39
+ background-color: #f0f0f0;
40
+ }
41
+
42
+ #error_explanation h2 {
43
+ text-align: left;
44
+ font-weight: bold;
45
+ padding: 5px 5px 5px 15px;
46
+ font-size: 12px;
47
+ margin: -7px;
48
+ margin-bottom: 0px;
49
+ background-color: #c00;
50
+ color: #fff;
51
+ }
52
+
53
+ #error_explanation ul li {
54
+ font-size: 12px;
55
+ list-style: square;
56
+ }
@@ -0,0 +1,87 @@
1
+ require_dependency "a4nt/application_controller"
2
+
3
+ module A4nt
4
+ class AnnouncementsController < ApplicationController
5
+ # GET /announcements
6
+ # GET /announcements.json
7
+ def index
8
+ @announcements = Announcement.all
9
+
10
+ respond_to do |format|
11
+ format.html # index.html.erb
12
+ format.json { render json: @announcements }
13
+ end
14
+ end
15
+
16
+ # GET /announcements/1
17
+ # GET /announcements/1.json
18
+ def show
19
+ @announcement = Announcement.find(params[:id])
20
+
21
+ respond_to do |format|
22
+ format.html # show.html.erb
23
+ format.json { render json: @announcement }
24
+ end
25
+ end
26
+
27
+ # GET /announcements/new
28
+ # GET /announcements/new.json
29
+ def new
30
+ @announcement = Announcement.new
31
+
32
+ respond_to do |format|
33
+ format.html # new.html.erb
34
+ format.json { render json: @announcement }
35
+ end
36
+ end
37
+
38
+ # GET /announcements/1/edit
39
+ def edit
40
+ @announcement = Announcement.find(params[:id])
41
+ end
42
+
43
+ # POST /announcements
44
+ # POST /announcements.json
45
+ def create
46
+ @announcement = Announcement.new(params[:announcement])
47
+
48
+ respond_to do |format|
49
+ if @announcement.save
50
+ format.html { redirect_to @announcement, notice: 'Announcement was successfully created.' }
51
+ format.json { render json: @announcement, status: :created, location: @announcement }
52
+ else
53
+ format.html { render action: "new" }
54
+ format.json { render json: @announcement.errors, status: :unprocessable_entity }
55
+ end
56
+ end
57
+ end
58
+
59
+ # PUT /announcements/1
60
+ # PUT /announcements/1.json
61
+ def update
62
+ @announcement = Announcement.find(params[:id])
63
+
64
+ respond_to do |format|
65
+ if @announcement.update_attributes(params[:announcement])
66
+ format.html { redirect_to @announcement, notice: 'Announcement was successfully updated.' }
67
+ format.json { head :no_content }
68
+ else
69
+ format.html { render action: "edit" }
70
+ format.json { render json: @announcement.errors, status: :unprocessable_entity }
71
+ end
72
+ end
73
+ end
74
+
75
+ # DELETE /announcements/1
76
+ # DELETE /announcements/1.json
77
+ def destroy
78
+ @announcement = Announcement.find(params[:id])
79
+ @announcement.destroy
80
+
81
+ respond_to do |format|
82
+ format.html { redirect_to announcements_url }
83
+ format.json { head :no_content }
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,4 @@
1
+ module A4nt
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module A4nt
2
+ module AnnouncementsHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module A4nt
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,7 @@
1
+ module A4nt
2
+ class Announcement < ActiveRecord::Base
3
+ attr_accessible :body, :end_time, :position, :start_time, :title
4
+ scope :active, -> { where(["start_time <= ? AND end_time >= ?", Time.now, Time.now]) }
5
+ scope :newer, -> { active.order('position ASC') }
6
+ end
7
+ end
@@ -0,0 +1,37 @@
1
+ <%= form_for(@announcement) do |f| %>
2
+ <% if @announcement.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@announcement.errors.count, "error") %> prohibited this announcement from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @announcement.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :title %><br />
16
+ <%= f.text_field :title %>
17
+ </div>
18
+ <div class="field">
19
+ <%= f.label :body %><br />
20
+ <%= f.text_field :body %>
21
+ </div>
22
+ <div class="field">
23
+ <%= f.label :start_time %><br />
24
+ <%= f.datetime_select :start_time %>
25
+ </div>
26
+ <div class="field">
27
+ <%= f.label :end_time %><br />
28
+ <%= f.datetime_select :end_time %>
29
+ </div>
30
+ <div class="field">
31
+ <%= f.label :position %><br />
32
+ <%= f.number_field :position %>
33
+ </div>
34
+ <div class="actions">
35
+ <%= f.submit %>
36
+ </div>
37
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing announcement</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @announcement %> |
6
+ <%= link_to 'Back', announcements_path %>
@@ -0,0 +1,31 @@
1
+ <h1>Listing announcements</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Title</th>
6
+ <th>Body</th>
7
+ <th>Start time</th>
8
+ <th>End time</th>
9
+ <th>Position</th>
10
+ <th></th>
11
+ <th></th>
12
+ <th></th>
13
+ </tr>
14
+
15
+ <% @announcements.each do |announcement| %>
16
+ <tr>
17
+ <td><%= announcement.title %></td>
18
+ <td><%= announcement.body %></td>
19
+ <td><%= announcement.start_time %></td>
20
+ <td><%= announcement.end_time %></td>
21
+ <td><%= announcement.position %></td>
22
+ <td><%= link_to 'Show', announcement %></td>
23
+ <td><%= link_to 'Edit', edit_announcement_path(announcement) %></td>
24
+ <td><%= link_to 'Destroy', announcement, method: :delete, data: { confirm: 'Are you sure?' } %></td>
25
+ </tr>
26
+ <% end %>
27
+ </table>
28
+
29
+ <br />
30
+
31
+ <%= link_to 'New Announcement', new_announcement_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New announcement</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', announcements_path %>
@@ -0,0 +1,30 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <b>Title:</b>
5
+ <%= @announcement.title %>
6
+ </p>
7
+
8
+ <p>
9
+ <b>Body:</b>
10
+ <%= @announcement.body %>
11
+ </p>
12
+
13
+ <p>
14
+ <b>Start time:</b>
15
+ <%= @announcement.start_time %>
16
+ </p>
17
+
18
+ <p>
19
+ <b>End time:</b>
20
+ <%= @announcement.end_time %>
21
+ </p>
22
+
23
+ <p>
24
+ <b>Position:</b>
25
+ <%= @announcement.position %>
26
+ </p>
27
+
28
+
29
+ <%= link_to 'Edit', edit_announcement_path(@announcement) %> |
30
+ <%= link_to 'Back', announcements_path %>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>A4nt</title>
5
+ <%= stylesheet_link_tag "a4nt/application", :media => "all" %>
6
+ <%= javascript_include_tag "a4nt/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,5 @@
1
+ A4nt::Engine.routes.draw do
2
+ resources :announcements
3
+
4
+ root to: "announcements#index"
5
+ end
@@ -0,0 +1,13 @@
1
+ class CreateA4ntAnnouncements < ActiveRecord::Migration
2
+ def change
3
+ create_table :a4nt_announcements do |t|
4
+ t.string :title
5
+ t.string :body
6
+ t.datetime :start_time
7
+ t.datetime :end_time
8
+ t.integer :position
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,4 @@
1
+ require "a4nt/engine"
2
+
3
+ module A4nt
4
+ end
@@ -0,0 +1,5 @@
1
+ module A4nt
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace A4nt
4
+ end
5
+ end