parklife 0.4.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/tests.yml +13 -2
  3. data/.rubocop.yml +30 -0
  4. data/CHANGELOG.md +26 -13
  5. data/Gemfile +7 -0
  6. data/README.md +9 -3
  7. data/Rakefile +2 -0
  8. data/bin/console +1 -0
  9. data/exe/parklife +2 -0
  10. data/lib/parklife/application.rb +2 -0
  11. data/lib/parklife/browser.rb +13 -5
  12. data/lib/parklife/cli.rb +34 -12
  13. data/lib/parklife/config.rb +2 -0
  14. data/lib/parklife/crawler.rb +8 -2
  15. data/lib/parklife/errors.rb +6 -13
  16. data/lib/parklife/rails.rb +25 -3
  17. data/lib/parklife/route.rb +2 -0
  18. data/lib/parklife/route_set.rb +2 -0
  19. data/lib/parklife/templates/Parkfile.erb +48 -0
  20. data/lib/parklife/templates/github_pages.yml +48 -0
  21. data/lib/parklife/templates/static_build.erb +28 -0
  22. data/lib/parklife/utils.rb +7 -0
  23. data/lib/parklife/version.rb +3 -1
  24. data/lib/parklife.rb +2 -0
  25. data/parklife.gemspec +6 -5
  26. metadata +8 -106
  27. data/examples/rack/.gitignore +0 -2
  28. data/examples/rack/Gemfile +0 -4
  29. data/examples/rack/Parkfile +0 -21
  30. data/examples/rails/.gitignore +0 -28
  31. data/examples/rails/Gemfile +0 -5
  32. data/examples/rails/Parkfile +0 -6
  33. data/examples/rails/Rakefile +0 -6
  34. data/examples/rails/app/assets/config/manifest.js +0 -2
  35. data/examples/rails/app/assets/images/.keep +0 -0
  36. data/examples/rails/app/assets/stylesheets/application.css +0 -15
  37. data/examples/rails/app/assets/stylesheets/global.css +0 -4
  38. data/examples/rails/app/controllers/application_controller.rb +0 -2
  39. data/examples/rails/app/controllers/posts_controller.rb +0 -9
  40. data/examples/rails/app/helpers/application_helper.rb +0 -2
  41. data/examples/rails/app/jobs/application_job.rb +0 -2
  42. data/examples/rails/app/models/application_record.rb +0 -3
  43. data/examples/rails/app/models/post.rb +0 -5
  44. data/examples/rails/app/views/layouts/application.html.erb +0 -14
  45. data/examples/rails/app/views/posts/index.html.erb +0 -7
  46. data/examples/rails/app/views/posts/show.html.erb +0 -3
  47. data/examples/rails/bin/bundle +0 -3
  48. data/examples/rails/bin/rails +0 -4
  49. data/examples/rails/bin/rake +0 -4
  50. data/examples/rails/bin/setup +0 -33
  51. data/examples/rails/bin/update +0 -28
  52. data/examples/rails/config/application.rb +0 -35
  53. data/examples/rails/config/boot.rb +0 -3
  54. data/examples/rails/config/database.yml +0 -25
  55. data/examples/rails/config/environment.rb +0 -5
  56. data/examples/rails/config/environments/development.rb +0 -53
  57. data/examples/rails/config/environments/production.rb +0 -79
  58. data/examples/rails/config/environments/test.rb +0 -36
  59. data/examples/rails/config/initializers/application_controller_renderer.rb +0 -8
  60. data/examples/rails/config/initializers/assets.rb +0 -12
  61. data/examples/rails/config/initializers/backtrace_silencers.rb +0 -7
  62. data/examples/rails/config/initializers/content_security_policy.rb +0 -25
  63. data/examples/rails/config/initializers/cookies_serializer.rb +0 -5
  64. data/examples/rails/config/initializers/filter_parameter_logging.rb +0 -4
  65. data/examples/rails/config/initializers/inflections.rb +0 -16
  66. data/examples/rails/config/initializers/mime_types.rb +0 -4
  67. data/examples/rails/config/initializers/wrap_parameters.rb +0 -14
  68. data/examples/rails/config/locales/en.yml +0 -33
  69. data/examples/rails/config/routes.rb +0 -5
  70. data/examples/rails/config.ru +0 -5
  71. data/examples/rails/data/1-hello-from-parklife.txt +0 -3
  72. data/examples/rails/data/2-hello-again.txt +0 -3
  73. data/examples/rails/data/3-magic-number.txt +0 -3
  74. data/examples/rails/db/migrate/20190507172823_create_posts.rb +0 -11
  75. data/examples/rails/db/schema.rb +0 -24
  76. data/examples/rails/db/seeds.rb +0 -10
  77. data/examples/rails/parklife-build +0 -25
  78. data/examples/rails/public/404.html +0 -67
  79. data/examples/rails/public/422.html +0 -67
  80. data/examples/rails/public/500.html +0 -66
  81. data/examples/rails/public/apple-touch-icon-precomposed.png +0 -0
  82. data/examples/rails/public/apple-touch-icon.png +0 -0
  83. data/examples/rails/public/favicon.ico +0 -0
  84. data/examples/rails/public/robots.txt +0 -1
  85. data/examples/sinatra/.gitignore +0 -2
  86. data/examples/sinatra/Gemfile +0 -4
  87. data/examples/sinatra/Parkfile +0 -19
