sooner 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -2
- data/Rakefile +3 -4
- data/app/controllers/sooner/subscribers_controller.rb +6 -18
- data/app/models/sooner/subscriber.rb +13 -36
- data/app/views/sooner/subscribers/_already_subscribed.html.erb +1 -0
- data/app/views/sooner/subscribers/_subscribed.html.erb +1 -0
- data/app/views/sooner/subscribers/_unsubscribed.html.erb +1 -0
- data/app/views/sooner/subscribers/new.html.erb +15 -1
- data/config/locales/en.yml +0 -1
- data/config/routes.rb +3 -0
- data/lib/generators/sooner_install/sooner_install_generator.rb +22 -3
- data/lib/generators/sooner_install/templates/migration.rb +18 -0
- data/lib/generators/sooner_views/sooner_views_generator.rb +1 -1
- data/lib/sooner/email_format_validator.rb +9 -0
- data/lib/sooner/version.rb +1 -1
- metadata +11 -9
- data/app/views/sooner/subscribers/edit.html.erb +0 -25
- data/app/views/sooner/subscribers/index.html.erb +0 -1
- data/lib/generators/sooner/sooner_generator.rb +0 -31
- data/lib/generators/sooner/templates/migration.rb +0 -18
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
require 'rake'
|
3
3
|
require 'rake/rdoctask'
|
4
4
|
require 'rake/gempackagetask'
|
5
|
-
|
6
5
|
require 'rake/testtask'
|
7
6
|
|
8
7
|
Rake::TestTask.new(:test) do |t|
|
@@ -24,10 +23,10 @@ end
|
|
24
23
|
|
25
24
|
spec = Gem::Specification.new do |s|
|
26
25
|
s.name = "sooner"
|
27
|
-
s.summary = "
|
28
|
-
s.description = "
|
26
|
+
s.summary = "PreLaunching Application for ComingSoon Pages"
|
27
|
+
s.description = "Sooner Comingsoon Application"
|
29
28
|
s.files = FileList["[A-Z]*", "{app,config,lib}/**/*"]
|
30
|
-
s.version = "0.0.
|
29
|
+
s.version = "0.0.3"
|
31
30
|
end
|
32
31
|
|
33
32
|
Rake::GemPackageTask.new(spec) do |pkg|
|
@@ -1,34 +1,22 @@
|
|
1
1
|
module Sooner
|
2
2
|
class SubscribersController < ApplicationController
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
end
|
7
|
-
|
4
|
+
unloadable
|
5
|
+
|
8
6
|
def new
|
9
7
|
@subscriber = Subscriber.new
|
10
8
|
end
|
11
9
|
|
12
10
|
def create
|
13
|
-
@subscriber = Subscriber.new(params[:
|
11
|
+
@subscriber = Subscriber.new(params[:sooner_subscriber])
|
14
12
|
|
15
13
|
respond_to do |format|
|
16
14
|
if @subscriber.save
|
17
|
-
format.html { render :
|
18
|
-
format.js do
|
19
|
-
render :update do |page|
|
20
|
-
page.replace_html "message", "Successfully Inserted"
|
21
|
-
end
|
22
|
-
end
|
15
|
+
format.html { render :partial => "subscribed" }
|
23
16
|
else
|
24
|
-
format.html { render :
|
25
|
-
format.js do
|
26
|
-
render :update do |page|
|
27
|
-
page.replace_html "message", "UnSuccessfully Inserted"
|
28
|
-
end
|
29
|
-
end
|
17
|
+
format.html { render :partial => "unsubscribed" }
|
30
18
|
end
|
31
19
|
end
|
32
20
|
end
|
33
21
|
end
|
34
|
-
end
|
22
|
+
end
|
@@ -1,42 +1,19 @@
|
|
1
1
|
module Sooner
|
2
2
|
class Subscriber < ActiveRecord::Base
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
#attr_accessor :request
|
8
|
-
#alias :original_save :save
|
9
|
-
|
10
|
-
# def save
|
11
|
-
# if Sooner.db_store
|
12
|
-
# db_store
|
13
|
-
# end
|
14
|
-
#
|
15
|
-
# if Sooner.csv_store
|
16
|
-
# csv_store
|
17
|
-
# end
|
18
|
-
#
|
19
|
-
# end
|
20
|
-
|
21
|
-
#------------------------ private ----------------------
|
22
|
-
#private
|
23
|
-
|
24
|
-
# writes email addresses to database
|
25
|
-
# def db_store
|
26
|
-
# self.original_save
|
27
|
-
# end
|
28
|
-
|
4
|
+
validates :email, :presence => true, :uniqueness => true, :email_format => true
|
5
|
+
validates :name, :presence => true, :uniqueness => true
|
6
|
+
|
29
7
|
# writes email addresses to CSV file
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
# end
|
8
|
+
def csv_store
|
9
|
+
begin
|
10
|
+
file = File.open("public/#{ Sooner.csv_file.nil? ? 'subscribers.csv' : Sooner.csv_file }", "a")
|
11
|
+
file << "#{ email }\n"
|
12
|
+
file.close
|
13
|
+
rescue Exception => e
|
14
|
+
self.errors.add_to_base(e.message + " (CSV)")
|
15
|
+
end
|
16
|
+
end
|
40
17
|
|
41
18
|
end
|
42
|
-
end
|
19
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= "Already Subscribed" %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= "Subscribed" %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= "UNSubscribed" %>
|
@@ -1,7 +1,21 @@
|
|
1
1
|
<h2>Add to subscriber List</h2>
|
2
2
|
|
3
|
-
<%= form_for @subscriber do |f| %>
|
3
|
+
<%= form_for @subscriber, :url => subscribers_path do |f| %>
|
4
4
|
|
5
|
+
<% if @subscriber.errors.any? %>
|
6
|
+
<div id="errorExplanation">
|
7
|
+
<h2><%= pluralize(@subscriber.errors.count, "error") %> prohibited this post from being saved:</h2>
|
8
|
+
<ul>
|
9
|
+
<% @subscriber.errors.full_messages.each do |msg| %>
|
10
|
+
<li><%= msg %></li>
|
11
|
+
<% end %>
|
12
|
+
</ul>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<%= f.label :name %>
|
17
|
+
<%= f.text_field :name %>
|
18
|
+
<br />
|
5
19
|
<%= f.label :email %>
|
6
20
|
<%= f.text_field :email %>
|
7
21
|
|
data/config/locales/en.yml
CHANGED
data/config/routes.rb
ADDED
@@ -1,19 +1,38 @@
|
|
1
1
|
class SoonerInstallGenerator < Rails::Generators::Base
|
2
|
+
include Rails::Generators::Migration
|
3
|
+
|
2
4
|
desc "Creates a Sooner initializer and copy locale files to your application."
|
3
5
|
|
4
6
|
class_option :orm
|
7
|
+
class_option :migration, :type => :boolean, :default => orm_has_migration?
|
5
8
|
|
6
9
|
def self.source_root
|
7
10
|
@_sooner_source_root ||= File.expand_path("../templates", __FILE__)
|
8
11
|
end
|
9
12
|
|
13
|
+
def self.orm_has_migration?
|
14
|
+
Rails::Generators.options[:rails][:orm] == :active_record
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.next_migration_number(dirname)
|
18
|
+
if ActiveRecord::Base.timestamped_migrations
|
19
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
20
|
+
else
|
21
|
+
"%.3d" % (current_migration_number(dirname) + 1)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_migration_file
|
26
|
+
migration_template 'migration.rb', 'db/migrate/sooner_create_#{[name]}.rb'
|
27
|
+
end
|
28
|
+
|
10
29
|
def copy_initializer
|
11
30
|
template "sooner.rb", "config/initializers/sooner.rb"
|
12
31
|
end
|
13
32
|
|
14
|
-
def copy_locale
|
15
|
-
copy_file "../../../../config/locales/en.yml", "config/locales/sooner.en.yml"
|
16
|
-
end
|
33
|
+
# def copy_locale
|
34
|
+
# copy_file "../../../../config/locales/en.yml", "config/locales/sooner.en.yml"
|
35
|
+
# end
|
17
36
|
|
18
37
|
def show_readme
|
19
38
|
readme "README"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class SoonerCreateSubscribers < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :subscribers do |t|
|
4
|
+
t.string :name
|
5
|
+
t.string :email
|
6
|
+
#Any additional fields here
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
|
11
|
+
add_index :subscribers, :name, :unique => true
|
12
|
+
add_index :subscribers, :email, :unique => true
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.down
|
16
|
+
drop_table :subscribers
|
17
|
+
end
|
18
|
+
end
|
@@ -4,7 +4,7 @@ class SoonerViewsGenerator < Rails::Generators::Base
|
|
4
4
|
argument :scope, :required => false, :default => nil, :desc => "The scope to copy views to"
|
5
5
|
|
6
6
|
class_option :template_engine, :type => :string, :aliases => "-t", :default => "erb",
|
7
|
-
|
7
|
+
:desc => "Template engine for the views. Available options are 'erb' and 'haml'."
|
8
8
|
|
9
9
|
def self.source_root
|
10
10
|
@_sooner_source_root ||= File.expand_path("../../../../app/views", __FILE__)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module Sooner
|
2
|
+
class EmailFormatValidator < ActiveModel::EachValidator
|
3
|
+
def validate_each(object, attribute, value)
|
4
|
+
unless value =~ /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
|
5
|
+
object.errors[attribute] << (options[:message] || "is not formatted properly")
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
data/lib/sooner/version.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors: []
|
12
12
|
|
@@ -14,11 +14,11 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-06-
|
17
|
+
date: 2010-06-07 00:00:00 +03:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
21
|
-
description:
|
21
|
+
description: Sooner Comingsoon Application
|
22
22
|
email:
|
23
23
|
executables: []
|
24
24
|
|
@@ -32,19 +32,21 @@ files:
|
|
32
32
|
- MIT-LICENSE
|
33
33
|
- Rakefile
|
34
34
|
- app/controllers/sooner/subscribers_controller.rb
|
35
|
-
- app/views/sooner/subscribers/
|
36
|
-
- app/views/sooner/subscribers/index.html.erb
|
35
|
+
- app/views/sooner/subscribers/_subscribed.html.erb
|
37
36
|
- app/views/sooner/subscribers/new.html.erb
|
37
|
+
- app/views/sooner/subscribers/_already_subscribed.html.erb
|
38
|
+
- app/views/sooner/subscribers/_unsubscribed.html.erb
|
38
39
|
- app/models/sooner/subscriber.rb
|
39
40
|
- config/locales/en.yml
|
40
|
-
-
|
41
|
-
- lib/generators/sooner/templates/migration.rb
|
41
|
+
- config/routes.rb
|
42
42
|
- lib/generators/sooner_install/templates/sooner.rb
|
43
|
+
- lib/generators/sooner_install/templates/migration.rb
|
43
44
|
- lib/generators/sooner_install/templates/README
|
44
45
|
- lib/generators/sooner_install/sooner_install_generator.rb
|
45
46
|
- lib/generators/sooner_views/sooner_views_generator.rb
|
46
47
|
- lib/sooner.rb
|
47
48
|
- lib/sooner/rails.rb
|
49
|
+
- lib/sooner/email_format_validator.rb
|
48
50
|
- lib/sooner/version.rb
|
49
51
|
has_rdoc: true
|
50
52
|
homepage:
|
@@ -77,6 +79,6 @@ rubyforge_project:
|
|
77
79
|
rubygems_version: 1.3.7
|
78
80
|
signing_key:
|
79
81
|
specification_version: 3
|
80
|
-
summary:
|
82
|
+
summary: PreLaunching Application for ComingSoon Pages
|
81
83
|
test_files: []
|
82
84
|
|
@@ -1,25 +0,0 @@
|
|
1
|
-
<h2>Edit <%= resource_name.to_s.humanize %></h2>
|
2
|
-
|
3
|
-
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
|
4
|
-
<%= devise_error_messages! %>
|
5
|
-
|
6
|
-
<p><%= f.label :email %><br />
|
7
|
-
<%= f.text_field :email %></p>
|
8
|
-
|
9
|
-
<p><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
|
10
|
-
<%= f.password_field :password %></p>
|
11
|
-
|
12
|
-
<p><%= f.label :password_confirmation %><br />
|
13
|
-
<%= f.password_field :password_confirmation %></p>
|
14
|
-
|
15
|
-
<p><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
|
16
|
-
<%= f.password_field :current_password %></p>
|
17
|
-
|
18
|
-
<p><%= f.submit "Update" %></p>
|
19
|
-
<% end %>
|
20
|
-
|
21
|
-
<h3>Cancel my account</h3>
|
22
|
-
|
23
|
-
<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.</p>
|
24
|
-
|
25
|
-
<%= link_to "Back", :back %>
|
@@ -1 +0,0 @@
|
|
1
|
-
Welcome To Sooner Launching
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'rails/generators/migration'
|
2
|
-
|
3
|
-
class SoonerGenerator < Rails::Generators::NamedBase
|
4
|
-
include Rails::Generators::Migration
|
5
|
-
|
6
|
-
desc "Generates a model with the given NAME (if one does not exist) with sooner " <<
|
7
|
-
"configuration plus a migration file and sooner routes."
|
8
|
-
|
9
|
-
def self.source_root
|
10
|
-
@_sooner_source_root ||= File.expand_path("../templates", __FILE__)
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.orm_has_migration?
|
14
|
-
Rails::Generators.options[:rails][:orm] == :active_record
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.next_migration_number(dirname)
|
18
|
-
if ActiveRecord::Base.timestamped_migrations
|
19
|
-
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
20
|
-
else
|
21
|
-
"%.3d" % (current_migration_number(dirname) + 1)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
class_option :orm
|
26
|
-
class_option :migration, :type => :boolean, :default => orm_has_migration?
|
27
|
-
|
28
|
-
def create_migration_file
|
29
|
-
migration_template 'migration.rb', 'db/migrate/sooner_create_#{[name]}.rb'
|
30
|
-
end
|
31
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
class SoonerCreate<%= table_name.camelize %> < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_table :<%= table_name %> do |t|
|
4
|
-
t.string :name
|
5
|
-
t.string :email
|
6
|
-
#Any additional fields here
|
7
|
-
|
8
|
-
t.timestamps
|
9
|
-
end
|
10
|
-
|
11
|
-
add_index :<%= table_name %>, :name, :unique => true
|
12
|
-
add_index :<%= table_name %>, :email, :unique => true
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.down
|
16
|
-
drop_table :<%= table_name %>
|
17
|
-
end
|
18
|
-
end
|