├── log └── .keep ├── tmp └── .keep ├── vendor └── .keep ├── lib ├── assets │ └── .keep └── tasks │ └── .keep ├── public ├── favicon.ico ├── apple-touch-icon.png ├── apple-touch-icon-precomposed.png ├── robots.txt ├── 500.html ├── 422.html └── 404.html ├── app ├── assets │ ├── images │ │ └── .keep │ ├── javascripts │ │ ├── channels │ │ │ └── .keep │ │ ├── submissions.js │ │ ├── cable.js │ │ └── application.js │ ├── config │ │ └── manifest.js │ └── stylesheets │ │ ├── submissions.scss │ │ └── application.scss ├── models │ ├── concerns │ │ └── .keep │ ├── submission.rb │ └── application_record.rb ├── controllers │ ├── concerns │ │ └── .keep │ ├── application_controller.rb │ ├── microformats_controller.rb │ └── submissions_controller.rb ├── views │ ├── layouts │ │ ├── mailer.text.erb │ │ ├── mailer.html.erb │ │ └── application.html.erb │ └── submissions │ │ ├── show.html.erb │ │ ├── new.html.erb │ │ └── _form.html.erb ├── helpers │ ├── application_helper.rb │ ├── microformats_helper.rb │ └── submissions_helper.rb ├── jobs │ └── application_job.rb ├── channels │ └── application_cable │ │ ├── channel.rb │ │ └── connection.rb └── mailers │ └── application_mailer.rb ├── .rspec ├── Procfile ├── package.json ├── bin ├── bundle ├── rake ├── rails ├── yarn ├── spring ├── update └── setup ├── config ├── spring.rb ├── boot.rb ├── environment.rb ├── routes.rb ├── initializers │ ├── mime_types.rb │ ├── application_controller_renderer.rb │ ├── filter_parameter_logging.rb │ ├── cookies_serializer.rb │ ├── backtrace_silencers.rb │ ├── wrap_parameters.rb │ ├── assets.rb │ └── inflections.rb ├── cable.yml ├── database.yml ├── application.rb ├── locales │ └── en.yml ├── secrets.yml ├── environments │ ├── test.rb │ ├── development.rb │ └── production.rb └── puma.rb ├── config.ru ├── spec ├── models │ └── submission_spec.rb ├── views │ ├── microformats │ │ └── show.html.erb_spec.rb │ └── submissions │ │ ├── new.html.erb_spec.rb │ │ └── show.html.erb_spec.rb ├── factories │ └── submissions.rb ├── controllers │ ├── microformats_controller_spec.rb │ └── submissions_controller_spec.rb ├── requests │ └── submissions_spec.rb ├── helpers │ ├── submissions_helper_spec.rb │ └── microformats_helper_spec.rb ├── routing │ └── submissions_routing_spec.rb ├── rails_helper.rb └── spec_helper.rb ├── Rakefile ├── db ├── migrate │ └── 20170516194159_create_submissions.rb ├── seeds.rb └── schema.rb ├── .gitignore ├── Gemfile ├── .rubocop.yml ├── README.md ├── CODE_OF_CONDUCT.md ├── LICENSE.md └── Gemfile.lock /log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tmp/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/apple-touch-icon.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --require spec_helper 2 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/assets/javascripts/channels/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/apple-touch-icon-precomposed.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.text.erb: -------------------------------------------------------------------------------- 1 | <%= yield %> 2 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/microformats_helper.rb: -------------------------------------------------------------------------------- 1 | module MicroformatsHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/submissions_helper.rb: -------------------------------------------------------------------------------- 1 | module SubmissionsHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/models/submission.rb: -------------------------------------------------------------------------------- 1 | class Submission < ApplicationRecord 2 | end 3 | -------------------------------------------------------------------------------- /app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | class ApplicationJob < ActiveJob::Base 2 | end 3 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | release: bundle exec rake db:migrate 2 | web: bundle exec puma -C config/puma.rb 3 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "microformats-ruby-parser", 3 | "private": true, 4 | "dependencies": {} 5 | } 6 | -------------------------------------------------------------------------------- /app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | self.abstract_class = true 3 | end 4 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | -------------------------------------------------------------------------------- /app/channels/application_cable/channel.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Channel < ActionCable::Channel::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/assets/config/manifest.js: -------------------------------------------------------------------------------- 1 | //= link_tree ../images 2 | //= link_directory ../javascripts .js 3 | //= link_directory ../stylesheets .css 4 | -------------------------------------------------------------------------------- /app/channels/application_cable/connection.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Connection < ActionCable::Connection::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | protect_from_forgery with: :exception 3 | end 4 | -------------------------------------------------------------------------------- /app/mailers/application_mailer.rb: -------------------------------------------------------------------------------- 1 | class ApplicationMailer < ActionMailer::Base 2 | default from: 'from@example.com' 3 | layout 'mailer' 4 | end 5 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /config/spring.rb: -------------------------------------------------------------------------------- 1 | %w[ 2 | .ruby-version 3 | .rbenv-vars 4 | tmp/restart.txt 5 | tmp/caching-dev.txt 6 | ].each { |path| Spring.watch(path) } 7 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require_relative 'config/environment' 4 | 5 | run Rails.application 6 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require_relative 'application' 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /spec/models/submission_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe Submission, type: :model do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /app/assets/javascripts/submissions.js: -------------------------------------------------------------------------------- 1 | // Place all the behaviors and hooks related to the matching controller here. 2 | // All this logic will automatically be available in application.js. 3 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | root to: 'submissions#new' 3 | 4 | resources :submissions 5 | get 'microformats', to: 'microformats#show', as: :microformats 6 | end 7 | -------------------------------------------------------------------------------- /config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 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 5 | -------------------------------------------------------------------------------- /spec/views/microformats/show.html.erb_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe 'microformats/show.html.erb', type: :view do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end 6 | -------------------------------------------------------------------------------- /app/assets/stylesheets/submissions.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the submissions controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | -------------------------------------------------------------------------------- /config/cable.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: async 3 | 4 | test: 5 | adapter: async 6 | 7 | production: 8 | adapter: redis 9 | url: redis://localhost:6379/1 10 | channel_prefix: microformats-ruby-parser_production 11 | -------------------------------------------------------------------------------- /spec/factories/submissions.rb: -------------------------------------------------------------------------------- 1 | FactoryBot.define do 2 | factory :submission do 3 | url 'MyText' 4 | html 'MyText' 5 | base_url 'MyText' 6 | save_html false 7 | render_html_in_page false 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /config/initializers/application_controller_renderer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # ApplicationController.renderer.defaults.merge!( 4 | # http_host: 'example.org', 5 | # https: false 6 | # ) 7 | -------------------------------------------------------------------------------- /config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 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] 5 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require_relative 'config/application' 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path('../spring', __FILE__) 4 | rescue LoadError => e 5 | raise unless e.message.include?('spring') 6 | end 7 | require_relative '../config/boot' 8 | require 'rake' 9 | Rake.application.run 10 | -------------------------------------------------------------------------------- /config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 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 6 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path('../spring', __FILE__) 4 | rescue LoadError => e 5 | raise unless e.message.include?('spring') 6 | end 7 | APP_PATH = File.expand_path('../config/application', __dir__) 8 | require_relative '../config/boot' 9 | require 'rails/commands' 10 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | -------------------------------------------------------------------------------- /spec/controllers/microformats_controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe MicroformatsController, type: :controller do 4 | describe 'GET #show' do 5 | it 'returns http redirect' do 6 | get :show 7 | expect(response).to have_http_status(:redirect) 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /spec/requests/submissions_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe 'Submissions', type: :request do 4 | describe 'GET /submissions' do 5 | it 'works! (now write some real specs)' do 6 | get submissions_path 7 | expect(response).to have_http_status(:redirect) 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /app/views/submissions/show.html.erb: -------------------------------------------------------------------------------- 1 | <%= render "form", submission: @submission %> 2 | 3 | <% if @submission.render_html_in_page? %> 4 |
5 |
6 | Rendered HTML 7 |
8 | 9 |
10 | <%= simple_format @submission.html %> 11 |
12 |
13 | <% end %> 14 | -------------------------------------------------------------------------------- /db/migrate/20170516194159_create_submissions.rb: -------------------------------------------------------------------------------- 1 | class CreateSubmissions < ActiveRecord::Migration[5.1] 2 | def change 3 | create_table :submissions do |t| 4 | t.text :html 5 | t.text :base_url 6 | t.text :json 7 | t.boolean :save_html 8 | t.boolean :render_html_in_page 9 | 10 | t.timestamps 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /bin/yarn: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | VENDOR_PATH = File.expand_path('..', __dir__) 3 | Dir.chdir(VENDOR_PATH) do 4 | begin 5 | exec "yarnpkg #{ARGV.join(" ")}" 6 | rescue Errno::ENOENT 7 | $stderr.puts "Yarn executable was not detected in the system." 8 | $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" 9 | exit 1 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) 7 | # Character.create(name: 'Luke', movie: movies.first) 8 | -------------------------------------------------------------------------------- /app/assets/javascripts/cable.js: -------------------------------------------------------------------------------- 1 | // Action Cable provides the framework to deal with WebSockets in Rails. 2 | // You can generate new channels where WebSocket features live using the `rails generate channel` command. 3 | // 4 | //= require action_cable 5 | //= require_self 6 | //= require_tree ./channels 7 | 8 | (function() { 9 | this.App || (this.App = {}); 10 | 11 | App.cable = ActionCable.createConsumer(); 12 | 13 | }).call(this); 14 | -------------------------------------------------------------------------------- /app/assets/stylesheets/application.scss: -------------------------------------------------------------------------------- 1 | @import "bootstrap"; 2 | 3 | form { 4 | label { 5 | font-weight: bold; 6 | } 7 | 8 | textarea, 9 | input[type=url], 10 | input[type=text] { 11 | font-family: "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; 12 | } 13 | 14 | .form-control:disabled { 15 | cursor: default; 16 | background: #efefef; 17 | color: black; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 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! 8 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | default: &default 2 | adapter: postgresql 3 | encoding: unicode 4 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 5 | 6 | development: 7 | <<: *default 8 | database: microformats_ruby_parser_development 9 | 10 | test: 11 | <<: *default 12 | database: microformats_ruby_parser_test 13 | 14 | production: 15 | <<: *default 16 | database: microformats_ruby_parser_production 17 | username: microformats_ruby_parser 18 | password: <%= ENV['MICROFORMATS_PARSER_DATABASE_PASSWORD'] %> 19 | -------------------------------------------------------------------------------- /spec/helpers/submissions_helper_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | # Specs in this file have access to a helper object that includes 4 | # the SubmissionsHelper. For example: 5 | # 6 | # describe SubmissionsHelper do 7 | # describe "string concat" do 8 | # it "concats two strings with spaces" do 9 | # expect(helper.concat_strings("this","that")).to eq("this that") 10 | # end 11 | # end 12 | # end 13 | RSpec.describe SubmissionsHelper, type: :helper do 14 | pending "add some examples to (or delete) #{__FILE__}" 15 | end 16 | -------------------------------------------------------------------------------- /spec/helpers/microformats_helper_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | # Specs in this file have access to a helper object that includes 4 | # the MicroformatsHelper. For example: 5 | # 6 | # describe MicroformatsHelper do 7 | # describe "string concat" do 8 | # it "concats two strings with spaces" do 9 | # expect(helper.concat_strings("this","that")).to eq("this that") 10 | # end 11 | # end 12 | # end 13 | RSpec.describe MicroformatsHelper, type: :helper do 14 | pending "add some examples to (or delete) #{__FILE__}" 15 | end 16 | -------------------------------------------------------------------------------- /config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 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 15 | -------------------------------------------------------------------------------- /bin/spring: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # This file loads spring without using Bundler, in order to be fast. 4 | # It gets overwritten when you run the `spring binstub` command. 5 | 6 | unless defined?(Spring) 7 | require 'rubygems' 8 | require 'bundler' 9 | 10 | lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) 11 | spring = lockfile.specs.detect { |spec| spec.name == "spring" } 12 | if spring 13 | Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path 14 | gem 'spring', spring.version 15 | require 'spring/binstub' 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /app/views/submissions/new.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_with url: "/microformats", method: "get", local: true do |form| %> 2 |
3 | <%= form.label :url, "Enter a URL" %> 4 | <%= form.url_field :url, id: :submission_url, placeholder: "https://example.com/person.html", class: "form-control form-control-lg" %> 5 |
6 | 7 |
8 | 9 |
10 | <% end %> 11 | 12 | 13 |

OR parse just a snippet of HTML

14 | 15 | 16 | <%= render "form", submission: @submission %> 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore the default SQLite database. 11 | /db/*.sqlite3 12 | /db/*.sqlite3-journal 13 | 14 | # Ignore all logfiles and tempfiles. 15 | /log/* 16 | /tmp/* 17 | !/log/.keep 18 | !/tmp/.keep 19 | 20 | /node_modules 21 | /yarn-error.log 22 | 23 | .byebug_history 24 | .DS_Store 25 | -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require_relative 'boot' 2 | 3 | require 'rails/all' 4 | 5 | # Require the gems listed in Gemfile, including any gems 6 | # you've limited to :test, :development, or :production. 7 | Bundler.require(*Rails.groups) 8 | 9 | module MicroformatsRubyParserWebsite 10 | class Application < Rails::Application 11 | # Initialize configuration defaults for originally generated Rails version. 12 | config.load_defaults 5.1 13 | 14 | # Settings in config/environments/* take precedence over those specified here. 15 | # Application configuration should go into files in config/initializers 16 | # -- all .rb files in that directory are automatically loaded. 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /config/initializers/assets.rb: -------------------------------------------------------------------------------- 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 | # Add Yarn node_modules folder to the asset load path. 9 | Rails.application.config.assets.paths << Rails.root.join('node_modules') 10 | 11 | # Precompile additional assets. 12 | # application.js, application.css, and all non-JS/CSS in the app/assets 13 | # folder are already added. 14 | # Rails.application.config.assets.precompile += %w( admin.js admin.css ) 15 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 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 17 | -------------------------------------------------------------------------------- /app/assets/javascripts/application.js: -------------------------------------------------------------------------------- 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, or any plugin's 5 | // vendor/assets/javascripts directory 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. JavaScript code in this file should be added after the last require_* statement. 9 | // 10 | // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details 11 | // about supported directives. 12 | // 13 | //= require rails-ujs 14 | //= require_tree . 15 | -------------------------------------------------------------------------------- /app/controllers/microformats_controller.rb: -------------------------------------------------------------------------------- 1 | class MicroformatsController < ApplicationController 2 | def show 3 | if params[:url].present? 4 | doc = Microformats.parse(params[:url].strip) 5 | 6 | results = doc.to_h 7 | 8 | # Add parser debut note to output 9 | results[:debug] = { 10 | package: 'https://rubygems.org/gems/microformats', 11 | version: Microformats::VERSION, 12 | note: [ 13 | 'This output was generated from the microformats-ruby gem available at https://github.com/indieweb/microformats-ruby', 14 | 'Please file any issues with the parser at https://github.com/indieweb/microformats-rubygems/issues' 15 | ] 16 | } 17 | 18 | render json: JSON.pretty_generate(results) 19 | else 20 | redirect_to new_submission_path 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /spec/views/submissions/new.html.erb_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe 'submissions/new', type: :view do 4 | before do 5 | assign(:submission, Submission.new( 6 | html: 'MyText', 7 | base_url: 'MyText', 8 | save_html: false, 9 | render_html_in_page: false 10 | )) 11 | end 12 | 13 | it 'renders new submission form' do 14 | render 15 | 16 | assert_select 'form[action=?][method=?]', submissions_path, 'post' do 17 | assert_select 'textarea[name=?]', 'submission[html]' 18 | 19 | assert_select 'input[name=?]', 'submission[base_url]' 20 | 21 | assert_select 'input[name=?]', 'submission[save_html]' 22 | 23 | assert_select 'input[name=?]', 'submission[render_html_in_page]' 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /bin/update: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'pathname' 3 | require 'fileutils' 4 | include FileUtils 5 | 6 | # path to your application root. 7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) 8 | 9 | def system!(*args) 10 | system(*args) || abort("\n== Command #{args} failed ==") 11 | end 12 | 13 | chdir APP_ROOT do 14 | # This script is a way to update your development environment automatically. 15 | # Add necessary update steps to this file. 16 | 17 | puts '== Installing dependencies ==' 18 | system! 'gem install bundler --conservative' 19 | system('bundle check') || system!('bundle install') 20 | 21 | puts "\n== Updating database ==" 22 | system! 'bin/rails db:migrate' 23 | 24 | puts "\n== Removing old logs and tempfiles ==" 25 | system! 'bin/rails log:clear tmp:clear' 26 | 27 | puts "\n== Restarting application server ==" 28 | system! 'bin/rails restart' 29 | end 30 | -------------------------------------------------------------------------------- /spec/views/submissions/show.html.erb_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe 'submissions/show', type: :view do 4 | before do 5 | @submission = assign(:submission, Submission.create!( 6 | html: 'MyText', 7 | base_url: 'MyText', 8 | save_html: false, 9 | render_html_in_page: false 10 | )) 11 | end 12 | 13 | it 'renders attributes in

' do 14 | render 15 | 16 | assert_select 'form[action=?][method=?]', submission_path(@submission.id), 'post' do 17 | assert_select 'textarea[name=?]', 'submission[html]' 18 | 19 | assert_select 'input[name=?][value=?]', 'submission[base_url]', 'MyText' 20 | 21 | assert_select 'textarea[name=?]', 'submission[json]' 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 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" 34 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'pathname' 3 | require 'fileutils' 4 | include FileUtils 5 | 6 | # path to your application root. 7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) 8 | 9 | def system!(*args) 10 | system(*args) || abort("\n== Command #{args} failed ==") 11 | end 12 | 13 | chdir APP_ROOT do 14 | # This script is a starting point to setup your application. 15 | # Add necessary setup steps to this file. 16 | 17 | puts '== Installing dependencies ==' 18 | system! 'gem install bundler --conservative' 19 | system('bundle check') || system!('bundle install') 20 | 21 | # Install JavaScript dependencies if using Yarn 22 | # system('bin/yarn') 23 | 24 | 25 | # puts "\n== Copying sample files ==" 26 | # unless File.exist?('config/database.yml') 27 | # cp 'config/database.yml.sample', 'config/database.yml' 28 | # end 29 | 30 | puts "\n== Preparing database ==" 31 | system! 'bin/rails db:setup' 32 | 33 | puts "\n== Removing old logs and tempfiles ==" 34 | system! 'bin/rails log:clear tmp:clear' 35 | 36 | puts "\n== Restarting application server ==" 37 | system! 'bin/rails restart' 38 | end 39 | -------------------------------------------------------------------------------- /spec/routing/submissions_routing_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe SubmissionsController, type: :routing do 4 | describe 'routing' do 5 | it 'routes to #index' do 6 | expect(get: '/submissions').to route_to('submissions#index') 7 | end 8 | 9 | it 'routes to #new' do 10 | expect(get: '/submissions/new').to route_to('submissions#new') 11 | end 12 | 13 | it 'routes to #show' do 14 | expect(get: '/submissions/1').to route_to('submissions#show', id: '1') 15 | end 16 | 17 | it 'routes to #edit' do 18 | expect(get: '/submissions/1/edit').to route_to('submissions#edit', id: '1') 19 | end 20 | 21 | it 'routes to #create' do 22 | expect(post: '/submissions').to route_to('submissions#create') 23 | end 24 | 25 | it 'routes to #update via PUT' do 26 | expect(put: '/submissions/1').to route_to('submissions#update', id: '1') 27 | end 28 | 29 | it 'routes to #update via PATCH' do 30 | expect(patch: '/submissions/1').to route_to('submissions#update', id: '1') 31 | end 32 | 33 | it 'routes to #destroy' do 34 | expect(delete: '/submissions/1').to route_to('submissions#destroy', id: '1') 35 | end 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /db/schema.rb: -------------------------------------------------------------------------------- 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: 2017_05_16_194159) do 14 | 15 | # These are extensions that must be enabled in order to support this database 16 | enable_extension "plpgsql" 17 | 18 | create_table "submissions", force: :cascade do |t| 19 | t.text "html" 20 | t.text "base_url" 21 | t.text "json" 22 | t.boolean "save_html" 23 | t.boolean "render_html_in_page" 24 | t.datetime "created_at", null: false 25 | t.datetime "updated_at", null: false 26 | end 27 | 28 | end 29 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | ruby '3.2.2' 3 | 4 | # app server 5 | gem 'rails', '~> 5.2.0' 6 | 7 | # database 8 | gem 'pg' 9 | 10 | # webserver 11 | gem 'puma' 12 | 13 | # webserver 14 | gem 'microformats', '~> 4.0.7' 15 | 16 | # assets 17 | gem 'autoprefixer-rails' 18 | gem 'bootstrap' 19 | gem 'jquery-rails' 20 | gem 'sass-rails' 21 | gem 'uglifier' 22 | 23 | # For codestyle guide and linting 24 | gem 'rubocop', require: false 25 | gem 'rubocop-rspec' 26 | 27 | # dev and testing 28 | group :development, :test do 29 | gem 'byebug', platform: :mri 30 | gem 'factory_bot_rails' 31 | gem 'guard-rspec' 32 | gem 'nokogiri' 33 | gem 'rails-controller-testing' 34 | gem 'rspec-rails' 35 | gem 'simplecov', require: false 36 | gem 'spring-commands-rspec' 37 | end 38 | 39 | # dev 40 | group :development do 41 | gem 'listen', '~> 3.1.5' 42 | gem 'spring' 43 | gem 'spring-watcher-listen', '~> 2.0.0' 44 | gem 'web-console' 45 | 46 | # For measuring page/code performance 47 | gem 'rack-mini-profiler' 48 | 49 | # For memory profiling 50 | gem 'memory_profiler' 51 | 52 | # For call-stack profiling flamegraphs 53 | gem 'fast_stack' 54 | gem 'flamegraph' 55 | gem 'stackprof' 56 | end 57 | 58 | # windows dev 59 | gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 60 | -------------------------------------------------------------------------------- /config/secrets.yml: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key is used for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | 6 | # Make sure the secret is at least 30 characters and all random, 7 | # no regular words or you'll be exposed to dictionary attacks. 8 | # You can use `rails secret` to generate a secure secret key. 9 | 10 | # Make sure the secrets in this file are kept private 11 | # if you're sharing your code publicly. 12 | 13 | # Shared secrets are available across all environments. 14 | 15 | # shared: 16 | # api_key: a1B2c3D4e5F6 17 | 18 | # Environmental secrets are only available for that specific environment. 19 | 20 | development: 21 | secret_key_base: a1fa807fcd02b00cb6178c9cfaa13511849d2d422686026107fd5718ae32b2e7d1c7033c6166586a64b5860e3d30b97b6bcbabf6d59cc23b2b40c106327c7db1 22 | 23 | test: 24 | secret_key_base: a6f49c98976b002139aaa5920eca7ee7f14123e676cad0d27f05f15d77390de492b9b72e773568adaff83d66cfd260f6dd507fa806e728cf55ff2e4f71e5e070 25 | 26 | # Do not keep production secrets in the unencrypted secrets file. 27 | # Instead, either read values from the environment. 28 | # Or, use `bin/rails secrets:setup` to configure encrypted secrets 29 | # and move the `production:` environment over there. 30 | 31 | production: 32 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> 33 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Ruby Microformats Parser 8 | <%= csrf_meta_tags %> 9 | 10 | <%= stylesheet_link_tag "application", media: "all" %> 11 | <%= javascript_include_tag "application" %> 12 | 13 | 14 | 15 |

16 | 17 | <% if notice.present? %> 18 | 21 | <% end %> 22 | 23 |

24 | <%= link_to_unless_current "Microformats Parser (Ruby) #{Microformats::VERSION}", root_path %> 25 |

26 | 27 | <%= yield %> 28 | 29 | 43 | 44 |
45 | 46 | 47 | -------------------------------------------------------------------------------- /app/controllers/submissions_controller.rb: -------------------------------------------------------------------------------- 1 | class SubmissionsController < ApplicationController 2 | before_action :set_submission, only: [:show, :edit, :update, :destroy] 3 | 4 | # GET /submissions 5 | def index 6 | redirect_to new_submission_path 7 | end 8 | 9 | # GET /submissions/1 10 | def show; end 11 | 12 | # GET /submissions/new 13 | def new 14 | @submission = Submission.new 15 | end 16 | 17 | # GET /submissions/1/edit 18 | def edit 19 | redirect_to new_submission_path 20 | end 21 | 22 | # POST /submissions 23 | def create 24 | @submission = Submission.new(submission_params) 25 | 26 | doc = Microformats.parse(@submission.html, base: @submission.base_url) 27 | json = JSON.pretty_generate(doc.to_h) 28 | 29 | @submission.json = json 30 | 31 | if @submission.save_html? 32 | if @submission.save 33 | redirect_to @submission, notice: 'Submission was successfully created.' 34 | else 35 | render :new 36 | end 37 | else 38 | render :show 39 | end 40 | end 41 | 42 | # PATCH/PUT /submissions/1 43 | def update 44 | redirect_to new_submission_path 45 | end 46 | 47 | # DELETE /submissions/1 48 | def destroy 49 | redirect_to new_submission_path 50 | end 51 | 52 | private 53 | 54 | # Use callbacks to share common setup or constraints between actions. 55 | def set_submission 56 | @submission = Submission.find(params[:id]) 57 | end 58 | 59 | # Only allow a trusted parameter "white list" through. 60 | def submission_params 61 | params.require(:submission).permit(:url, :html, :base_url, :save_html, :render_html_in_page) 62 | end 63 | end 64 | -------------------------------------------------------------------------------- /public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

We're sorry, but something went wrong.

62 |
63 |

If you are the application owner check the logs for more information.

64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Do not eager load code on boot. This avoids loading your whole application 11 | # just for the purpose of running a single test. If you are using a tool that 12 | # preloads Rails for running tests, you may have to set it to true. 13 | config.eager_load = false 14 | 15 | # Configure public file server for tests with Cache-Control for performance. 16 | config.public_file_server.enabled = true 17 | config.public_file_server.headers = { 18 | 'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}" 19 | } 20 | 21 | # Show full error reports and disable caching. 22 | config.consider_all_requests_local = true 23 | config.action_controller.perform_caching = false 24 | 25 | # Raise exceptions instead of rendering exception templates. 26 | config.action_dispatch.show_exceptions = false 27 | 28 | # Disable request forgery protection in test environment. 29 | config.action_controller.allow_forgery_protection = false 30 | config.action_mailer.perform_caching = false 31 | 32 | # Tell Action Mailer not to deliver emails to the real world. 33 | # The :test delivery method accumulates sent emails in the 34 | # ActionMailer::Base.deliveries array. 35 | config.action_mailer.delivery_method = :test 36 | 37 | # Print deprecation notices to the stderr. 38 | config.active_support.deprecation = :stderr 39 | 40 | # Raises error for missing translations 41 | # config.action_view.raise_on_missing_translations = true 42 | end 43 | -------------------------------------------------------------------------------- /public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The change you wanted was rejected.

62 |

Maybe you tried to change something you didn't have access to.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | require: rubocop-rspec 2 | 3 | AllCops: 4 | TargetRubyVersion: 2.5 5 | 6 | Exclude: 7 | - 'db/**/*' 8 | - 'script/*' 9 | - 'bin/*' 10 | - 'log/**/*' 11 | - 'node_modules/**/*' 12 | - 'public/**/*' 13 | - 'vendor/**/*' 14 | - 'tmp/**/*' 15 | - '.git/**/*' 16 | 17 | IndentationConsistency: 18 | EnforcedStyle: 'rails' 19 | 20 | Naming/FileName: 21 | Exclude: 22 | - 'Gemfile' 23 | - 'Guardfile' 24 | - 'Rakefile' 25 | 26 | Rails: 27 | Enabled: true 28 | 29 | Metrics/CyclomaticComplexity: 30 | Max: 15 31 | 32 | Metrics/PerceivedComplexity: 33 | Max: 15 34 | 35 | Metrics/ClassLength: 36 | Max: 210 37 | 38 | Metrics/ParameterLists: 39 | Max: 6 40 | 41 | Metrics/LineLength: 42 | Max: 200 43 | 44 | Metrics/MethodLength: 45 | Max: 40 46 | 47 | Metrics/BlockLength: 48 | Max: 140 49 | 50 | Exclude: 51 | - 'spec/**/*' 52 | 53 | Metrics/AbcSize: 54 | Max: 65 55 | 56 | Style/Documentation: 57 | Enabled: false 58 | 59 | Style/SymbolArray: 60 | Enabled: false 61 | 62 | Style/MethodDefParentheses: 63 | Enabled: false 64 | 65 | Style/AsciiComments: 66 | Enabled: false 67 | 68 | Style/NestedParenthesizedCalls: 69 | Enabled: false 70 | 71 | # TEMP: private and def foo() are at the same indentation level 72 | # This should NOT cause an offense but it does. ¯\_(ツ)_/¯ 73 | # https://rubocop.readthedocs.io/en/latest/cops_layout/ 74 | Layout/IndentationWidth: 75 | Enabled: false 76 | 77 | Style/FrozenStringLiteralComment: 78 | Enabled: false 79 | 80 | Rails/OutputSafety: 81 | Enabled: false 82 | 83 | RSpec/NestedGroups: 84 | Max: 4 85 | 86 | RSpec/ExampleLength: 87 | Max: 20 88 | 89 | RSpec/MultipleExpectations: 90 | Max: 10 91 | 92 | RSpec/VerifiedDoubles: 93 | Enabled: false 94 | 95 | RSpec/MessageSpies: 96 | Enabled: false 97 | 98 | RSpec/DescribeClass: 99 | Exclude: 100 | - 'spec/system/*' 101 | -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The page you were looking for doesn't exist.

62 |

You may have mistyped the address or the page may have moved.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Microformats Ruby Parser Website 2 | 3 | Website for Microformats Ruby parser (based on pin13.net by [@aaronpk](https://github.com/aaronpk)). 4 | 5 | https://ruby.microformats.io 6 | 7 | ## Deployment 8 | 9 | All commits to the `master` branch get auto-deployed to the live website (running on [Heroku](https://ruby.microformats.io)) 10 | 11 | ## Development Status 12 | 13 | Implemented: 14 | 15 | - Parse a website from a pasted URL 16 | - Parse a blob of `HTML` with optional `Base URL` 17 | - Optionally, save `HTML` blob, creating a permalink (a la Gist) 18 | - Optionally, display rendered `HTML` blob on the page 19 | 20 | ## Requirements 21 | 22 | - Rails 23 | - Postgresql 24 | 25 | 26 | ## Installation 27 | 28 | Clone the repo: 29 | 30 | ``` 31 | git clone https://github.com/indieweb/microformats-ruby-parser-website.git 32 | cd microformats-ruby-parser-website 33 | ``` 34 | 35 | Install the dependencies: 36 | 37 | ``` 38 | brew install postgresql 39 | bundle 40 | ``` 41 | 42 | Set up database: 43 | 44 | ``` 45 | rake db:create 46 | rake db:migrate 47 | ``` 48 | 49 | Start the server: 50 | 51 | ``` 52 | rails server 53 | ``` 54 | 55 | Open the site in your browser: 56 | 57 | ``` 58 | open http://localhost:3000 59 | ``` 60 | 61 | 62 | ## Authors 63 | 64 | - Shane Becker / [@veganstraightedge](https://github.com/veganstraightedge) 65 | 66 | ## Contributions 67 | 68 | 1. Fork it 69 | 2. Get it running (see Installation above) 70 | 3. Create your feature branch (`git checkout -b my-new-feature`) 71 | 4. Write your code and **specs** 72 | 5. Commit your changes (`git commit -am 'Add some feature'`) 73 | 6. Push to the branch (`git push origin my-new-feature`) 74 | 7. Create new Pull Request 75 | 76 | If you find bugs, have feature requests or questions, please 77 | [file an issue](https://github.com/indieweb/microformats-parser-website-ruby/issues). 78 | 79 | 80 | ## License 81 | 82 | Microformats Ruby Parser Website is dedicated to the public domain using Creative Commons -- CC0 1.0 Universal. 83 | 84 | http://creativecommons.org/publicdomain/zero/1.0 85 | -------------------------------------------------------------------------------- /app/views/submissions/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_with model: submission, local: true, class: "mb-5" do |form| %> 2 | <% if submission.errors.any? %> 3 |
4 |

<%= pluralize(submission.errors.count, "error") %> prohibited this submission from being saved:

5 | 6 | 11 |
12 | <% end %> 13 | 14 |
15 | <%= form.label :html, "HTML" %> 16 | <%= form.text_area :html, id: :submission_html, class: "form-control form-control-lg", rows: 6, disabled: submission.id.present? %> 17 |
18 | 19 |
20 | <%= form.label :base_url, "Base URL" %> 21 | <%= form.url_field :base_url, id: :submission_base_url, class: "form-control form-control-lg", disabled: submission.id.present? %> 22 |
23 | 24 | <% unless action_name == "new" %> 25 |
26 | <%= form.label :json, "JSON" %> 27 | <%= form.text_area :json, id: :submission_json, class: "form-control form-control-lg", rows: 10, disabled: submission.id.present? %> 28 |
29 | <% end %> 30 | 31 | <% if submission.id.blank? %> 32 |
33 | 39 |
40 | 41 |
42 | 48 |
49 | 50 |
51 | <%= form.submit "Parse", class: "btn btn-lg btn-success" %> 52 |
53 | <% end %> 54 | 55 | <% end %> 56 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Do not eager load code on boot. 10 | config.eager_load = false 11 | 12 | # Show full error reports. 13 | config.consider_all_requests_local = true 14 | 15 | # Enable/disable caching. By default caching is disabled. 16 | if Rails.root.join('tmp', 'caching-dev.txt').exist? 17 | config.action_controller.perform_caching = true 18 | 19 | config.cache_store = :memory_store 20 | config.public_file_server.headers = { 21 | 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}" 22 | } 23 | else 24 | config.action_controller.perform_caching = false 25 | 26 | config.cache_store = :null_store 27 | end 28 | 29 | # Don't care if the mailer can't send. 30 | config.action_mailer.raise_delivery_errors = false 31 | 32 | config.action_mailer.perform_caching = false 33 | 34 | # Print deprecation notices to the Rails logger. 35 | config.active_support.deprecation = :log 36 | 37 | # Raise an error on page load if there are pending migrations. 38 | config.active_record.migration_error = :page_load 39 | 40 | # Debug mode disables concatenation and preprocessing of assets. 41 | # This option may cause significant delays in view rendering with a large 42 | # number of complex assets. 43 | config.assets.debug = true 44 | 45 | # Suppress logger output for asset requests. 46 | config.assets.quiet = true 47 | 48 | # Raises error for missing translations 49 | # config.action_view.raise_on_missing_translations = true 50 | 51 | # Use an evented file watcher to asynchronously detect changes in source code, 52 | # routes, locales, etc. This feature depends on the listen gem. 53 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker 54 | end 55 | -------------------------------------------------------------------------------- /config/puma.rb: -------------------------------------------------------------------------------- 1 | # Puma can serve each request in a thread from an internal thread pool. 2 | # The `threads` method setting takes two numbers: a minimum and maximum. 3 | # Any libraries that use thread pools should be configured to match 4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum 5 | # and maximum; this matches the default thread size of Active Record. 6 | # 7 | threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 } 8 | threads threads_count, threads_count 9 | 10 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000. 11 | # 12 | port ENV.fetch('PORT') { 3000 } 13 | 14 | # Specifies the `environment` that Puma will run in. 15 | # 16 | environment ENV.fetch('RAILS_ENV') { 'development' } 17 | 18 | # Specifies the number of `workers` to boot in clustered mode. 19 | # Workers are forked webserver processes. If using threads and workers together 20 | # the concurrency of the application would be max `threads` * `workers`. 21 | # Workers do not work on JRuby or Windows (both of which do not support 22 | # processes). 23 | # 24 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 } 25 | 26 | # Use the `preload_app!` method when specifying a `workers` number. 27 | # This directive tells Puma to first boot the application and load code 28 | # before forking the application. This takes advantage of Copy On Write 29 | # process behavior so workers use less memory. If you use this option 30 | # you need to make sure to reconnect any threads in the `on_worker_boot` 31 | # block. 32 | # 33 | # preload_app! 34 | 35 | # If you are preloading your application and using Active Record, it's 36 | # recommended that you close any connections to the database before workers 37 | # are forked to prevent connection leakage. 38 | # 39 | # before_fork do 40 | # ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord) 41 | # end 42 | 43 | # The code in the `on_worker_boot` will be called if you are using 44 | # clustered mode by specifying a number of `workers`. After each worker 45 | # process is booted, this block will be run. If you are using the `preload_app!` 46 | # option, you will want to use this block to reconnect to any threads 47 | # or connections that may have been created at application boot, as Ruby 48 | # cannot share connections between processes. 49 | # 50 | # on_worker_boot do 51 | # ActiveRecord::Base.establish_connection if defined?(ActiveRecord) 52 | # end 53 | # 54 | 55 | # Allow puma to be restarted by `rails restart` command. 56 | plugin :tmp_restart 57 | -------------------------------------------------------------------------------- /spec/rails_helper.rb: -------------------------------------------------------------------------------- 1 | # This file is copied to spec/ when you run 'rails generate rspec:install' 2 | require 'spec_helper' 3 | ENV['RAILS_ENV'] ||= 'test' 4 | require File.expand_path('../config/environment', __dir__) 5 | # Prevent database truncation if the environment is production 6 | abort('The Rails environment is running in production mode!') if Rails.env.production? 7 | require 'rspec/rails' 8 | # Add additional requires below this line. Rails is not loaded until this point! 9 | 10 | # Requires supporting ruby files with custom matchers and macros, etc, in 11 | # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are 12 | # run as spec files by default. This means that files in spec/support that end 13 | # in _spec.rb will both be required and run as specs, causing the specs to be 14 | # run twice. It is recommended that you do not name files matching this glob to 15 | # end with _spec.rb. You can configure this pattern with the --pattern 16 | # option on the command line or in ~/.rspec, .rspec or `.rspec-local`. 17 | # 18 | # The following line is provided for convenience purposes. It has the downside 19 | # of increasing the boot-up time by auto-requiring all files in the support 20 | # directory. Alternatively, in the individual `*_spec.rb` files, manually 21 | # require only the support files necessary. 22 | # 23 | # Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } 24 | 25 | # Checks for pending migration and applies them before tests are run. 26 | # If you are not using ActiveRecord, you can remove this line. 27 | ActiveRecord::Migration.maintain_test_schema! 28 | 29 | RSpec.configure do |config| 30 | # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures 31 | config.fixture_path = "#{::Rails.root}/spec/fixtures" 32 | 33 | # If you're not using ActiveRecord, or you'd prefer not to run each of your 34 | # examples within a transaction, remove the following line or assign false 35 | # instead of true. 36 | config.use_transactional_fixtures = true 37 | 38 | # RSpec Rails can automatically mix in different behaviours to your tests 39 | # based on their file location, for example enabling you to call `get` and 40 | # `post` in specs under `spec/controllers`. 41 | # 42 | # You can disable this behaviour by removing the line below, and instead 43 | # explicitly tag your specs with their type, e.g.: 44 | # 45 | # RSpec.describe UsersController, :type => :controller do 46 | # # ... 47 | # end 48 | # 49 | # The different available types are documented in the features, such as in 50 | # https://relishapp.com/rspec/rspec-rails/docs 51 | config.infer_spec_type_from_file_location! 52 | 53 | # Filter lines from Rails gems in backtraces. 54 | config.filter_rails_from_backtrace! 55 | # arbitrary gems may also be filtered via: 56 | # config.filter_gems_from_backtrace("gem name") 57 | end 58 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at veganstraightedge@gmail.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at [http://contributor-covenant.org/version/1/4][version] 72 | 73 | [homepage]: http://contributor-covenant.org 74 | [version]: http://contributor-covenant.org/version/1/4/ 75 | -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # Code is not reloaded between requests. 5 | config.cache_classes = true 6 | 7 | # Eager load code on boot. This eager loads most of Rails and 8 | # your application in memory, allowing both threaded web servers 9 | # and those relying on copy on write to perform better. 10 | # Rake tasks automatically ignore this option for performance. 11 | config.eager_load = true 12 | 13 | # Full error reports are disabled and caching is turned on. 14 | config.consider_all_requests_local = false 15 | config.action_controller.perform_caching = true 16 | 17 | # Attempt to read encrypted secrets from `config/secrets.yml.enc`. 18 | # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or 19 | # `config/secrets.yml.key`. 20 | config.read_encrypted_secrets = true 21 | 22 | # Disable serving static files from the `/public` folder by default since 23 | # Apache or NGINX already handles this. 24 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? 25 | 26 | # Compress JavaScripts and CSS. 27 | config.assets.js_compressor = :uglifier 28 | # config.assets.css_compressor = :sass 29 | 30 | # Do not fallback to assets pipeline if a precompiled asset is missed. 31 | config.assets.compile = false 32 | 33 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb 34 | 35 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 36 | # config.action_controller.asset_host = 'http://assets.example.com' 37 | 38 | # Specifies the header that your server uses for sending files. 39 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache 40 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX 41 | 42 | # Mount Action Cable outside main process or domain 43 | # config.action_cable.mount_path = nil 44 | # config.action_cable.url = 'wss://example.com/cable' 45 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] 46 | 47 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 48 | # config.force_ssl = true 49 | 50 | # Use the lowest log level to ensure availability of diagnostic information 51 | # when problems arise. 52 | config.log_level = :debug 53 | 54 | # Prepend all log lines with the following tags. 55 | config.log_tags = [:request_id] 56 | 57 | # Use a different cache store in production. 58 | # config.cache_store = :mem_cache_store 59 | 60 | # Use a real queuing backend for Active Job (and separate queues per environment) 61 | # config.active_job.queue_adapter = :resque 62 | # config.active_job.queue_name_prefix = "microformats-ruby-parser_#{Rails.env}" 63 | config.action_mailer.perform_caching = false 64 | 65 | # Ignore bad email addresses and do not raise email delivery errors. 66 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 67 | # config.action_mailer.raise_delivery_errors = false 68 | 69 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 70 | # the I18n.default_locale when a translation cannot be found). 71 | config.i18n.fallbacks = true 72 | 73 | # Send deprecation notices to registered listeners. 74 | config.active_support.deprecation = :notify 75 | 76 | # Use default logging formatter so that PID and timestamp are not suppressed. 77 | config.log_formatter = ::Logger::Formatter.new 78 | 79 | # Use a different logger for distributed setups. 80 | # require 'syslog/logger' 81 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') 82 | 83 | if ENV['RAILS_LOG_TO_STDOUT'].present? 84 | logger = ActiveSupport::Logger.new(STDOUT) 85 | logger.formatter = config.log_formatter 86 | config.logger = ActiveSupport::TaggedLogging.new(logger) 87 | end 88 | 89 | # Do not dump schema after migrations. 90 | config.active_record.dump_schema_after_migration = false 91 | end 92 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # This file was generated by the `rails generate rspec:install` command. Conventionally, all 2 | # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. 3 | # The generated `.rspec` file contains `--require spec_helper` which will cause 4 | # this file to always be loaded, without a need to explicitly require it in any 5 | # files. 6 | # 7 | # Given that it is always loaded, you are encouraged to keep this file as 8 | # light-weight as possible. Requiring heavyweight dependencies from this file 9 | # will add to the boot time of your test suite on EVERY test run, even for an 10 | # individual file that may not need all of that loaded. Instead, consider making 11 | # a separate helper file that requires the additional dependencies and performs 12 | # the additional setup, and require it from the spec files that actually need 13 | # it. 14 | # 15 | # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration 16 | RSpec.configure do |config| 17 | # rspec-expectations config goes here. You can use an alternate 18 | # assertion/expectation library such as wrong or the stdlib/minitest 19 | # assertions if you prefer. 20 | config.expect_with :rspec do |expectations| 21 | # This option will default to `true` in RSpec 4. It makes the `description` 22 | # and `failure_message` of custom matchers include text for helper methods 23 | # defined using `chain`, e.g.: 24 | # be_bigger_than(2).and_smaller_than(4).description 25 | # # => "be bigger than 2 and smaller than 4" 26 | # ...rather than: 27 | # # => "be bigger than 2" 28 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true 29 | end 30 | 31 | # rspec-mocks config goes here. You can use an alternate test double 32 | # library (such as bogus or mocha) by changing the `mock_with` option here. 33 | config.mock_with :rspec do |mocks| 34 | # Prevents you from mocking or stubbing a method that does not exist on 35 | # a real object. This is generally recommended, and will default to 36 | # `true` in RSpec 4. 37 | mocks.verify_partial_doubles = true 38 | end 39 | 40 | # This option will default to `:apply_to_host_groups` in RSpec 4 (and will 41 | # have no way to turn it off -- the option exists only for backwards 42 | # compatibility in RSpec 3). It causes shared context metadata to be 43 | # inherited by the metadata hash of host groups and examples, rather than 44 | # triggering implicit auto-inclusion in groups with matching metadata. 45 | config.shared_context_metadata_behavior = :apply_to_host_groups 46 | 47 | # The settings below are suggested to provide a good initial experience 48 | # with RSpec, but feel free to customize to your heart's content. 49 | 50 | # This allows you to limit a spec run to individual examples or groups 51 | # you care about by tagging them with `:focus` metadata. When nothing 52 | # is tagged with `:focus`, all examples get run. RSpec also provides 53 | # aliases for `it`, `describe`, and `context` that include `:focus` 54 | # metadata: `fit`, `fdescribe` and `fcontext`, respectively. 55 | # config.filter_run_when_matching :focus 56 | 57 | # Allows RSpec to persist some state between runs in order to support 58 | # the `--only-failures` and `--next-failure` CLI options. We recommend 59 | # you configure your source control system to ignore this file. 60 | # config.example_status_persistence_file_path = "spec/examples.txt" 61 | 62 | # Limits the available syntax to the non-monkey patched syntax that is 63 | # recommended. For more details, see: 64 | # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ 65 | # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ 66 | # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode 67 | # config.disable_monkey_patching! 68 | 69 | # Many RSpec users commonly either run the entire suite or an individual 70 | # file, and it's useful to allow more verbose output when running an 71 | # individual spec file. 72 | # if config.files_to_run.one? 73 | # # Use the documentation formatter for detailed output, 74 | # # unless a formatter has already been configured 75 | # # (e.g. via a command-line flag). 76 | # config.default_formatter = "doc" 77 | # end 78 | 79 | # Print the 10 slowest examples and example groups at the 80 | # end of the spec run, to help surface which specs are running 81 | # particularly slow. 82 | # config.profile_examples = 10 83 | 84 | # Run specs in random order to surface order dependencies. If you find an 85 | # order dependency and want to debug it, you can fix the order by providing 86 | # the seed, which is printed after each run. 87 | # --seed 1234 88 | # config.order = :random 89 | 90 | # Seed global randomization in this process using the `--seed` CLI option. 91 | # Setting this allows you to use `--seed` to deterministically reproduce 92 | # test failures related to randomization by passing the same `--seed` value 93 | # as the one that triggered the failure. 94 | # Kernel.srand config.seed 95 | end 96 | -------------------------------------------------------------------------------- /spec/controllers/submissions_controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | # This spec was generated by rspec-rails when you ran the scaffold generator. 4 | # It demonstrates how one might use RSpec to specify the controller code that 5 | # was generated by Rails when you ran the scaffold generator. 6 | # 7 | # It assumes that the implementation code is generated by the rails scaffold 8 | # generator. If you are using any extension libraries to generate different 9 | # controller code, this generated spec may or may not pass. 10 | # 11 | # It only uses APIs available in rails and/or rspec-rails. There are a number 12 | # of tools you can use to make these specs even more expressive, but we're 13 | # sticking to rails and rspec-rails APIs to keep things simple and stable. 14 | # 15 | # Compared to earlier versions of this generator, there is very limited use of 16 | # stubs and message expectations in this spec. Stubs are only used when there 17 | # is no simpler way to get a handle on the object needed for the example. 18 | # Message expectations are only used when there is no simpler way to specify 19 | # that an instance is receiving a specific message. 20 | # 21 | # Also compared to earlier versions of this generator, there are no longer any 22 | # expectations of assigns and templates rendered. These features have been 23 | # removed from Rails core in Rails 5, but can be added back in via the 24 | # `rails-controller-testing` gem. 25 | 26 | RSpec.describe SubmissionsController, type: :controller do 27 | # This should return the minimal set of attributes required to create a valid 28 | # Submission. As you add validations to Submission, be sure to 29 | # adjust the attributes here as well. 30 | let(:valid_attributes) do 31 | skip('Add a hash of attributes valid for your model') 32 | end 33 | 34 | let(:invalid_attributes) do 35 | skip('Add a hash of attributes invalid for your model') 36 | end 37 | 38 | # This should return the minimal set of values that should be in the session 39 | # in order to pass any filters (e.g. authentication) defined in 40 | # SubmissionsController. Be sure to keep this updated too. 41 | let(:valid_session) { {} } 42 | 43 | describe 'GET #index' do 44 | it 'returns a success response' do 45 | Submission.create! valid_attributes 46 | get :index, params: {}, session: valid_session 47 | expect(response).to be_success 48 | end 49 | end 50 | 51 | describe 'GET #show' do 52 | it 'returns a success response' do 53 | submission = Submission.create! valid_attributes 54 | get :show, params: { id: submission.to_param }, session: valid_session 55 | expect(response).to be_success 56 | end 57 | end 58 | 59 | describe 'GET #new' do 60 | it 'returns a success response' do 61 | get :new, params: {}, session: valid_session 62 | expect(response).to be_success 63 | end 64 | end 65 | 66 | describe 'GET #edit' do 67 | it 'returns a success response' do 68 | submission = Submission.create! valid_attributes 69 | get :edit, params: { id: submission.to_param }, session: valid_session 70 | expect(response).to be_success 71 | end 72 | end 73 | 74 | describe 'POST #create' do 75 | context 'with valid params' do 76 | it 'creates a new Submission' do 77 | expect do 78 | post :create, params: { submission: valid_attributes }, session: valid_session 79 | end.to change(Submission, :count).by(1) 80 | end 81 | 82 | it 'redirects to the created submission' do 83 | post :create, params: { submission: valid_attributes }, session: valid_session 84 | expect(response).to redirect_to(Submission.last) 85 | end 86 | end 87 | 88 | context 'with invalid params' do 89 | it "returns a success response (i.e. to display the 'new' template)" do 90 | post :create, params: { submission: invalid_attributes }, session: valid_session 91 | expect(response).to be_success 92 | end 93 | end 94 | end 95 | 96 | describe 'PUT #update' do 97 | context 'with valid params' do 98 | let(:new_attributes) do 99 | skip('Add a hash of attributes valid for your model') 100 | end 101 | 102 | it 'updates the requested submission' do 103 | submission = Submission.create! valid_attributes 104 | put :update, params: { id: submission.to_param, submission: new_attributes }, session: valid_session 105 | submission.reload 106 | skip('Add assertions for updated state') 107 | end 108 | 109 | it 'redirects to the submission' do 110 | submission = Submission.create! valid_attributes 111 | put :update, params: { id: submission.to_param, submission: valid_attributes }, session: valid_session 112 | expect(response).to redirect_to(submission) 113 | end 114 | end 115 | 116 | context 'with invalid params' do 117 | it "returns a success response (i.e. to display the 'edit' template)" do 118 | submission = Submission.create! valid_attributes 119 | put :update, params: { id: submission.to_param, submission: invalid_attributes }, session: valid_session 120 | expect(response).to be_success 121 | end 122 | end 123 | end 124 | 125 | describe 'DELETE #destroy' do 126 | it 'destroys the requested submission' do 127 | submission = Submission.create! valid_attributes 128 | expect do 129 | delete :destroy, params: { id: submission.to_param }, session: valid_session 130 | end.to change(Submission, :count).by(-1) 131 | end 132 | 133 | it 'redirects to the submissions list' do 134 | submission = Submission.create! valid_attributes 135 | delete :destroy, params: { id: submission.to_param }, session: valid_session 136 | expect(response).to redirect_to(submissions_url) 137 | end 138 | end 139 | end 140 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # Creative Commons Legal Code 2 | 3 | ## CC0 1.0 Universal 4 | 5 | http://creativecommons.org/publicdomain/zero/1.0 6 | 7 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER. 8 | 9 | ### _Statement of Purpose_ 10 | 11 | The laws of most jurisdictions throughout the world automatically confer exclusive Copyright and Related Rights (defined below) upon the creator and subsequent owner(s) (each and all, an "owner") of an original work of authorship and/or a database (each, a "Work"). 12 | 13 | Certain owners wish to permanently relinquish those rights to a Work for the purpose of contributing to a commons of creative, cultural and scientific works ("Commons") that the public can reliably and without fear of later claims of infringement build upon, modify, incorporate in other works, reuse and redistribute as freely as possible in any form whatsoever and for any purposes, including without limitation commercial purposes. These owners may contribute to the Commons to promote the ideal of a free culture and the further production of creative, cultural and scientific works, or to gain reputation or greater distribution for their Work in part through the use and efforts of others. 14 | 15 | For these and/or other purposes and motivations, and without any expectation of additional consideration or compensation, the person associating CC0 with a Work (the "Affirmer"), to the extent that he or she is an owner of Copyright and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and publicly distribute the Work under its terms, with knowledge of his or her Copyright and Related Rights in the Work and the meaning and intended legal effect of CC0 on those rights. 16 | 17 | **1. Copyright and Related Rights.** A Work made available under CC0 may be protected by copyright and related or neighboring rights ("Copyright and Related Rights"). Copyright and Related Rights include, but are not limited to, the following: 18 | 19 | 1. the right to reproduce, adapt, distribute, perform, display, communicate, and translate a Work; 20 | 2. moral rights retained by the original author(s) and/or performer(s); 21 | 3. publicity and privacy rights pertaining to a person's image or likeness depicted in a Work; 22 | 4. rights protecting against unfair competition in regards to a Work, subject to the limitations in paragraph 4(a), below; 23 | 5. rights protecting the extraction, dissemination, use and reuse of data in a Work; 24 | 6. database rights (such as those arising under Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, and under any national implementation thereof, including any amended or successor version of such directive); and 25 | 7. other similar, equivalent or corresponding rights throughout the world based on applicable law or treaty, and any national implementations thereof. 26 | 27 | **2. Waiver.** To the greatest extent permitted by, but not in contravention of, applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and unconditionally waives, abandons, and surrenders all of Affirmer's Copyright and Related Rights and associated claims and causes of action, whether now known or unknown (including existing as well as future claims and causes of action), in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each member of the public at large and to the detriment of Affirmer's heirs and successors, fully intending that such Waiver shall not be subject to revocation, rescission, cancellation, termination, or any other legal or equitable action to disrupt the quiet enjoyment of the Work by the public as contemplated by Affirmer's express Statement of Purpose. 28 | 29 | **3. Public License Fallback.** Should any part of the Waiver for any reason be judged legally invalid or ineffective under applicable law, then the Waiver shall be preserved to the maximum extent permitted taking into account Affirmer's express Statement of Purpose. In addition, to the extent the Waiver is so judged Affirmer hereby grants to each affected person a royalty-free, non transferable, non sublicensable, non exclusive, irrevocable and unconditional license to exercise Affirmer's Copyright and Related Rights in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "License"). The License shall be deemed effective as of the date CC0 was applied by Affirmer to the Work. Should any part of the License for any reason be judged legally invalid or ineffective under applicable law, such partial invalidity or ineffectiveness shall not invalidate the remainder of the License, and in such case Affirmer hereby affirms that he or she will not (i) exercise any of his or her remaining Copyright and Related Rights in the Work or (ii) assert any associated claims and causes of action with respect to the Work, in either case contrary to Affirmer's express Statement of Purpose. 30 | 31 | **4. Limitations and Disclaimers.** 32 | 33 | 1. No trademark or patent rights held by Affirmer are waived, abandoned, surrendered, licensed or otherwise affected by this document. 34 | 2. Affirmer offers the Work as-is and makes no representations or warranties of any kind concerning the Work, express, implied, statutory or otherwise, including without limitation warranties of title, merchantability, fitness for a particular purpose, non infringement, or the absence of latent or other defects, accuracy, or the present or absence of errors, whether or not discoverable, all to the greatest extent permissible under applicable law. 35 | 3. Affirmer disclaims responsibility for clearing rights of other persons that may apply to the Work or any use thereof, including without limitation any person's Copyright and Related Rights in the Work. Further, Affirmer disclaims responsibility for obtaining any necessary consents, permissions or other rights required for any use of the Work. 36 | 4. Affirmer understands and acknowledges that Creative Commons is not a party to this document and has no duty or obligation with respect to this CC0 or use of the Work. 37 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actioncable (5.2.0) 5 | actionpack (= 5.2.0) 6 | nio4r (~> 2.0) 7 | websocket-driver (>= 0.6.1) 8 | actionmailer (5.2.0) 9 | actionpack (= 5.2.0) 10 | actionview (= 5.2.0) 11 | activejob (= 5.2.0) 12 | mail (~> 2.5, >= 2.5.4) 13 | rails-dom-testing (~> 2.0) 14 | actionpack (5.2.0) 15 | actionview (= 5.2.0) 16 | activesupport (= 5.2.0) 17 | rack (~> 2.0) 18 | rack-test (>= 0.6.3) 19 | rails-dom-testing (~> 2.0) 20 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 21 | actionview (5.2.0) 22 | activesupport (= 5.2.0) 23 | builder (~> 3.1) 24 | erubi (~> 1.4) 25 | rails-dom-testing (~> 2.0) 26 | rails-html-sanitizer (~> 1.0, >= 1.0.3) 27 | activejob (5.2.0) 28 | activesupport (= 5.2.0) 29 | globalid (>= 0.3.6) 30 | activemodel (5.2.0) 31 | activesupport (= 5.2.0) 32 | activerecord (5.2.0) 33 | activemodel (= 5.2.0) 34 | activesupport (= 5.2.0) 35 | arel (>= 9.0) 36 | activestorage (5.2.0) 37 | actionpack (= 5.2.0) 38 | activerecord (= 5.2.0) 39 | marcel (~> 0.3.1) 40 | activesupport (5.2.0) 41 | concurrent-ruby (~> 1.0, >= 1.0.2) 42 | i18n (>= 0.7, < 2) 43 | minitest (~> 5.1) 44 | tzinfo (~> 1.1) 45 | arel (9.0.0) 46 | ast (2.4.0) 47 | autoprefixer-rails (9.1.0) 48 | execjs 49 | bindex (0.5.0) 50 | bootstrap (4.1.3) 51 | autoprefixer-rails (>= 6.0.3) 52 | popper_js (>= 1.12.9, < 2) 53 | sass (>= 3.5.2) 54 | builder (3.2.3) 55 | byebug (10.0.2) 56 | coderay (1.1.2) 57 | concurrent-ruby (1.0.5) 58 | crass (1.0.4) 59 | diff-lcs (1.3) 60 | docile (1.3.1) 61 | erubi (1.7.1) 62 | execjs (2.7.0) 63 | factory_bot (4.10.0) 64 | activesupport (>= 3.0.0) 65 | factory_bot_rails (4.10.0) 66 | factory_bot (~> 4.10.0) 67 | railties (>= 3.0.0) 68 | fast_stack (0.2.0) 69 | ffi (1.9.25) 70 | flamegraph (0.9.5) 71 | formatador (0.2.5) 72 | globalid (0.4.1) 73 | activesupport (>= 4.2.0) 74 | guard (2.14.2) 75 | formatador (>= 0.2.4) 76 | listen (>= 2.7, < 4.0) 77 | lumberjack (>= 1.0.12, < 2.0) 78 | nenv (~> 0.1) 79 | notiffany (~> 0.0) 80 | pry (>= 0.9.12) 81 | shellany (~> 0.0) 82 | thor (>= 0.18.1) 83 | guard-compat (1.2.1) 84 | guard-rspec (4.7.3) 85 | guard (~> 2.1) 86 | guard-compat (~> 1.1) 87 | rspec (>= 2.99.0, < 4.0) 88 | i18n (1.0.1) 89 | concurrent-ruby (~> 1.0) 90 | jaro_winkler (1.5.1) 91 | jquery-rails (4.3.3) 92 | rails-dom-testing (>= 1, < 3) 93 | railties (>= 4.2.0) 94 | thor (>= 0.14, < 2.0) 95 | json (2.1.0) 96 | listen (3.1.5) 97 | rb-fsevent (~> 0.9, >= 0.9.4) 98 | rb-inotify (~> 0.9, >= 0.9.7) 99 | ruby_dep (~> 1.2) 100 | loofah (2.2.2) 101 | crass (~> 1.0.2) 102 | nokogiri (>= 1.5.9) 103 | lumberjack (1.0.13) 104 | mail (2.7.0) 105 | mini_mime (>= 0.1.1) 106 | marcel (0.3.2) 107 | mimemagic (~> 0.3.2) 108 | memory_profiler (0.9.11) 109 | method_source (0.9.0) 110 | microformats (4.0.7) 111 | json 112 | nokogiri 113 | mimemagic (0.3.10) 114 | nokogiri (~> 1) 115 | rake 116 | mini_mime (1.0.0) 117 | mini_portile2 (2.3.0) 118 | minitest (5.11.3) 119 | nenv (0.3.0) 120 | nio4r (2.3.1) 121 | nokogiri (1.8.4) 122 | mini_portile2 (~> 2.3.0) 123 | notiffany (0.1.1) 124 | nenv (~> 0.1) 125 | shellany (~> 0.0) 126 | parallel (1.12.1) 127 | parser (2.5.1.2) 128 | ast (~> 2.4.0) 129 | pg (1.0.0) 130 | popper_js (1.14.3) 131 | powerpack (0.1.2) 132 | pry (0.11.3) 133 | coderay (~> 1.1.0) 134 | method_source (~> 0.9.0) 135 | puma (3.12.0) 136 | rack (2.0.5) 137 | rack-mini-profiler (1.0.0) 138 | rack (>= 1.2.0) 139 | rack-test (1.1.0) 140 | rack (>= 1.0, < 3) 141 | rails (5.2.0) 142 | actioncable (= 5.2.0) 143 | actionmailer (= 5.2.0) 144 | actionpack (= 5.2.0) 145 | actionview (= 5.2.0) 146 | activejob (= 5.2.0) 147 | activemodel (= 5.2.0) 148 | activerecord (= 5.2.0) 149 | activestorage (= 5.2.0) 150 | activesupport (= 5.2.0) 151 | bundler (>= 1.3.0) 152 | railties (= 5.2.0) 153 | sprockets-rails (>= 2.0.0) 154 | rails-controller-testing (1.0.2) 155 | actionpack (~> 5.x, >= 5.0.1) 156 | actionview (~> 5.x, >= 5.0.1) 157 | activesupport (~> 5.x) 158 | rails-dom-testing (2.0.3) 159 | activesupport (>= 4.2.0) 160 | nokogiri (>= 1.6) 161 | rails-html-sanitizer (1.0.4) 162 | loofah (~> 2.2, >= 2.2.2) 163 | railties (5.2.0) 164 | actionpack (= 5.2.0) 165 | activesupport (= 5.2.0) 166 | method_source 167 | rake (>= 0.8.7) 168 | thor (>= 0.18.1, < 2.0) 169 | rainbow (3.0.0) 170 | rake (12.3.1) 171 | rb-fsevent (0.10.3) 172 | rb-inotify (0.9.10) 173 | ffi (>= 0.5.0, < 2) 174 | rspec (3.8.0) 175 | rspec-core (~> 3.8.0) 176 | rspec-expectations (~> 3.8.0) 177 | rspec-mocks (~> 3.8.0) 178 | rspec-core (3.8.0) 179 | rspec-support (~> 3.8.0) 180 | rspec-expectations (3.8.0) 181 | diff-lcs (>= 1.2.0, < 2.0) 182 | rspec-support (~> 3.8.0) 183 | rspec-mocks (3.8.0) 184 | diff-lcs (>= 1.2.0, < 2.0) 185 | rspec-support (~> 3.8.0) 186 | rspec-rails (3.8.0) 187 | actionpack (>= 3.0) 188 | activesupport (>= 3.0) 189 | railties (>= 3.0) 190 | rspec-core (~> 3.8.0) 191 | rspec-expectations (~> 3.8.0) 192 | rspec-mocks (~> 3.8.0) 193 | rspec-support (~> 3.8.0) 194 | rspec-support (3.8.0) 195 | rubocop (0.58.2) 196 | jaro_winkler (~> 1.5.1) 197 | parallel (~> 1.10) 198 | parser (>= 2.5, != 2.5.1.1) 199 | powerpack (~> 0.1) 200 | rainbow (>= 2.2.2, < 4.0) 201 | ruby-progressbar (~> 1.7) 202 | unicode-display_width (~> 1.0, >= 1.0.1) 203 | rubocop-rspec (1.27.0) 204 | rubocop (>= 0.56.0) 205 | ruby-progressbar (1.9.0) 206 | ruby_dep (1.5.0) 207 | sass (3.5.7) 208 | sass-listen (~> 4.0.0) 209 | sass-listen (4.0.0) 210 | rb-fsevent (~> 0.9, >= 0.9.4) 211 | rb-inotify (~> 0.9, >= 0.9.7) 212 | sass-rails (5.0.7) 213 | railties (>= 4.0.0, < 6) 214 | sass (~> 3.1) 215 | sprockets (>= 2.8, < 4.0) 216 | sprockets-rails (>= 2.0, < 4.0) 217 | tilt (>= 1.1, < 3) 218 | shellany (0.0.1) 219 | simplecov (0.16.1) 220 | docile (~> 1.1) 221 | json (>= 1.8, < 3) 222 | simplecov-html (~> 0.10.0) 223 | simplecov-html (0.10.2) 224 | spring (2.0.2) 225 | activesupport (>= 4.2) 226 | spring-commands-rspec (1.0.4) 227 | spring (>= 0.9.1) 228 | spring-watcher-listen (2.0.1) 229 | listen (>= 2.7, < 4.0) 230 | spring (>= 1.2, < 3.0) 231 | sprockets (3.7.2) 232 | concurrent-ruby (~> 1.0) 233 | rack (> 1, < 3) 234 | sprockets-rails (3.2.1) 235 | actionpack (>= 4.0) 236 | activesupport (>= 4.0) 237 | sprockets (>= 3.0.0) 238 | stackprof (0.2.12) 239 | thor (0.20.0) 240 | thread_safe (0.3.6) 241 | tilt (2.0.8) 242 | tzinfo (1.2.10) 243 | thread_safe (~> 0.1) 244 | uglifier (4.1.17) 245 | execjs (>= 0.3.0, < 3) 246 | unicode-display_width (1.4.0) 247 | web-console (3.6.2) 248 | actionview (>= 5.0) 249 | activemodel (>= 5.0) 250 | bindex (>= 0.4.0) 251 | railties (>= 5.0) 252 | websocket-driver (0.7.0) 253 | websocket-extensions (>= 0.1.0) 254 | websocket-extensions (0.1.3) 255 | 256 | PLATFORMS 257 | ruby 258 | 259 | DEPENDENCIES 260 | autoprefixer-rails 261 | bootstrap 262 | byebug 263 | factory_bot_rails 264 | fast_stack 265 | flamegraph 266 | guard-rspec 267 | jquery-rails 268 | listen (~> 3.1.5) 269 | memory_profiler 270 | microformats (~> 4.0.7) 271 | nokogiri 272 | pg 273 | puma 274 | rack-mini-profiler 275 | rails (~> 5.2.0) 276 | rails-controller-testing 277 | rspec-rails 278 | rubocop 279 | rubocop-rspec 280 | sass-rails 281 | simplecov 282 | spring 283 | spring-commands-rspec 284 | spring-watcher-listen (~> 2.0.0) 285 | stackprof 286 | tzinfo-data 287 | uglifier 288 | web-console 289 | 290 | RUBY VERSION 291 | ruby 2.5.1p57 292 | 293 | BUNDLED WITH 294 | 1.16.2 295 | --------------------------------------------------------------------------------