under_construction 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. data/README.md +156 -0
  2. data/Rakefile +35 -0
  3. data/app/assets/fonts/under_construction/site-under-construction-fa/IranianSans.eot +0 -0
  4. data/app/assets/fonts/under_construction/site-under-construction-fa/IranianSans.ttf +0 -0
  5. data/app/assets/fonts/under_construction/site-under-construction-fa/IranianSans.woff +0 -0
  6. data/app/assets/images/under_construction/site-under-construction/bg.jpg +0 -0
  7. data/app/assets/images/under_construction/site-under-construction/button.png +0 -0
  8. data/app/assets/images/under_construction/site-under-construction/counter_bg.png +0 -0
  9. data/app/assets/images/under_construction/site-under-construction/deviantart.png +0 -0
  10. data/app/assets/images/under_construction/site-under-construction/facebook.png +0 -0
  11. data/app/assets/images/under_construction/site-under-construction/flickr.png +0 -0
  12. data/app/assets/images/under_construction/site-under-construction/google.png +0 -0
  13. data/app/assets/images/under_construction/site-under-construction/identica.png +0 -0
  14. data/app/assets/images/under_construction/site-under-construction/linkedin.png +0 -0
  15. data/app/assets/images/under_construction/site-under-construction/logo.png +0 -0
  16. data/app/assets/images/under_construction/site-under-construction/mail-bg.png +0 -0
  17. data/app/assets/images/under_construction/site-under-construction/next.png +0 -0
  18. data/app/assets/images/under_construction/site-under-construction/page_background.png +0 -0
  19. data/app/assets/images/under_construction/site-under-construction/prev.png +0 -0
  20. data/app/assets/images/under_construction/site-under-construction/skype.png +0 -0
  21. data/app/assets/images/under_construction/site-under-construction/stumbleupon.png +0 -0
  22. data/app/assets/images/under_construction/site-under-construction/twitter.png +0 -0
  23. data/app/assets/images/under_construction/site-under-construction/yahoo.png +0 -0
  24. data/app/assets/images/under_construction/site-under-construction/youtube.png +0 -0
  25. data/app/assets/images/under_construction/site-under-construction-fa/bg.jpg +0 -0
  26. data/app/assets/images/under_construction/site-under-construction-fa/button.png +0 -0
  27. data/app/assets/images/under_construction/site-under-construction-fa/counter_bg.png +0 -0
  28. data/app/assets/images/under_construction/site-under-construction-fa/deviantart.png +0 -0
  29. data/app/assets/images/under_construction/site-under-construction-fa/facebook.png +0 -0
  30. data/app/assets/images/under_construction/site-under-construction-fa/flickr.png +0 -0
  31. data/app/assets/images/under_construction/site-under-construction-fa/google.png +0 -0
  32. data/app/assets/images/under_construction/site-under-construction-fa/identica.png +0 -0
  33. data/app/assets/images/under_construction/site-under-construction-fa/linkedin.png +0 -0
  34. data/app/assets/images/under_construction/site-under-construction-fa/logo.png +0 -0
  35. data/app/assets/images/under_construction/site-under-construction-fa/mail-bg.png +0 -0
  36. data/app/assets/images/under_construction/site-under-construction-fa/next.png +0 -0
  37. data/app/assets/images/under_construction/site-under-construction-fa/page_background.png +0 -0
  38. data/app/assets/images/under_construction/site-under-construction-fa/prev.png +0 -0
  39. data/app/assets/images/under_construction/site-under-construction-fa/skype.png +0 -0
  40. data/app/assets/images/under_construction/site-under-construction-fa/stumbleupon.png +0 -0
  41. data/app/assets/images/under_construction/site-under-construction-fa/twitter.png +0 -0
  42. data/app/assets/images/under_construction/site-under-construction-fa/yahoo.png +0 -0
  43. data/app/assets/images/under_construction/site-under-construction-fa/youtube.png +0 -0
  44. data/app/assets/javascripts/under_construction/site-under-construction/DD_belatedPNG_0.0.7a-min.js +14 -0
  45. data/app/assets/javascripts/under_construction/site-under-construction/jcarousellite1.0.1_min.js +1 -0
  46. data/app/assets/javascripts/under_construction/site-under-construction/jquery.countdown.min.js +6 -0
  47. data/app/assets/javascripts/under_construction/site-under-construction-fa/DD_belatedPNG_0.0.7a-min.js +14 -0
  48. data/app/assets/javascripts/under_construction/site-under-construction-fa/jcarousellite1.0.1_min.js +1 -0
  49. data/app/assets/javascripts/under_construction/site-under-construction-fa/jquery.countdown-fa.js +13 -0
  50. data/app/assets/javascripts/under_construction/site-under-construction-fa/jquery.countdown.min.js +6 -0
  51. data/app/assets/stylesheets/under_construction/site-under-construction/style.css +325 -0
  52. data/app/assets/stylesheets/under_construction/site-under-construction-fa/style.css +326 -0
  53. data/app/controllers/under_construction_controller.rb +20 -0
  54. data/app/controllers/under_construction_email_storage_controller.rb +17 -0
  55. data/app/helpers/email_storage_helper.rb +13 -0
  56. data/app/mailers/notify_under_construction_submitted_mails.rb +7 -0
  57. data/app/models/under_construction_email_storage.rb +61 -0
  58. data/app/views/email_storage/_form.html.erb +6 -0
  59. data/app/views/notify_under_construction_submitted_mails/under_construction_notify.text.erb +1 -0
  60. data/lib/generators/under_construction/USAGE +8 -0
  61. data/lib/generators/under_construction/clear_generator.rb +38 -0
  62. data/lib/generators/under_construction/config_generator.rb +38 -0
  63. data/lib/generators/under_construction/constants.rb +37 -0
  64. data/lib/generators/under_construction/templates/under_construction/site-under-construction/index.html.erb +116 -0
  65. data/lib/generators/under_construction/templates/under_construction/site-under-construction-fa/index.html.erb +116 -0
  66. data/lib/generators/under_construction/templates/under_construction.yml +41 -0
  67. data/lib/generators/under_construction/templates/under_construction_scheduler.rb +6 -0
  68. data/lib/tasks/under_cunstruction_tasks.rake +12 -0
  69. data/lib/under_construction/config.rb +46 -0
  70. data/lib/under_construction/engine.rb +15 -0
  71. data/lib/under_construction/schedule.rb +39 -0
  72. data/lib/under_construction/version.rb +3 -0
  73. data/lib/under_construction.rb +18 -0
  74. metadata +283 -0