@@ -1,8 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # ActiveSupport::Reloader.to_prepare do
4
- # ApplicationController.renderer.defaults.merge!(
5
- # http_host: 'example.org',
6
- # https: false
7
- # )
8
- # end
@@ -1,12 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Version of your assets, change this if you want to expire all your assets.
4
- Rails.application.config.assets.version = '1.0'
5
-
6
- # Add additional assets to the asset load path.
7
- # Rails.application.config.assets.paths << Emoji.images_path
8
-
9
- # Precompile additional assets.
10
- # application.js, application.css, and all non-JS/CSS in the app/assets
11
- # folder are already added.
12
- # Rails.application.config.assets.precompile += %w( admin.js admin.css )
@@ -1,7 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
- # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
-
6
- # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
- # Rails.backtrace_cleaner.remove_silencers!
@@ -1,25 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Define an application-wide content security policy
4
- # For further information see the following documentation
5
- # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
6
-
7
- # Rails.application.config.content_security_policy do |policy|
8
- # policy.default_src :self, :https
9
- # policy.font_src :self, :https, :data
10
- # policy.img_src :self, :https, :data
11
- # policy.object_src :none
12
- # policy.script_src :self, :https
13
- # policy.style_src :self, :https
14
-
15
- # # Specify URI for violation reports
16
- # # policy.report_uri "/csp-violation-report-endpoint"
17
- # end
18
-
19
- # If you are using UJS then enable automatic nonce generation
20
- # Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
21
-
22
- # Report CSP violations to a specified URI
23
- # For further information see the following documentation:
24
- # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
25
- # Rails.application.config.content_security_policy_report_only = true
@@ -1,5 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Specify a serializer for the signed and encrypted cookie jars.
4
- # Valid options are :json, :marshal, and :hybrid.
5
- Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -1,4 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Configure sensitive parameters which will be filtered from the log file.
4
- Rails.application.config.filter_parameters += [:password]
@@ -1,16 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Add new inflection rules using the following format. Inflections
4
- # are locale specific, and you may define rules for as many different
5
- # locales as you wish. All of these examples are active by default:
6
- # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
- # inflect.plural /^(ox)$/i, '\1en'
8
- # inflect.singular /^(ox)en/i, '\1'
9
- # inflect.irregular 'person', 'people'
10
- # inflect.uncountable %w( fish sheep )
11
- # end
12
-
13
- # These inflection rules are supported but not enabled by default:
14
- # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
- # inflect.acronym 'RESTful'
16
- # end
@@ -1,4 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Add new mime types for use in respond_to blocks:
4
- # Mime::Type.register "text/richtext", :rtf
@@ -1,14 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # This file contains settings for ActionController::ParamsWrapper which
4
- # is enabled by default.
5
-
6
- # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
- ActiveSupport.on_load(:action_controller) do
8
- wrap_parameters format: [:json]
9
- end
10
-
11
- # To enable root element in JSON for ActiveRecord objects.
12
- # ActiveSupport.on_load(:active_record) do
13
- # self.include_root_in_json = true
14
- # end
@@ -1,33 +0,0 @@
1
- # Files in the config/locales directory are used for internationalization
2
- # and are automatically loaded by Rails. If you want to use locales other
3
- # than English, add the necessary files in this directory.
4
- #
5
- # To use the locales, use `I18n.t`:
6
- #
7
- # I18n.t 'hello'
8
- #
9
- # In views, this is aliased to just `t`:
10
- #
11
- # <%= t('hello') %>
12
- #
13
- # To use a different locale, set it with `I18n.locale`:
14
- #
15
- # I18n.locale = :es
16
- #
17
- # This would use the information in config/locales/es.yml.
18
- #
19
- # The following keys must be escaped otherwise they will not be retrieved by
20
- # the default I18n backend:
21
- #
22
- # true, false, on, off, yes, no
23
- #
24
- # Instead, surround them with single quotes.
25
- #
26
- # en:
27
- # 'true': 'foo'
28
- #
29
- # To learn more, please read the Rails Internationalization guide
30
- # available at http://guides.rubyonrails.org/i18n.html.
31
-
32
- en:
33
- hello: "Hello world"
@@ -1,5 +0,0 @@
1
- Rails.application.routes.draw do
2
- root to: 'posts#index'
3
-
4
- resources :posts
5
- end
@@ -1,5 +0,0 @@
1
- # This file is used by Rack-based servers to start the application.
2
-
3
- require_relative 'config/environment'
4
-
5
- run Rails.application
@@ -1,3 +0,0 @@
1
- Hello from Parklife
2
-
3
- Some token body content.
@@ -1,3 +0,0 @@
1
- Hello again!
2
-
3
- Oops.
@@ -1,3 +0,0 @@
1
- Three is the magic number
2
-
3
- Yes it is.
@@ -1,11 +0,0 @@
1
- class CreatePosts < ActiveRecord::Migration[5.2]
2
- def change
3
- create_table :posts do |t|
4
- t.string :slug, null: false
5
- t.string :title, null: false
6
- t.text :body
7
- t.timestamps
8
- t.index :slug, unique: true
9
- end
10
- end
11
- end
@@ -1,24 +0,0 @@
1
- # This file is auto-generated from the current state of the database. Instead
2
- # of editing this file, please use the migrations feature of Active Record to
3
- # incrementally modify your database, and then regenerate this schema definition.
4
- #
5
- # Note that this schema.rb definition is the authoritative source for your
6
- # database schema. If you need to create the application database on another
7
- # system, you should be using db:schema:load, not running all the migrations
8
- # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
- # you'll amass, the slower it'll run and the greater likelihood for issues).
10
- #
11
- # It's strongly recommended that you check this file into your version control system.
12
-
13
- ActiveRecord::Schema.define(version: 2019_05_07_172823) do
14
-
15
- create_table "posts", force: :cascade do |t|
16
- t.string "slug", null: false
17
- t.string "title", null: false
18
- t.text "body"
19
- t.datetime "created_at", null: false
20
- t.datetime "updated_at", null: false
21
- t.index ["slug"], name: "index_posts_on_slug", unique: true
22
- end
23
-
24
- end
@@ -1,10 +0,0 @@
1
- Rails.root.join('data').children.each do |path|
2
- id, slug = path.basename('.*').to_s.split('-', 2)
3
- title, rest = path.read.split("\n", 2)
4
-
5
- post = Post.find_or_initialize_by(id: id)
6
- post.body = rest
7
- post.slug = slug
8
- post.title = title
9
- post.save!
10
- end
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env sh
2
-
3
- set -eu
4
-
5
- export RAILS_ENV=production
6
- export SECRET_KEY_BASE=secret
7
-
8
- # Create a production SQLite database and populate it with the app's data (see
9
- # db/seeds.rb for how).
10
- bundle exec rails db:setup
11
-
12
- # Generate production-optimised assets with Sprockets and friends. This must be
13
- # done before generating the Parklife build as Rails will blow up if it detects
14
- # missing assets at runtime.
15
- bundle exec rails assets:precompile
16
-
17
- # Generate the Parklife build.
18
- bundle exec parklife build
19
-
20
- # Copy everything in /public to the build directory -- this includes the newly
21
- # generated sprockets assets and things like favicon.ico and robots.txt.
22
- cp -R public/* build
23
-
24
- # List everything in the final build -- useful debug output.
25
- find build -type f | sort
@@ -1,67 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- .rails-default-error-page {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
-
15
- .rails-default-error-page div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- .rails-default-error-page div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- .rails-default-error-page h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- .rails-default-error-page div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body class="rails-default-error-page">
58
- <!-- This file lives in public/404.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>The page you were looking for doesn't exist.</h1>
62
- <p>You may have mistyped the address or the page may have moved.</p>
63
- </div>
64
- <p>If you are the application owner check the logs for more information.</p>
65
- </div>
66
- </body>
67
- </html>
@@ -1,67 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The change you wanted was rejected (422)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- .rails-default-error-page {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
-
15
- .rails-default-error-page div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- .rails-default-error-page div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- .rails-default-error-page h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- .rails-default-error-page div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body class="rails-default-error-page">
58
- <!-- This file lives in public/422.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>The change you wanted was rejected.</h1>
62
- <p>Maybe you tried to change something you didn't have access to.</p>
63
- </div>
64
- <p>If you are the application owner check the logs for more information.</p>
65
- </div>
66
- </body>
67
- </html>
@@ -1,66 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- .rails-default-error-page {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
-
15
- .rails-default-error-page div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- .rails-default-error-page div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- .rails-default-error-page h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- .rails-default-error-page div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body class="rails-default-error-page">
58
- <!-- This file lives in public/500.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>We're sorry, but something went wrong.</h1>
62
- </div>
63
- <p>If you are the application owner check the logs for more information.</p>
64
- </div>
65
- </body>
66
- </html>
File without changes
File without changes
@@ -1 +0,0 @@
1
- # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
@@ -1,2 +0,0 @@
1
- Gemfile.lock
2
- build
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'parklife', path: '../..'
4
- gem 'sinatra'
@@ -1,19 +0,0 @@
1
- require 'sinatra'
2
-
3
- get '/' do
4
- '<a href="/hello/foo">foo</foo>, <a href="/hello/bar">bar</foo>, <a href="/hello/baz">baz</foo>'
5
- end
6
-
7
- get '/hello/:name' do
8
- "Hello #{params[:name]}"
9
- end
10
-
11
- Parklife.application.configure do |config|
12
- config.app = Sinatra::Application
13
- end
14
-
15
- Parklife.application.routes do
16
- root crawl: true
17
-
18
- get '/hello/other'
19
- end