radiant-flapper-extension 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE.md +7 -0
- data/README.md +71 -0
- data/Rakefile +109 -0
- data/app/views/admin/pages/_flapper.html.haml +27 -0
- data/config/initializers/radiant_config.rb +12 -0
- data/config/locales/en.yml +6 -0
- data/config/routes.rb +5 -0
- data/cucumber.yml +1 -0
- data/db/migrate/20110609044628_add_twitter_notification_field.rb +15 -0
- data/features/support/env.rb +11 -0
- data/features/support/paths.rb +22 -0
- data/flapper_extension.rb +80 -0
- data/lib/radiant-flapper-extension.rb +2 -0
- data/lib/radiant-flapper-extension/version.rb +5 -0
- data/lib/tasks/flapper_extension_tasks.rake +55 -0
- data/radiant-flapper-extension.gemspec +31 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helper.rb +36 -0
- metadata +119 -0
data/MIT-LICENSE.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2011 john muhl
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
A tweet pusher for Radiant CMS
|
2
|
+
https://github.com/johnmuhl/flapper
|
3
|
+
|
4
|
+
# Install
|
5
|
+
|
6
|
+
```bash
|
7
|
+
# gem install (preferred)
|
8
|
+
gem install radiant-flapper-extension
|
9
|
+
$EDITOR config/environment.rb # add config.gem "radiant-flapper-extension"
|
10
|
+
rake db:migrate:extensions
|
11
|
+
|
12
|
+
# manual install
|
13
|
+
gem install googl -v "~> 0.5.0"
|
14
|
+
gem install twitter -v "~> 1.5.0"
|
15
|
+
script/extension install flapper
|
16
|
+
|
17
|
+
# otherwise
|
18
|
+
curl -LO https://github.com/johnmuhl/flapper/zipball/master
|
19
|
+
unzip master ; rm master
|
20
|
+
mv johnmuhl-flapper-* vendor/extensions/flapper
|
21
|
+
gem install googl -v "~> 0.5.0"
|
22
|
+
gem install twitter -v "~> 1.5.0"
|
23
|
+
rake db:migrate:extensions
|
24
|
+
```
|
25
|
+
|
26
|
+
# Setup
|
27
|
+
|
28
|
+
[Register a new app][register]. **Make sure you set the Default Access type to Read & Write** - none of the other settings effect this extension. From the app page grab the *OAuth Consumer* & *Consumer Secret* keys. Click the "My Access Token" button and get your *Access Token* & *Access Token Secret*.
|
29
|
+
|
30
|
+
Edit (or create) `config/initializers/radiant_config.rb` to include your Twitter access credentials. `flapper.username` is your Twitter username. `flapper.domain` is used to build a full URL to the page being tweeted.
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
config["flapper.username"] = "username"
|
34
|
+
config["flapper.domain"] = "www.example.com"
|
35
|
+
config["flapper.consumer_key"] = "consumer_key"
|
36
|
+
config["flapper.consumer_secret"] = "consumer_secret"
|
37
|
+
config["flapper.oauth_token"] = "oauth_token"
|
38
|
+
config["flapper.oauth_token_secret"] = "oauth_token_secret"
|
39
|
+
```
|
40
|
+
|
41
|
+
Add your Google Account if you want to track your short URLs with [Google URL Shortener][googl].
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
config["flapper.google_email"] = "you@gmail.com"
|
45
|
+
config["flapper.google_password"] = "password"
|
46
|
+
```
|
47
|
+
|
48
|
+
# Usage
|
49
|
+
|
50
|
+
From the Radiant admin find the page whose children you want to tweet and check the "Publish children to Twitter?" box (it's hidden under "More"). When you create a new child enter the page content as usual and fill in the Tweet field (again, under "More") with a short message you'd like to accompany the URL to the page. The Tweet field has a 130 character limit to leave room for the `...` and shortened URL; if the URL ever needs more space characters will be dropped from the Tweet field to make room.
|
51
|
+
|
52
|
+
# Notes
|
53
|
+
|
54
|
+
Much code (and db schema) lifted from the original [Twitter extension by Sean Cribbs][cribbs]. As a result you should be able to drop Flapper in as a replacement when you decided to upgrade to Radiant 1.x.
|
55
|
+
|
56
|
+
Written in a fit so no tests and probably many subtle (and not so subtle) bugs not to mention all the code is just stuffed in `#activate`. May not work with Radiant < master.
|
57
|
+
|
58
|
+
[Issues & pull requests][issues] are welcome.
|
59
|
+
|
60
|
+
# MIT License
|
61
|
+
|
62
|
+
https://github.com/johnmuhl/flapper/blob/master/MIT-LICENSE.md
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
[cribbs]: https://github.com/seancribbs/radiant-twitter-extension
|
69
|
+
[googl]: http://goo.gl/
|
70
|
+
[issues]: https://github.com/johnmuhl/flapper/issues
|
71
|
+
[register]: https://dev.twitter.com/apps
|
data/Rakefile
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
# Determine where the RSpec plugin is by loading the boot
|
2
|
+
unless defined? RADIANT_ROOT
|
3
|
+
ENV["RAILS_ENV"] = "test"
|
4
|
+
case
|
5
|
+
when ENV["RADIANT_ENV_FILE"]
|
6
|
+
require File.dirname(ENV["RADIANT_ENV_FILE"]) + "/boot"
|
7
|
+
when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
|
8
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../")}/config/boot"
|
9
|
+
else
|
10
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../")}/config/boot"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'rake'
|
15
|
+
require 'rake/rdoctask'
|
16
|
+
require 'rake/testtask'
|
17
|
+
|
18
|
+
rspec_base = File.expand_path(RADIANT_ROOT + '/vendor/plugins/rspec/lib')
|
19
|
+
$LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
|
20
|
+
require 'spec/rake/spectask'
|
21
|
+
require 'cucumber'
|
22
|
+
require 'cucumber/rake/task'
|
23
|
+
|
24
|
+
# Cleanup the RADIANT_ROOT constant so specs will load the environment
|
25
|
+
Object.send(:remove_const, :RADIANT_ROOT)
|
26
|
+
|
27
|
+
extension_root = File.expand_path(File.dirname(__FILE__))
|
28
|
+
|
29
|
+
task :default => [:spec, :features]
|
30
|
+
task :stats => "spec:statsetup"
|
31
|
+
|
32
|
+
desc "Run all specs in spec directory"
|
33
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
34
|
+
t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
35
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
36
|
+
end
|
37
|
+
|
38
|
+
task :features => 'spec:integration'
|
39
|
+
|
40
|
+
namespace :spec do
|
41
|
+
desc "Run all specs in spec directory with RCov"
|
42
|
+
Spec::Rake::SpecTask.new(:rcov) do |t|
|
43
|
+
t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
44
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
45
|
+
t.rcov = true
|
46
|
+
t.rcov_opts = ['--exclude', 'spec', '--rails']
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "Print Specdoc for all specs"
|
50
|
+
Spec::Rake::SpecTask.new(:doc) do |t|
|
51
|
+
t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
52
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
53
|
+
end
|
54
|
+
|
55
|
+
[:models, :controllers, :views, :helpers].each do |sub|
|
56
|
+
desc "Run the specs under spec/#{sub}"
|
57
|
+
Spec::Rake::SpecTask.new(sub) do |t|
|
58
|
+
t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
59
|
+
t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
desc "Run the Cucumber features"
|
64
|
+
Cucumber::Rake::Task.new(:integration) do |t|
|
65
|
+
t.fork = true
|
66
|
+
t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'pretty')]
|
67
|
+
# t.feature_pattern = "#{extension_root}/features/**/*.feature"
|
68
|
+
t.profile = "default"
|
69
|
+
end
|
70
|
+
|
71
|
+
# Setup specs for stats
|
72
|
+
task :statsetup do
|
73
|
+
require 'code_statistics'
|
74
|
+
::STATS_DIRECTORIES << %w(Model\ specs spec/models)
|
75
|
+
::STATS_DIRECTORIES << %w(View\ specs spec/views)
|
76
|
+
::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers)
|
77
|
+
::STATS_DIRECTORIES << %w(Helper\ specs spec/views)
|
78
|
+
::CodeStatistics::TEST_TYPES << "Model specs"
|
79
|
+
::CodeStatistics::TEST_TYPES << "View specs"
|
80
|
+
::CodeStatistics::TEST_TYPES << "Controller specs"
|
81
|
+
::CodeStatistics::TEST_TYPES << "Helper specs"
|
82
|
+
::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
|
83
|
+
end
|
84
|
+
|
85
|
+
namespace :db do
|
86
|
+
namespace :fixtures do
|
87
|
+
desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
|
88
|
+
task :load => :environment do
|
89
|
+
require 'active_record/fixtures'
|
90
|
+
ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
|
91
|
+
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
|
92
|
+
Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
desc 'Generate documentation for the flapper extension.'
|
100
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
101
|
+
rdoc.rdoc_dir = 'rdoc'
|
102
|
+
rdoc.title = 'FlapperExtension'
|
103
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
104
|
+
rdoc.rdoc_files.include('README')
|
105
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
106
|
+
end
|
107
|
+
|
108
|
+
# Load any custom rakefiles for extension
|
109
|
+
Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
|
@@ -0,0 +1,27 @@
|
|
1
|
+
- if @page.parent
|
2
|
+
-if @page.parent.notify_twitter_of_children?
|
3
|
+
- if @page.twitter_id
|
4
|
+
%tr
|
5
|
+
%th.label= t("flapper.status")
|
6
|
+
%td
|
7
|
+
%a{ :href => "http://twitter.com/#{Radiant::Config['flapper.username']}/statuses/#{@page.twitter_id}", :style => "color:white" }
|
8
|
+
= "http://twitter.com/#{Radiant::Config['flapper.username']}/statuses/#{@page.twitter_id}"
|
9
|
+
%td
|
10
|
+
- else
|
11
|
+
- if @page.field("Tweet").nil?
|
12
|
+
- page_field = PageField.new
|
13
|
+
%tr
|
14
|
+
%th.label
|
15
|
+
%label{ :for => "page_Tweet" }= t("flapper.tweet")
|
16
|
+
%td.field
|
17
|
+
%input#page_fields_attributes_2_name.page_field_name{ :name => "page[fields_attributes][2][name]", :type => "hidden", :value => "Tweet" }
|
18
|
+
%input#page_fields_attributes_2__destroy.delete_input{ :name => "page[fields_attributes][2][_destroy]", :type => "hidden" }
|
19
|
+
%input#page_fields_attributes_2_content.textbox{ :maxlength => "130", :name => "page[fields_attributes][2][content]", :value => "" }
|
20
|
+
- else
|
21
|
+
%tr
|
22
|
+
%th.label= t("flapper.tweet")
|
23
|
+
%td
|
24
|
+
= check_box 'page', 'notify_twitter_of_children'
|
25
|
+
%label{ :for => "page_notify_twitter_of_children" }
|
26
|
+
= t("flapper.publish_children")
|
27
|
+
%td
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Radiant.config do |config|
|
2
|
+
config.namespace "flapper" do |c|
|
3
|
+
c.define "consumer_key", :allow_change => true
|
4
|
+
c.define "consumer_secret", :allow_change => true
|
5
|
+
c.define "domain", :allow_change => true
|
6
|
+
c.define "google_email", :allow_change => true
|
7
|
+
c.define "google_password", :allow_change => true
|
8
|
+
c.define "oauth_token", :allow_change => true
|
9
|
+
c.define "oauth_token_secret", :allow_change => true
|
10
|
+
c.define "username", :allow_change => true
|
11
|
+
end
|
12
|
+
end
|
data/config/routes.rb
ADDED
data/cucumber.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
default: --format progress features --tags ~@proposed,~@in_progress
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class AddTwitterNotificationField < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
begin
|
4
|
+
add_column :pages, :notify_twitter_of_children, :boolean, :default => false
|
5
|
+
add_column :pages, :twitter_id, :string
|
6
|
+
rescue
|
7
|
+
puts "You've already run the migrations"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.down
|
12
|
+
remove_column :pages, :notify_twitter_of_children
|
13
|
+
remove_column :pages, :twitter_id
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Sets up the Rails environment for Cucumber
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
# Extension root
|
4
|
+
extension_env = File.expand_path(File.dirname(__FILE__) + '/../../../../../config/environment')
|
5
|
+
require extension_env+'.rb'
|
6
|
+
|
7
|
+
Dir.glob(File.join(RADIANT_ROOT, "features", "**", "*.rb")).each {|step| require step unless step =~ /datasets_loader\.rb$/}
|
8
|
+
|
9
|
+
Cucumber::Rails::World.class_eval do
|
10
|
+
dataset :flapper
|
11
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module NavigationHelpers
|
2
|
+
|
3
|
+
# Extend the standard PathMatchers with your own paths
|
4
|
+
# to be used in your features.
|
5
|
+
#
|
6
|
+
# The keys and values here may be used in your standard web steps
|
7
|
+
# Using:
|
8
|
+
#
|
9
|
+
# When I go to the "flapper" admin page
|
10
|
+
#
|
11
|
+
# would direct the request to the path you provide in the value:
|
12
|
+
#
|
13
|
+
# admin_flapper_path
|
14
|
+
#
|
15
|
+
PathMatchers = {} unless defined?(PathMatchers)
|
16
|
+
PathMatchers.merge!({
|
17
|
+
# /flapper/i => 'admin_flapper_path'
|
18
|
+
})
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
World(NavigationHelpers)
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# Uncomment this if you reference any of your controllers in activate
|
2
|
+
# require_dependency "application_controller"
|
3
|
+
|
4
|
+
require "radiant-flapper-extension/version"
|
5
|
+
|
6
|
+
class FlapperExtension < Radiant::Extension
|
7
|
+
version RadiantFlapperExtension::VERSION
|
8
|
+
description "Push new tweets as you publish pages"
|
9
|
+
url "https://github.com/johnmuhl/flapper"
|
10
|
+
|
11
|
+
extension_config do |config|
|
12
|
+
config.gem "googl", :version => "~> 0.5.0"
|
13
|
+
config.gem "twitter", :version => "~> 1.5.0"
|
14
|
+
config.after_initialize do
|
15
|
+
if ["flapper.username", "flapper.domain", "flapper.consumer_key",
|
16
|
+
"flapper.consumer_secret", "flapper.oauth_token",
|
17
|
+
"flapper.oauth_token_secret"].any? { |key| Radiant::Config[key].blank? }
|
18
|
+
puts "!! Flapper is not configured. https://github.com/johnmuhl/flapper"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def activate
|
24
|
+
Page.class_eval do
|
25
|
+
require "googl"
|
26
|
+
require "twitter"
|
27
|
+
after_save :notify_twitter
|
28
|
+
def notify_twitter
|
29
|
+
if parent
|
30
|
+
if notifiable?
|
31
|
+
content = self.field("Tweet")["content"]
|
32
|
+
if content.blank?
|
33
|
+
logger.error "!! Tweet field does not have any content."
|
34
|
+
else
|
35
|
+
url = shorten "http://#{Radiant::Config["flapper.domain"]}/#{parent.slug}/#{self.slug}/"
|
36
|
+
message = content[0..(136 - url.length)] + "..." + url
|
37
|
+
begin
|
38
|
+
Twitter.configure do |config|
|
39
|
+
config.consumer_key = Radiant::Config['flapper.consumer_key']
|
40
|
+
config.consumer_secret = Radiant::Config['flapper.consumer_secret']
|
41
|
+
config.oauth_token = Radiant::Config['flapper.oauth_token']
|
42
|
+
config.oauth_token_secret = Radiant::Config['flapper.oauth_token_secret']
|
43
|
+
end
|
44
|
+
status = Twitter::Client.new.update(message)
|
45
|
+
self.class.update_all({ :twitter_id => status.id }, :id => self.id)
|
46
|
+
rescue Exception
|
47
|
+
logger.error "!! Invalid Twitter configuration."
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
def twitter_configured?
|
54
|
+
!["flapper.username", "flapper.domain", "flapper.consumer_key",
|
55
|
+
"flapper.consumer_secret", "flapper.oauth_token", "flapper.oauth_token_secret"
|
56
|
+
].any? { |key| Radiant::Config[key].blank? }
|
57
|
+
end
|
58
|
+
def notifiable?
|
59
|
+
published? &&
|
60
|
+
twitter_configured? &&
|
61
|
+
parent.notify_twitter_of_children? &&
|
62
|
+
!self.twitter_id
|
63
|
+
end
|
64
|
+
def shorten url
|
65
|
+
if google_configured?
|
66
|
+
googl = Googl.client(Radiant::Config["flapper.google_email"], Radiant::Config["flapper.google_password"])
|
67
|
+
else
|
68
|
+
googl = Googl
|
69
|
+
end
|
70
|
+
googl.shorten(url).short_url
|
71
|
+
end
|
72
|
+
def google_configured?
|
73
|
+
!["flapper.google_email", "flapper.google_password"
|
74
|
+
].any? { |key| Radiant::Config[key].blank? }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
admin.pages.edit.add :extended_metadata, "flapper"
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
namespace :radiant do
|
2
|
+
namespace :extensions do
|
3
|
+
namespace :flapper do
|
4
|
+
|
5
|
+
desc "Runs the migration of the Flapper extension"
|
6
|
+
task :migrate => :environment do
|
7
|
+
require 'radiant/extension_migrator'
|
8
|
+
if ENV["VERSION"]
|
9
|
+
FlapperExtension.migrator.migrate(ENV["VERSION"].to_i)
|
10
|
+
Rake::Task['db:schema:dump'].invoke
|
11
|
+
else
|
12
|
+
FlapperExtension.migrator.migrate
|
13
|
+
Rake::Task['db:schema:dump'].invoke
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Copies public assets of the Flapper to the instance public/ directory."
|
18
|
+
task :update => :environment do
|
19
|
+
is_svn_or_dir = proc {|path| path =~ /\.svn/ || File.directory?(path) }
|
20
|
+
puts "Copying assets from FlapperExtension"
|
21
|
+
Dir[FlapperExtension.root + "/public/**/*"].reject(&is_svn_or_dir).each do |file|
|
22
|
+
path = file.sub(FlapperExtension.root, '')
|
23
|
+
directory = File.dirname(path)
|
24
|
+
mkdir_p RAILS_ROOT + directory, :verbose => false
|
25
|
+
cp file, RAILS_ROOT + path, :verbose => false
|
26
|
+
end
|
27
|
+
unless FlapperExtension.root.starts_with? RAILS_ROOT # don't need to copy vendored tasks
|
28
|
+
puts "Copying rake tasks from FlapperExtension"
|
29
|
+
local_tasks_path = File.join(RAILS_ROOT, %w(lib tasks))
|
30
|
+
mkdir_p local_tasks_path, :verbose => false
|
31
|
+
Dir[File.join FlapperExtension.root, %w(lib tasks *.rake)].each do |file|
|
32
|
+
cp file, local_tasks_path, :verbose => false
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "Syncs all available translations for this ext to the English ext master"
|
38
|
+
task :sync => :environment do
|
39
|
+
# The main translation root, basically where English is kept
|
40
|
+
language_root = FlapperExtension.root + "/config/locales"
|
41
|
+
words = TranslationSupport.get_translation_keys(language_root)
|
42
|
+
|
43
|
+
Dir["#{language_root}/*.yml"].each do |filename|
|
44
|
+
next if filename.match('_available_tags')
|
45
|
+
basename = File.basename(filename, '.yml')
|
46
|
+
puts "Syncing #{basename}"
|
47
|
+
(comments, other) = TranslationSupport.read_file(filename, basename)
|
48
|
+
words.each { |k,v| other[k] ||= words[k] } # Initializing hash variable as empty if it does not exist
|
49
|
+
other.delete_if { |k,v| !words[k] } # Remove if not defined in en.yml
|
50
|
+
TranslationSupport.write_file(filename, basename, comments, other)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "radiant-flapper-extension/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "radiant-flapper-extension"
|
7
|
+
s.version = RadiantFlapperExtension::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["john muhl"]
|
10
|
+
s.email = ["git@johnmuhl.com"]
|
11
|
+
s.homepage = "https://github.com/johnmuhl/flapper"
|
12
|
+
s.summary = %q{Post Twitter updates from Radiant CMS}
|
13
|
+
s.description = %q{Pushes new tweets as you publish pages from Radiant CMS}
|
14
|
+
|
15
|
+
ignores = if File.exist?('.gitignore')
|
16
|
+
File.read('.gitignore').split("\n").inject([]) {|a,p| a + Dir[p] }
|
17
|
+
else
|
18
|
+
[]
|
19
|
+
end
|
20
|
+
s.files = Dir['**/*'] - ignores
|
21
|
+
s.test_files = Dir['test/**/*','spec/**/*','features/**/*'] - ignores
|
22
|
+
s.require_paths = ["lib"]
|
23
|
+
|
24
|
+
s.post_install_message = %{
|
25
|
+
Add this to your radiant project with:
|
26
|
+
config.gem "radiant-flapper-extension", :version => "~> #{RadiantFlapperExtension::VERSION}"
|
27
|
+
}
|
28
|
+
|
29
|
+
s.add_runtime_dependency "googl", "~> 0.5.0"
|
30
|
+
s.add_runtime_dependency "twitter", "~> 1.5.0"
|
31
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
unless defined? RADIANT_ROOT
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
case
|
4
|
+
when ENV["RADIANT_ENV_FILE"]
|
5
|
+
require ENV["RADIANT_ENV_FILE"]
|
6
|
+
when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
|
7
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../../")}/config/environment"
|
8
|
+
else
|
9
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../")}/config/environment"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
require "#{RADIANT_ROOT}/spec/spec_helper"
|
13
|
+
|
14
|
+
Dataset::Resolver.default << (File.dirname(__FILE__) + "/datasets")
|
15
|
+
|
16
|
+
if File.directory?(File.dirname(__FILE__) + "/matchers")
|
17
|
+
Dir[File.dirname(__FILE__) + "/matchers/*.rb"].each {|file| require file }
|
18
|
+
end
|
19
|
+
|
20
|
+
Spec::Runner.configure do |config|
|
21
|
+
# config.use_transactional_fixtures = true
|
22
|
+
# config.use_instantiated_fixtures = false
|
23
|
+
# config.fixture_path = RAILS_ROOT + '/spec/fixtures'
|
24
|
+
|
25
|
+
# You can declare fixtures for each behaviour like this:
|
26
|
+
# describe "...." do
|
27
|
+
# fixtures :table_a, :table_b
|
28
|
+
#
|
29
|
+
# Alternatively, if you prefer to declare them only once, you can
|
30
|
+
# do so here, like so ...
|
31
|
+
#
|
32
|
+
# config.global_fixtures = :table_a, :table_b
|
33
|
+
#
|
34
|
+
# If you declare global fixtures, be aware that they will be declared
|
35
|
+
# for all of your examples, even those that don't use them.
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: radiant-flapper-extension
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- john muhl
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-06-09 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: googl
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 11
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 5
|
33
|
+
- 0
|
34
|
+
version: 0.5.0
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: twitter
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
46
|
+
segments:
|
47
|
+
- 1
|
48
|
+
- 5
|
49
|
+
- 0
|
50
|
+
version: 1.5.0
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
53
|
+
description: Pushes new tweets as you publish pages from Radiant CMS
|
54
|
+
email:
|
55
|
+
- git@johnmuhl.com
|
56
|
+
executables: []
|
57
|
+
|
58
|
+
extensions: []
|
59
|
+
|
60
|
+
extra_rdoc_files: []
|
61
|
+
|
62
|
+
files:
|
63
|
+
- app/views/admin/pages/_flapper.html.haml
|
64
|
+
- config/initializers/radiant_config.rb
|
65
|
+
- config/locales/en.yml
|
66
|
+
- config/routes.rb
|
67
|
+
- cucumber.yml
|
68
|
+
- db/migrate/20110609044628_add_twitter_notification_field.rb
|
69
|
+
- features/support/env.rb
|
70
|
+
- features/support/paths.rb
|
71
|
+
- flapper_extension.rb
|
72
|
+
- lib/radiant-flapper-extension/version.rb
|
73
|
+
- lib/radiant-flapper-extension.rb
|
74
|
+
- lib/tasks/flapper_extension_tasks.rake
|
75
|
+
- MIT-LICENSE.md
|
76
|
+
- radiant-flapper-extension.gemspec
|
77
|
+
- Rakefile
|
78
|
+
- README.md
|
79
|
+
- spec/spec.opts
|
80
|
+
- spec/spec_helper.rb
|
81
|
+
has_rdoc: true
|
82
|
+
homepage: https://github.com/johnmuhl/flapper
|
83
|
+
licenses: []
|
84
|
+
|
85
|
+
post_install_message: "\n Add this to your radiant project with:\n config.gem \"radiant-flapper-extension\", :version => \"~> 0.1.0\"\n "
|
86
|
+
rdoc_options: []
|
87
|
+
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
hash: 3
|
96
|
+
segments:
|
97
|
+
- 0
|
98
|
+
version: "0"
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
hash: 3
|
105
|
+
segments:
|
106
|
+
- 0
|
107
|
+
version: "0"
|
108
|
+
requirements: []
|
109
|
+
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 1.3.7
|
112
|
+
signing_key:
|
113
|
+
specification_version: 3
|
114
|
+
summary: Post Twitter updates from Radiant CMS
|
115
|
+
test_files:
|
116
|
+
- spec/spec.opts
|
117
|
+
- spec/spec_helper.rb
|
118
|
+
- features/support/env.rb
|
119
|
+
- features/support/paths.rb
|