@@ -0,0 +1,61 @@
1
+ class UnderConstructionEmailStorage
2
+ include ActiveModel::Validations
3
+ include ActiveModel::Conversion
4
+ extend ActiveModel::Naming
5
+
6
+ attr_accessor :email
7
+ FILE_PATH = Rails.root + "db/under_construction_mails.txt"
8
+
9
+ class UniquenessValidator < ActiveModel::EachValidator
10
+ def validate_each(record, attribute, value)
11
+ emails_path = Rails.root + "db/under_construction_mails.txt"
12
+ if File.exist? emails_path
13
+ File.open(emails_path, "r") do |f|
14
+ if f.readlines.include? value + "\n"
15
+ record.errors[attribute] << I18n.t('activemodel.errors.models.under_construction_email_storage.attributes.email.uniqueness', default: "Already submitted")
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ validates :email, presence: true, uniqueness: true,
23
+ format: { with: /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i,
24
+ message: I18n.t('activemodel.errors.models.under_construction_email_storage.attributes.email.format', default: "doesn't looks like correct") }
25
+
26
+ def initialize(attributes = {})
27
+ attributes.each do |name, value|
28
+ send("#{name}=", value)
29
+ end
30
+ end
31
+
32
+ def persisted?
33
+ false
34
+ end
35
+
36
+ # save submitted mail to a text file
37
+ def save_to_file
38
+ File.open(FILE_PATH, "a") do |f|
39
+ f.puts email
40
+ end
41
+ end
42
+
43
+ # return emails in a array
44
+ def self.emails
45
+ File.open(FILE_PATH, "r") do |f|
46
+ f.readlines
47
+ end
48
+ rescue Errno::ENOENT
49
+ []
50
+ end
51
+
52
+ def self.no_emails?
53
+ emails.empty?
54
+ end
55
+
56
+ def self.remove_file
57
+ if File.exist? FILE_PATH
58
+ FileUtils.rm FILE_PATH
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,6 @@
1
+ <%= form_for @email, url: under_construction_email_storage_index_path, html: { id: 'subscribeform' } do |f| %>
2
+ <div id='email_input'>
3
+ <%= f.text_field :email, id: 'email', placeholder: @info['email_field_value'], size: 30 %>
4
+ <%= f.submit t('.submit', default: "SUBMIT"), id: 'submit' %>
5
+ </div>
6
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= UnderConstruction.config.notify_mail["email_content"] %>
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ rails generate under_construction Thing
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -0,0 +1,38 @@
1
+ require_relative 'constants'
2
+
3
+ module UnderConstruction
4
+ module Generators
5
+ class ClearGenerator < ::Rails::Generators::Base
6
+ desc 'Clears configs application controller'
7
+ def clear_application_controller
8
+ if File.exist?('app/controllers/application_controller.rb')
9
+ # remove the exact block we've inserted. We don't want
10
+ # to remove the block if user has edited it
11
+ gsub_file 'app/controllers/application_controller.rb', /#{Regexp.escape(APPLICATION_CONFIG_TXT)}/,
12
+ ''
13
+ end
14
+ end
15
+
16
+ def clear_routes_file
17
+ file_path = 'config/routes.rb'
18
+ gsub_file file_path, /#{Regexp.escape(ROUTES_CONFIG_TXT)}/, ''
19
+ gsub_file file_path, /#{Regexp.escape(ROUTES_REDIRECT_TO_TXT)}/, ''
20
+ insert_into_file file_path, ROUTES_CLEAR_TXT, after: /Application.routes.draw do/
21
+ end
22
+
23
+ # def remove_view_files
24
+ # file_path = 'app/views/under_construction'
25
+ # if File.exist? file_path
26
+ # remove_file file_path
27
+ # end
28
+ # end
29
+
30
+ def remove_scheduler_file
31
+ file_path = 'config/initializers/under_construction_scheduler.rb'
32
+ if File.exist? file_path
33
+ remove_file file_path
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,38 @@
1
+ require_relative 'constants'
2
+
3
+ module UnderConstruction
4
+ module Generators
5
+ class ConfigGenerator < ::Rails::Generators::Base
6
+ source_root File.expand_path("../templates", __FILE__)
7
+
8
+ desc 'Configs application controller'
9
+ def edit_application_Controller
10
+ if File.exist?(Rails.root + "app/controllers/application_controller.rb")
11
+ insert_into_file "app/controllers/application_controller.rb", APPLICATION_CONFIG_TXT, :after => "protect_from_forgery"
12
+ else
13
+ raise 'Couldn\'t find application_controller file'
14
+ end
15
+ end
16
+
17
+ def copy_config_file
18
+ copy_file 'under_construction.yml', 'config/under_construction.yml'
19
+ end
20
+
21
+ def config_route_file
22
+ file_path = 'config/routes.rb'
23
+ gsub_file file_path, /match "under_construction", :to => redirect\('\/'\)/, ''
24
+ insert_into_file file_path, ROUTES_CONFIG_TXT, after: /Application.routes.draw do/
25
+ gsub_file file_path, /(Application.routes.draw do)(.*)(end)/m, '\1\2'+"#{ROUTES_REDIRECT_TO_TXT}" + '\3'
26
+ end
27
+
28
+ def copy_index_file_to_app
29
+ directory 'under_construction', 'app/views/under_construction'
30
+ end
31
+
32
+ def copy_scheduler_initializer
33
+ destination_path = 'config/initializers/under_construction_scheduler.rb'
34
+ copy_file 'under_construction_scheduler.rb', destination_path
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,37 @@
1
+ module UnderConstruction
2
+ module Generators
3
+ APPLICATION_CONFIG_TXT = <<-EOM
4
+
5
+ # Editing UnderConstruction block causes it's clear generator to not work
6
+ before_filter :redirect_to_under_construction
7
+
8
+ # Will redirect all requests to under construction page
9
+ def redirect_to_under_construction
10
+ if request.host_with_port == UnderConstruction.config.host_name && Rails.env.production?
11
+ unless request.url =~ /(under_construction|email_storage)/
12
+ redirect_to under_construction_index_path
13
+ end
14
+ end
15
+ end
16
+ EOM
17
+
18
+ ROUTES_CONFIG_TXT = <<-EOM
19
+
20
+ # generated by under_construction gem
21
+ resources 'under_construction_email_storage', only: :create
22
+ resources 'under_construction', only: :index
23
+ EOM
24
+
25
+ ROUTES_REDIRECT_TO_TXT = <<-EOM
26
+
27
+ # generated by under_construction gem
28
+ match "/*other" => redirect("/under_construction")
29
+ EOM
30
+
31
+ ROUTES_CLEAR_TXT = <<-EOM
32
+
33
+ # generated by under_construction gem
34
+ match "under_construction", :to => redirect('/')
35
+ EOM
36
+ end
37
+ end
@@ -0,0 +1,116 @@
1
+ <html xmlns="http://www.w3.org/1999/xhtml">
2
+ <head>
3
+ <meta name="generator" content=
4
+ "HTML Tidy for Linux/x86 (vers 25 March 2009), see www.w3.org" />
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+
7
+ <meta http-equiv="refresh" content="60">
8
+
9
+ <title><%= @info['site_title'] %></title>
10
+ <%= javascript_include_tag "application" %>
11
+ <%= stylesheet_link_tag "under_construction/#{@theme}/style.css", :media => "all" %>
12
+ <%= javascript_include_tag "under_construction/#{@theme}/jquery.countdown.min.js" %>
13
+ <%= javascript_include_tag "under_construction/#{@theme}/jcarousellite1.0.1_min.js" %>
14
+ <!-- jquery countdown-->
15
+
16
+ <script type="text/javascript">
17
+ $(function () {
18
+ var austDay = new Date("<%= Chronic.parse(@launch_time).to_s(:rfc822) %>");
19
+ $('#defaultCountdown').countdown({until: austDay, layout: '{dn} {dl}, {hn} {hl}, {mn} {ml}, and {sn} {sl}'});
20
+ $('#year').text(austDay.getFullYear());
21
+ });
22
+ </script><!-- jquery slider -->
23
+
24
+ <script type="text/javascript">
25
+ $(function() {
26
+ $("#slidertext").jCarouselLite({
27
+ btnNext: ".next",
28
+ btnPrev: ".prev"
29
+ });
30
+ });
31
+ </script><!--script for IE6-image transparency recover-->
32
+ <!--[if IE 6]>
33
+ <script type="text/javascript" src="js/DD_belatedPNG_0.0.7a-min.js"></script>
34
+ <script>
35
+ /* EXAMPLE */
36
+ DD_belatedPNG.fix('#logo img,#main,.counter,.twitter,.flickr,.facebook,.youtube,.skype,.stumbleupon, #submit,.prev img,.next img,#email');
37
+ </script>
38
+ <![endif]-->
39
+ </head>
40
+
41
+ <body>
42
+ <div class="container">
43
+ <%= view_flash_messages unless view_flash_messages.blank? %>
44
+ <div id="header">
45
+ <div id="logo">
46
+ <a href="/under_construction">
47
+ <img src="<%= @info['logo_url'] %>"></img>
48
+ </a>
49
+ </div><!--end logo-->
50
+
51
+ <div id="contact_details">
52
+ <p><%= link_to @info['email'], "#" %></p>
53
+
54
+ <p><%= link_to "#{@info['phone']}", "#" %></p>
55
+ </div><!--end contact details-->
56
+ </div><!--end header-->
57
+
58
+ <div style="clear:both"></div>
59
+
60
+ <div id="main">
61
+ <div id="content">
62
+ <div class="text">
63
+ <h2><%= @info['heading'] %></h2>
64
+ </div><!--end text-->
65
+
66
+ <div class="counter">
67
+ <h3><%= @info['counter_heading'] %></h3>
68
+
69
+ <div id="defaultCountdown"></div>
70
+ </div><!--end counter-->
71
+
72
+ <div class="details">
73
+ <!--slider prev button-->
74
+ <a class="prev" href="#">
75
+ <%= image_tag "under_construction/#{@theme}/prev.png" %></a>
76
+
77
+ <div id="sliderwrap">
78
+ <div id="slidertext">
79
+ <!-- The slider -->
80
+
81
+ <ul>
82
+ <li>
83
+ <h3><%= @info['inform_by_email'] %></h3>
84
+ <%= render partial: 'email_storage/form', object: @email %>
85
+ </li><!-- Slider item -->
86
+
87
+ <li>
88
+ <h3><%= @socials_title %></h3>
89
+
90
+ <div class="social">
91
+ <% @socials.each do |name, url| %>
92
+ <%= link_to name, url, class: name %>
93
+ <% end %>
94
+ </div>
95
+ </li><!-- Slider item -->
96
+
97
+ <li>
98
+ <h3><%= @info['about_title'] %></h3>
99
+
100
+ <p><%= @info['about_content'] %></p>
101
+ </li><!-- Slider item -->
102
+ </ul>
103
+ </div><!-- End of slidertext -->
104
+ </div><!-- End of sliderwrap -->
105
+ <!--slider next button-->
106
+ <a class="next" href=
107
+ "#"><%= image_tag "under_construction/#{@theme}/next.png" %></a>
108
+ </div><!--end details-->
109
+ </div><!--end content-->
110
+
111
+ <p class="copyright">
112
+ <%= raw @info['copyright'] + " " + @site_developer['name'] %></p>
113
+ </div><!--end main-->
114
+ </div><!--end class container-->
115
+ </body>
116
+ </html>
@@ -0,0 +1,116 @@
1
+ <html xmlns="http://www.w3.org/1999/xhtml">
2
+ <head>
3
+ <meta http-equiv="refresh" content="60">
4
+ <meta name="generator" content=
5
+ "HTML Tidy for Linux/x86 (vers 25 March 2009), see www.w3.org" />
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
7
+
8
+ <title><%= @info['site_title'] %></title>
9
+ <%= javascript_include_tag "application" %>
10
+ <%= stylesheet_link_tag "under_construction/#{@theme}/style.css", :media => "all" %>
11
+ <%= javascript_include_tag "under_construction/#{@theme}/jquery.countdown.min.js" %>
12
+ <%= javascript_include_tag "under_construction/#{@theme}/jquery.countdown-fa.js" %>
13
+ <%= javascript_include_tag "under_construction/#{@theme}/jcarousellite1.0.1_min.js" %>
14
+ <!-- jquery countdown-->
15
+
16
+ <script type="text/javascript">
17
+ $(function () {
18
+ var austDay = new Date("<%= Chronic.parse(@launch_time).to_s(:rfc822) %>");
19
+ $('#defaultCountdown').countdown({until: austDay, layout: '{dn} {dl} و {hn} {hl} و {mn} {ml} و {sn} {sl}'});
20
+ $('#year').text(austDay.getFullYear());
21
+ });
22
+ </script><!-- jquery slider -->
23
+
24
+ <script type="text/javascript">
25
+ $(function() {
26
+ $("#slidertext").jCarouselLite({
27
+ btnNext: ".next",
28
+ btnPrev: ".prev"
29
+ });
30
+ });
31
+ </script><!--script for IE6-image transparency recover-->
32
+ <!--[if IE 6]>
33
+ <script type="text/javascript" src="js/DD_belatedPNG_0.0.7a-min.js"></script>
34
+ <script>
35
+ /* EXAMPLE */
36
+ DD_belatedPNG.fix('#logo img,#main,.counter,.twitter,.flickr,.facebook,.youtube,.skype,.stumbleupon, #submit,.prev img,.next img,#email');
37
+ </script>
38
+ <![endif]-->
39
+ </head>
40
+
41
+ <body dir="rtl">
42
+ <div class="container">
43
+ <%= view_flash_messages unless view_flash_messages.blank? %>
44
+ <div id="header">
45
+ <div id="logo">
46
+ <a href="/under_construction">
47
+ <img src="<%= @info['logo_url'] %>"></img>
48
+ </a>
49
+ </div><!--end logo-->
50
+
51
+ <div id="contact_details">
52
+ <p><%= link_to @info['email'], "#" %></p>
53
+
54
+ <p><%= link_to "#{@info['phone']}", "#" %></p>
55
+ </div><!--end contact details-->
56
+ </div><!--end header-->
57
+
58
+ <div style="clear:both"></div>
59
+
60
+ <div id="main">
61
+ <div id="content">
62
+ <div class="text">
63
+ <h2><%= @info['heading'] %></h2>
64
+ </div><!--end text-->
65
+
66
+ <div class="counter">
67
+ <h3><%= @info['counter_heading'] %></h3>
68
+
69
+ <div id="defaultCountdown"></div>
70
+ </div><!--end counter-->
71
+
72
+ <div class="details">
73
+ <!--slider prev button-->
74
+ <a class="prev" href="#">
75
+ <%= image_tag "under_construction/#{@theme}/prev.png" %></a>
76
+
77
+ <div id="sliderwrap">
78
+ <div id="slidertext">
79
+ <!-- The slider -->
80
+
81
+ <ul>
82
+ <li>
83
+ <h3><%= @info['inform_by_email'] %></h3>
84
+ <%= render partial: 'email_storage/form', object: @email %>
85
+ </li><!-- Slider item -->
86
+
87
+ <li>
88
+ <h3><%= @socials_title %></h3>
89
+
90
+ <div class="social">
91
+ <% @socials.each do |name, url| %>
92
+ <%= link_to name, url, class: name %>
93
+ <% end %>
94
+ </div>
95
+ </li><!-- Slider item -->
96
+
97
+ <li>
98
+ <h3><%= @info['about_title'] %></h3>
99
+
100
+ <p><%= @info['about_content'] %></p>
101
+ </li><!-- Slider item -->
102
+ </ul>
103
+ </div><!-- End of slidertext -->
104
+ </div><!-- End of sliderwrap -->
105
+ <!--slider next button-->
106
+ <a class="next" href=
107
+ "#"><%= image_tag "under_construction/#{@theme}/next.png" %></a>
108
+ </div><!--end details-->
109
+ </div><!--end content-->
110
+
111
+ <p class="copyright">
112
+ <%= raw @info['copyright'] + " " + @site_developer['name'] %></p>
113
+ </div><!--end main-->
114
+ </div><!--end class container-->
115
+ </body>
116
+ </html>
@@ -0,0 +1,41 @@
1
+ theme: 'site-under-construction'
2
+ launch_time: "24 Feb 2050 7:00pm"
3
+ progress: "60" # Percent
4
+ progress_label: "Progress"
5
+ website_address: "http://example.com"
6
+ host_name: "localhost:3000"
7
+ info:
8
+ site_title: "My Website"
9
+ logo_url: "/assets/under_construction/site-under-construction/logo.png"
10
+ email: "support@example.com"
11
+ phone: "phone : 555-123456"
12
+ heading: "This website is under construction"
13
+ counter_heading: "Estimated Time Remaining Before Launch:"
14
+ about_title: "Some words about us"
15
+ about_content: |
16
+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
17
+ Phasellus hendrerit. Pellentesque aliquet nibh nec urna. I
18
+ n nisi neque, aliquet vel, dapibus id, mattis vel, nisi.
19
+ inform_by_email: "Type your email id to get the updates!"
20
+ email_field_value: "Enter Your E-mail"
21
+ copyright: "Copyright &copy;"
22
+ site_developer:
23
+ name: "Great Developer"
24
+ socials_title: "You may find us below:"
25
+ socials:
26
+ twitter: "#" #Full URL: http://twitter.com/great_developer
27
+ facebook: "#"
28
+ yahoo: "#"
29
+ # stumbleupon: "#"
30
+ flickr: "#"
31
+ #google: "#"
32
+ youtube: "#"
33
+ skype: "#"
34
+ deviantart: "#"
35
+ identica: "#"
36
+ notify_mail:
37
+ sender_email_address: "do_not_reply@example.com"
38
+ email_subject: "My Website just launched!"
39
+ email_content: |
40
+ Hi! Our site, "Example", has just launched!
41
+ Click the flowing link to view the website: http://example.com
@@ -0,0 +1,6 @@
1
+ # This line will initialize a scheduler to remove
2
+ # under_construction configs after running your server
3
+
4
+ Rails.application.config.after_initialize do
5
+ UnderConstruction::Schedule.new
6
+ end
@@ -0,0 +1,12 @@
1
+ desc "Send notify emails to users submited their email to underconstruction page"
2
+ namespace :under_construction do
3
+ task :send_mails => :environment do
4
+ if File.exist? Rails.root + "db/under_construction_mails.txt"
5
+ UnderConstructionEmailStorage.emails.each do |email|
6
+ NotifyUnderConstructionSubmittedMails.under_construction_notify(email.chomp).deliver
7
+ end
8
+ else
9
+ puts "There's no email submitted"
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,46 @@
1
+ require 'active_support/configurable'
2
+ require 'yaml'
3
+
4
+ module UnderConstruction
5
+ def self.configure(&block)
6
+ yield @config ||= UnderConstruction::Configuration.new
7
+ end
8
+
9
+ def self.config
10
+ @config
11
+ end
12
+
13
+ def self.config_file
14
+ config_path = File.join(Rails.root, 'config','under_construction.yml')
15
+ if File.exist? File.join(Rails.root, 'config','under_construction.yml')
16
+ YAML.load_file(config_path)
17
+ else
18
+ false
19
+ end
20
+ end
21
+
22
+ class Configuration
23
+ include ActiveSupport::Configurable
24
+
25
+ config_accessor :theme
26
+ config_accessor :launch_time
27
+ config_accessor :host_name
28
+ config_accessor :progress
29
+ config_accessor :progress_label
30
+ config_accessor :info
31
+ config_accessor :site_developer
32
+ config_accessor :socials_title
33
+ config_accessor :socials
34
+ config_accessor :notify_mail
35
+ config_accessor :website_address
36
+ end
37
+
38
+ if config_file
39
+ configure do |configuration|
40
+ config_file.each_pair do |key, value|
41
+ configuration.config[key.to_sym] = value
42
+ end
43
+ end
44
+ end
45
+
46
+ end
@@ -0,0 +1,15 @@
1
+ module UnderConstruction
2
+ class Engine < ::Rails::Engine
3
+ config.generators do |g|
4
+ g.test_framework :rspec,
5
+ :fixtures => false,
6
+ :view_specs => false,
7
+ :helper_specs => false,
8
+ :routing_specs => false,
9
+ :controller_specs => true,
10
+ :request_specs => true
11
+ g.assets false
12
+ g.helper false
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,39 @@
1
+ require 'rails/generators'
2
+
3
+ module UnderConstruction
4
+ class Schedule
5
+ def initialize(*args)
6
+ @scheduler = Rufus::Scheduler.start_new
7
+ @end_time = args[0]
8
+ schedule()
9
+ end
10
+
11
+ def schedule
12
+ @end_time ||= UnderConstruction.config.launch_time
13
+ @job = @scheduler.at Chronic.parse(@end_time) do
14
+ invoke_clear_generator()
15
+ end
16
+ end
17
+
18
+ # Stop the schedule
19
+ def stop_schedule
20
+ @job.unschedule
21
+ end
22
+
23
+ # Shows all schaduled jobs. just for testing perposes
24
+ def jobs
25
+ @scheduler.jobs
26
+ end
27
+
28
+ private
29
+ def invoke_clear_generator
30
+ Rails::Generators.invoke('under_construction:clear')
31
+ # If there's a scheduled job, remove it
32
+ stop_schedule if jobs.size > 0
33
+ # To make passenger to restart the application
34
+ FileUtils.touch Rails.root + 'tmp/restart.txt'
35
+ # After restart server, sends email to subscribers
36
+ system "bundle exec rake under_construction:send_mails RAILS_ENV=#{Rails.env}"
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,3 @@
1
+ module UnderConstruction
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,18 @@
1
+ require 'rails'
2
+ require 'rufus-scheduler'
3
+ require 'chronic'
4
+
5
+ require "under_construction/engine"
6
+
7
+ module UnderConstruction
8
+
9
+ class Railtie < ::Rails::Railtie
10
+ initializer "set_autoload_paths" do |app|
11
+ if app.config.autoload_paths
12
+ require "under_construction/config"
13
+ require "under_construction/schedule"
14
+ end
15
+ end
16
+ end
17
+
18
+ end