paul_revere 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -4,13 +4,17 @@ Simple announcement plugin to include "one off" style announcements in Rails web
4
4
 
5
5
  h2. Install
6
6
 
7
- Install the engine as normal:
7
+ Install the engine as normal, in your Gemfile:
8
8
 
9
- @script/plugin install git://github.com/thoughtbot/paul_revere.git@
9
+ @gem 'paul_revere'@
10
+
11
+ or...
12
+
13
+ @rails plugin install git://github.com/thoughtbot/paul_revere.git@
10
14
 
11
15
  Run the generator to create the migration and copy the javascript file into public:
12
16
 
13
- @./script/generate paul_revere@
17
+ @rails generate paul_revere@
14
18
 
15
19
  h2. Beastie Boys Lyrics
16
20
 
data/Rakefile CHANGED
@@ -25,17 +25,16 @@ end
25
25
 
26
26
  spec = Gem::Specification.new do |s|
27
27
  s.name = "paul_revere"
28
- s.version = "0.1.0"
28
+ s.version = "0.1.1"
29
29
  s.summary = "Simple announcement plugin to include 'one off' style announcements in Rails web apps."
30
30
  s.author = "Thoughtbot"
31
31
  s.email = "support@thoughtbot.com"
32
32
  s.homepage = "http://thoughtbot.com/community"
33
-
34
33
  s.has_rdoc = true
35
34
  s.extra_rdoc_files = %w(README.textile)
36
35
  s.rdoc_options = %w(--main README.textile)
37
-
38
- s.files = %w(init.rb install.rb MIT-LICENSE Rakefile README.textile uninstall.rb) + Dir.glob("{test,lib/**/*}")
36
+ s.files = %w(init.rb MIT-LICENSE Rakefile README.textile) +
37
+ Dir.glob("{test,lib/**/*,app/**/*}")
39
38
  s.require_paths = ["lib"]
40
39
 
41
40
  s.add_dependency("rails", "~> 3.0.0")
@@ -0,0 +1,11 @@
1
+ module AnnouncementsHelper
2
+ def announcement_hidden?(announcement)
3
+ cookies["announcement_#{announcement.created_at}"] == "hidden"
4
+ end
5
+
6
+ def current_announcement
7
+ @current_announcement ||= Announcement.current
8
+ end
9
+ end
10
+
11
+
@@ -0,0 +1,9 @@
1
+ class Announcement < ActiveRecord::Base
2
+ def self.current
3
+ first(:order => 'created_at DESC') || new
4
+ end
5
+
6
+ def exists?
7
+ !new_record?
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ <% if current_user and current_announcement.exists? and not announcement_hidden?(current_announcement) %>
2
+ <div id="announcement">
3
+ <%= current_announcement.body %>
4
+ <div class="hide">
5
+ <%= link_to_function "hide", "hideAnnouncement('announcement_#{current_announcement.created_at}');" %>
6
+ </div>
7
+ </div>
8
+ <% end %>
9
+
@@ -0,0 +1,5 @@
1
+ <% if current_announcement.exists? -%>
2
+ <%= strip_tags(current_announcement.body) %>
3
+ ---
4
+
5
+ <% end -%>
data/init.rb CHANGED
@@ -1,2 +1 @@
1
- # Include hook code here
2
-
1
+ require 'paul_revere'
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ rails generate paul_revere Thing
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -0,0 +1,10 @@
1
+ class PaulRevereGenerator < Rails::Generator::Base
2
+ desc "Put the javascript and migration in place"
3
+ source_root File.join(File.dirname(__FILE__), "templates")
4
+
5
+ def install
6
+ directory "public/javascripts"
7
+ file "announcements.js", "public/javascripts/announcements.js"
8
+ migration_template "migration.rb", "db/migrate/create_announcements.rb"
9
+ end
10
+ end
@@ -0,0 +1,6 @@
1
+
2
+ function hideAnnouncement(announcement_created_at) {
3
+ setCookie(announcement_created_at, 'hidden');
4
+ $("announcement").fade();
5
+ }
6
+
@@ -0,0 +1,12 @@
1
+ class CreateAnnouncements < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :announcements do |t|
4
+ t.text :body
5
+ t.timestamps
6
+ end
7
+ end
8
+
9
+ def self.down
10
+ drop_table :announcements
11
+ end
12
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paul_revere
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Thoughtbot
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-12 00:00:00 -04:00
18
+ date: 2010-10-13 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -86,12 +86,18 @@ extra_rdoc_files:
86
86
  - README.textile
87
87
  files:
88
88
  - init.rb
89
- - install.rb
90
89
  - MIT-LICENSE
91
90
  - Rakefile
92
91
  - README.textile
93
- - uninstall.rb
92
+ - lib/generators/paul_revere/paul_revere_generator.rb
93
+ - lib/generators/paul_revere/templates/announcements.js
94
+ - lib/generators/paul_revere/templates/migration.rb
95
+ - lib/generators/paul_revere/USAGE
94
96
  - lib/paul_revere.rb
97
+ - app/helpers/announcements_helper.rb
98
+ - app/models/announcement.rb
99
+ - app/views/announcements/_announcement.html.erb
100
+ - app/views/announcements/_email_announcement.erb
95
101
  has_rdoc: true
96
102
  homepage: http://thoughtbot.com/community
97
103
  licenses: []
data/install.rb DELETED
File without changes
data/uninstall.rb DELETED
@@ -1 +0,0 @@
1
- # Uninstall hook code here