cartoonist-announcements 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/app/assets/javascripts/cartoonist-announcements.js +4 -0
- data/app/controllers/announcements_admin_controller.rb +10 -0
- data/app/controllers/announcements_controller.rb +2 -0
- data/app/models/announcement.rb +37 -0
- data/app/views/announcements_admin/index.html.erb +23 -0
- data/app/views/layouts/announcements_admin.html.erb +11 -0
- data/cartoonist-announcements.gemspec +12 -0
- data/config/locales/en.yml +15 -0
- data/db/migrate/20120412035009_create_announcements.rb +16 -0
- data/lib/cartoonist-announcements.rb +3 -0
- data/lib/cartoonist-announcements/engine.rb +14 -0
- metadata +57 -0
data/.gitignore
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
class Announcement < ActiveRecord::Base
|
2
|
+
validate :posted_at_must_be_before_expired_at, :posted_at_must_exist_if_expired_at_exists
|
3
|
+
|
4
|
+
def posted_at_must_be_before_expired_at
|
5
|
+
if posted_at && expired_at && posted_at > expired_at
|
6
|
+
errors.add :posted_at, "must be before expiration"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def posted_at_must_exist_if_expired_at_exists
|
11
|
+
if expired_at && !posted_at
|
12
|
+
errors.add :posted_at, "must exist if expiration exists"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class << self
|
17
|
+
def disabled
|
18
|
+
where :enabled => false
|
19
|
+
end
|
20
|
+
|
21
|
+
def enabled
|
22
|
+
where :enabled => true
|
23
|
+
end
|
24
|
+
|
25
|
+
def active
|
26
|
+
where "posted_at < ? AND (expired_at IS NULL OR expired_at > ?)", DateTime.now, DateTime.now
|
27
|
+
end
|
28
|
+
|
29
|
+
def expired
|
30
|
+
where "expired_at < ?", DateTime.now
|
31
|
+
end
|
32
|
+
|
33
|
+
def future
|
34
|
+
where "posted_at IS NULL OR posted_at > ?", DateTime.now
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<h2><%= t "admin.announcements.index.not_posted" %></h2>
|
2
|
+
|
3
|
+
<ul>
|
4
|
+
<% @unposted.each do |announcement| %>
|
5
|
+
<li><%= announcement.title %></li>
|
6
|
+
<% end %>
|
7
|
+
</ul>
|
8
|
+
|
9
|
+
<h2><%= t "admin.announcements.index.active" %></h2>
|
10
|
+
|
11
|
+
<ul>
|
12
|
+
<% @active.each do |announcement| %>
|
13
|
+
<li><%= announcement.title %></li>
|
14
|
+
<% end %>
|
15
|
+
</ul>
|
16
|
+
|
17
|
+
<h2><%= t "admin.announcements.index.expired" %></h2>
|
18
|
+
|
19
|
+
<ul>
|
20
|
+
<% @expired.each do |announcement| %>
|
21
|
+
<li><%= announcement.title %></li>
|
22
|
+
<% end %>
|
23
|
+
</ul>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<% content_for :subtabs do %>
|
2
|
+
<a class="subtab" href="/announcements_admin"><%= t "admin.announcements.layout.list" %></a>
|
3
|
+
<!-- Disable until they are ready.
|
4
|
+
<a class="subtab" href="/announcements_admin/new"><%= t "admin.announcements.layout.new" %></a>
|
5
|
+
<a class="subtab" href="/announcements_admin/preview"><%= t "admin.announcements.layout.preview" %></a>
|
6
|
+
-->
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<% content_for :page_title, t("admin.announcements.layout.section") %>
|
10
|
+
<% content_for(:content) { yield } %>
|
11
|
+
<%= render :template => "layouts/admin" %>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "cartoonist-announcements"
|
3
|
+
s.version = "0.0.3"
|
4
|
+
s.date = "2012-04-07"
|
5
|
+
s.summary = "Cartoonist Announcements"
|
6
|
+
s.description = "This plugin for Cartoonist adds announcements for things like announcing a new website."
|
7
|
+
s.authors = ["Mike Virata-Stone"]
|
8
|
+
s.email = "reasonnumber@gmail.com"
|
9
|
+
s.files = `git ls-files`.split("\n")
|
10
|
+
s.require_paths = ["lib"]
|
11
|
+
s.homepage = "http://reasonnumber.com/cartoonist"
|
12
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
en:
|
2
|
+
admin:
|
3
|
+
announcements:
|
4
|
+
index:
|
5
|
+
active: Currently active
|
6
|
+
expired: Expired
|
7
|
+
not_posted: Not yet posted
|
8
|
+
layout:
|
9
|
+
list: List
|
10
|
+
new: New Announcement
|
11
|
+
preview: Preview
|
12
|
+
section: Announcements
|
13
|
+
layout:
|
14
|
+
tab:
|
15
|
+
announcements: Announcements
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateAnnouncements < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :announcements do |t|
|
4
|
+
t.datetime :posted_at
|
5
|
+
t.datetime :expired_at
|
6
|
+
t.string :title
|
7
|
+
t.text :content, :null => false
|
8
|
+
t.string :location
|
9
|
+
t.boolean :enabled, :null => false, :default => false
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
|
13
|
+
add_index :announcements, [:posted_at, :expired_at, :enabled]
|
14
|
+
add_index :announcements, [:expired_at, :enabled]
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module CartoonistAnnouncements
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
Cartoonist::Admin::Tab.add :announcements, :url => "/announcements_admin"
|
4
|
+
Cartoonist::Asset.include_js "cartoonist-announcements.js"
|
5
|
+
Cartoonist::Migration.add_for self
|
6
|
+
Cartoonist::Backup.for :announcements do
|
7
|
+
Announcement.order(:id).all
|
8
|
+
end
|
9
|
+
Cartoonist::Routes.add do
|
10
|
+
resources :announcements
|
11
|
+
resources :announcements_admin
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cartoonist-announcements
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Mike Virata-Stone
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-07 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: This plugin for Cartoonist adds announcements for things like announcing
|
15
|
+
a new website.
|
16
|
+
email: reasonnumber@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- app/assets/javascripts/cartoonist-announcements.js
|
23
|
+
- app/controllers/announcements_admin_controller.rb
|
24
|
+
- app/controllers/announcements_controller.rb
|
25
|
+
- app/models/announcement.rb
|
26
|
+
- app/views/announcements_admin/index.html.erb
|
27
|
+
- app/views/layouts/announcements_admin.html.erb
|
28
|
+
- cartoonist-announcements.gemspec
|
29
|
+
- config/locales/en.yml
|
30
|
+
- db/migrate/20120412035009_create_announcements.rb
|
31
|
+
- lib/cartoonist-announcements.rb
|
32
|
+
- lib/cartoonist-announcements/engine.rb
|
33
|
+
homepage: http://reasonnumber.com/cartoonist
|
34
|
+
licenses: []
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
requirements: []
|
52
|
+
rubyforge_project:
|
53
|
+
rubygems_version: 1.8.17
|
54
|
+
signing_key:
|
55
|
+
specification_version: 3
|
56
|
+
summary: Cartoonist Announcements
|
57
|
+
test_files: []
|