rails-zero 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2ba6e138cdeb9b604c743e4ea7417b73d7abe2c3
4
+ data.tar.gz: eaf3425df9b310abc418f8abad736d390d0c61ba
5
+ SHA512:
6
+ metadata.gz: d19b8bc94dd0d5e1e232fce995f0a452f13a1c3a7715be7c26777ae8e05a19c7b6f31dd61ecc8848cc814f493391bd95f165d0c486b3c7870ee8729e439d09db
7
+ data.tar.gz: 27e175f061c27cfb5a4b79abba09b9249b0a9e0131b9beee520512e98adc00a9da6d6274a31684996f57656fe3e16cc560d8d21653567dfcba92c5de0db7f0e4
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2014 Jens Bissinger
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
8
+ load 'rails/tasks/engine.rake'
9
+
10
+ Bundler::GemHelper.install_tasks
11
+
12
+ require 'rspec/core'
13
+ require 'rspec/core/rake_task'
14
+
15
+ desc "Run all specs in spec directory (excluding plugin specs)"
16
+ RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
17
+
18
+ task :default => :spec
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,5 @@
1
+ module RailsZero
2
+ class BaseClient
3
+ include RailsZero::Engine.routes.url_helpers
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ require_dependency "rails_zero/base_client"
2
+
3
+ module RailsZero
4
+ class PackagesClient < BaseClient
5
+ def get url
6
+ remote_url = File.join(url, packages_path)
7
+ destination = Rails.root.join('tmp', 'downloads', 'public.tar')
8
+ FileUtils.mkdir_p(File.dirname(destination))
9
+ command = "curl #{remote_url} > #{destination}"
10
+ stdout_str, stderr_str, status = Open3.capture3(command)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,4 @@
1
+ module RailsZero
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,27 @@
1
+ require_dependency "rails_zero/application_controller"
2
+
3
+ module RailsZero
4
+ class PackagesController < ApplicationController
5
+ def index
6
+ FileUtils.mkdir_p(File.dirname(archive_path))
7
+ command = "tar -cf '#{archive_path}' '#{public_path}/'"
8
+ stdout_str, stderr_str, status = Open3.capture3(command)
9
+ send_file archive_path
10
+ end
11
+
12
+ def new
13
+ CleanSiteJob.new.run
14
+ head :ok
15
+ end
16
+
17
+ private
18
+
19
+ def public_path
20
+ Rails.root.join('public')
21
+ end
22
+
23
+ def archive_path
24
+ Rails.root.join('tmp', 'packages', 'public.tar')
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,4 @@
1
+ module RailsZero
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,17 @@
1
+ module RailsZero
2
+ class CleanSiteJob
3
+ def run
4
+ Dir[Rails.root.join('public', '**', '*').to_s].each do |f|
5
+ if !excluded_files.include?(f) && File.exists?(f)
6
+ FileUtils.rm_rf(f)
7
+ end
8
+ end
9
+ end
10
+
11
+ private
12
+
13
+ def excluded_files
14
+ RailsZero.pages_config.paths_to_except_from_cleanup
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ module RailsZero
2
+ class GenerateSiteJob
3
+ def run
4
+ RailsZero.pages_config.links.each do |path|
5
+ Capybara.visit path
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>RailsZero</title>
5
+ <%= stylesheet_link_tag "rails_zero/application", media: "all" %>
6
+ <%= javascript_include_tag "rails_zero/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,4 @@
1
+ RailsZero::Engine.routes.draw do
2
+ get 'packages' => 'packages#index'
3
+ get 'packages/new' => 'packages#new'
4
+ end
data/lib/rails-zero.rb ADDED
@@ -0,0 +1 @@
1
+ require 'rails_zero'
@@ -0,0 +1,16 @@
1
+ module RailsZero
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace RailsZero
4
+
5
+ config.generators do |g|
6
+ g.test_framework :rspec, :fixture => false
7
+ #g.fixture_replacement :factory_girl, :dir => 'spec/factories'
8
+ g.assets false
9
+ g.helper false
10
+ end
11
+
12
+ initializer 'rails_zero.set_page_cache_dir' do |app|
13
+ app.config.action_controller.page_cache_directory = "#{Rails.root.to_s}/public/deploy"
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ module RailsZero
2
+ class PagesConfig
3
+ def links
4
+ @links ||= []
5
+ end
6
+
7
+ def paths_to_except_from_cleanup
8
+ @paths_to_except_from_cleanup ||= begin
9
+ %w[ 404.html 422.html 500.html favicon.ico ].map do |f|
10
+ Rails.root.join('public', f).to_s
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module RailsZero
2
+ VERSION = "0.0.1"
3
+ end
data/lib/rails_zero.rb ADDED
@@ -0,0 +1,14 @@
1
+ require "rails_zero/engine"
2
+ require "rails_zero/pages_config"
3
+ require 'actionpack/page_caching/railtie'
4
+ require 'open3'
5
+
6
+ module RailsZero
7
+ def self.configure_pages
8
+ yield pages_config
9
+ end
10
+
11
+ def self.pages_config
12
+ @config ||= PagesConfig.new
13
+ end
14
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :rails_zero do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-zero
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jens Bissinger
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 4.0.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 4.0.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: actionpack-page_caching
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sqlite3
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: RailsZero is a Rails Engine that helps generating static websites out
56
+ of any Rails application.
57
+ email:
58
+ - mail@jens-bissinger.de
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - app/assets/javascripts/rails_zero/application.js
64
+ - app/assets/stylesheets/rails_zero/application.css
65
+ - app/clients/rails_zero/base_client.rb
66
+ - app/clients/rails_zero/packages_client.rb
67
+ - app/controllers/rails_zero/application_controller.rb
68
+ - app/controllers/rails_zero/packages_controller.rb
69
+ - app/helpers/rails_zero/application_helper.rb
70
+ - app/jobs/rails_zero/clean_site_job.rb
71
+ - app/jobs/rails_zero/generate_site_job.rb
72
+ - app/views/layouts/rails_zero/application.html.erb
73
+ - config/routes.rb
74
+ - lib/rails-zero.rb
75
+ - lib/rails_zero/engine.rb
76
+ - lib/rails_zero/pages_config.rb
77
+ - lib/rails_zero/version.rb
78
+ - lib/rails_zero.rb
79
+ - lib/tasks/rails_zero_tasks.rake
80
+ - MIT-LICENSE
81
+ - Rakefile
82
+ homepage: https://github.com/dpree/rails-zero
83
+ licenses: []
84
+ metadata: {}
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 2.0.3
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: RailsZero is a static site generator based on Rails
105
+ test_files: []