From 9f418bef26b3d1ebbab90231eef7933e4218cc7c Mon Sep 17 00:00:00 2001 From: Scott Sims Date: Wed, 7 May 2014 14:21:46 -0500 Subject: [PATCH 1/2] MASSIVE code rewrite --- CHANGELOG.md | 5 - Gemfile | 15 - MIT-LICENSE | 20 - README.md | 72 +- Rakefile | 22 - .../concerns/landable/variables_concern.rb | 38 - .../landable/api/access_tokens_controller.rb | 48 - .../landable/api/assets_controller.rb | 55 - .../landable/api/categories_controller.rb | 13 - .../landable/api/directories_controller.rb | 19 - .../landable/api/page_revisions_controller.rb | 38 - .../landable/api/pages_controller.rb | 96 - .../landable/api/templates_controller.rb | 33 - .../landable/api/themes_controller.rb | 57 - app/controllers/landable/api_controller.rb | 75 - .../landable/application_controller.rb | 4 - .../landable/public/pages_controller.rb | 25 - .../preview/page_revisions_controller.rb | 16 - .../public/preview/pages_controller.rb | 16 - .../landable/public/sitemap_controller.rb | 18 - .../landable/null_page_decorator.rb | 26 - app/decorators/landable/page_decorator.rb | 40 - app/helpers/landable/application_helper.rb | 13 - app/helpers/landable/pages_helper.rb | 20 - app/models/concerns/landable/has_assets.rb | 74 - app/models/concerns/landable/table_name.rb | 12 - .../concerns/landable/traffic/table_name.rb | 14 - app/models/landable/access_token.rb | 20 - app/models/landable/asset.rb | 63 - app/models/landable/asset_search_engine.rb | 20 - app/models/landable/author.rb | 12 - app/models/landable/category.rb | 27 - app/models/landable/directory.rb | 23 - app/models/landable/page.rb | 259 - app/models/landable/page_revision.rb | 74 - app/models/landable/page_search_engine.rb | 20 - app/models/landable/search_engine.rb | 39 - app/models/landable/template.rb | 24 - app/models/landable/theme.rb | 20 - app/models/landable/traffic/access.rb | 11 - app/models/landable/traffic/ad_group.rb | 11 - app/models/landable/traffic/ad_type.rb | 11 - app/models/landable/traffic/attribution.rb | 38 - app/models/landable/traffic/bid_match_type.rb | 11 - app/models/landable/traffic/browser.rb | 11 - app/models/landable/traffic/campaign.rb | 11 - app/models/landable/traffic/city.rb | 11 - app/models/landable/traffic/content.rb | 11 - app/models/landable/traffic/cookie.rb | 16 - app/models/landable/traffic/country.rb | 11 - app/models/landable/traffic/creative.rb | 11 - app/models/landable/traffic/device.rb | 11 - app/models/landable/traffic/device_type.rb | 11 - app/models/landable/traffic/domain.rb | 12 - app/models/landable/traffic/event.rb | 12 - app/models/landable/traffic/event_type.rb | 11 - app/models/landable/traffic/experiment.rb | 11 - app/models/landable/traffic/http_method.rb | 11 - app/models/landable/traffic/ip_address.rb | 11 - app/models/landable/traffic/ip_lookup.rb | 12 - app/models/landable/traffic/keyword.rb | 11 - app/models/landable/traffic/location.rb | 11 - app/models/landable/traffic/match_type.rb | 11 - app/models/landable/traffic/medium.rb | 11 - app/models/landable/traffic/mime_type.rb | 11 - app/models/landable/traffic/network.rb | 11 - app/models/landable/traffic/owner.rb | 10 - app/models/landable/traffic/ownership.rb | 10 - app/models/landable/traffic/page_view.rb | 24 - app/models/landable/traffic/path.rb | 13 - app/models/landable/traffic/placement.rb | 11 - app/models/landable/traffic/platform.rb | 11 - app/models/landable/traffic/position.rb | 11 - app/models/landable/traffic/query_string.rb | 12 - app/models/landable/traffic/referer.rb | 11 - app/models/landable/traffic/region.rb | 11 - app/models/landable/traffic/search_term.rb | 11 - app/models/landable/traffic/source.rb | 11 - app/models/landable/traffic/target.rb | 11 - app/models/landable/traffic/user_agent.rb | 28 - .../landable/traffic/user_agent_type.rb | 11 - app/models/landable/traffic/visit.rb | 15 - app/models/landable/traffic/visitor.rb | 13 - app/responders/landable/api_responder.rb | 76 - .../landable/page_render_responder.rb | 15 - .../landable/access_token_serializer.rb | 6 - app/serializers/landable/asset_serializer.rb | 14 - app/serializers/landable/author_serializer.rb | 5 - .../landable/category_serializer.rb | 5 - .../landable/directory_serializer.rb | 8 - .../landable/page_revision_serializer.rb | 15 - app/serializers/landable/page_serializer.rb | 31 - .../landable/template_serializer.rb | 5 - app/serializers/landable/theme_serializer.rb | 7 - .../landable/authentication_service.rb | 44 - app/services/landable/registration_service.rb | 13 - app/services/landable/render_service.rb | 86 - app/services/landable/tidy_service.rb | 155 - app/uploaders/landable/asset_uploader.rb | 9 - app/validators/path_validator.rb | 12 - app/validators/url_validator.rb | 13 - app/views/templates/preview.liquid | 122 - bin/rails | 8 - bin/redb | 7 - config.ru | 7 - config/cucumber.yml | 5 - config/routes.rb | 62 - .../20130510221424_create_landable_schema.rb | 338 - ...09182713_landable_pages__add_updated_by.rb | 11 - ...able_page_revisions__break_out_snapshot.rb | 72 - ...191153_landable_pages__add_lock_version.rb | 5 - .../20131002220041_file_based_themes.rb | 12 - .../20131008164204_create_head_tag_on_page.rb | 19 - .../20131008193544_drop_status_codes_model.rb | 44 - .../20131028145652_add_traffic_schema.rb | 276 - ...20131101213623_add_dnt_column_to_visits.rb | 7 - .../20131104224120_add_meta_on_events.rb | 7 - ...185946_add_index_on_page_revisions_path.rb | 6 - ...page_revisisons__path_status_code_index.rb | 9 - ...108212501_traffic_owner_ids_are_serials.rb | 20 - ...0902_add_attribution_id_to_unique_index.rb | 10 - ...16214027_drop_browser_screenshot_tables.rb | 6 - .../20140128170659_file_backed_templates.rb | 8 - db/migrate/20140205193757_fix_status_codes.rb | 24 - ...add_response_time_to_traffic_page_views.rb | 7 - .../20140220170324_add_slug_to_categories.rb | 14 - ..._hero_asset_to_pages_and_page_revisions.rb | 8 - .../20140224205516_rename_traffic_schema.rb | 40 - db/pgtap/pgtap.sql | 9034 ----------------- db/test/landable.access_tokens.sql | 13 - db/test/landable.assets.sql | 16 - db/test/landable.authors.sql | 22 - db/test/landable.categories.sql | 9 - db/test/landable.page_revisions.sql | 41 - db/test/landable.pages.sql | 19 - db/test/landable.templates.sql | 15 - db/test/landable.themes.sql | 25 - doc/schema/access_token.json | 22 - doc/schema/asset.json | 65 - doc/schema/author.json | 30 - doc/schema/directory.json | 24 - doc/schema/page.json | 95 - doc/schema/page_revision.json | 70 - doc/schema/theme.json | 37 - doc/schema/uuid.json | 6 - features/api/access_tokens.feature | 84 - features/api/assets.feature | 46 - features/api/cors.feature | 25 - features/api/pages.feature | 42 - features/api/preview.feature | 16 - features/api/templates.feature | 33 - features/api/themes.feature | 33 - features/liquid/body.feature | 35 - features/liquid/drops/categories.feature | 54 - features/liquid/tags.feature | 168 - features/public/content_types.feature | 17 - features/public/publishing.feature | 45 - features/public/status_codes.feature | 25 - features/public/views.feature | 17 - features/step_definitions/asset_steps.rb | 60 - features/step_definitions/core_api_steps.rb | 139 - features/step_definitions/debug_steps.rb | 3 - features/step_definitions/factory_steps.rb | 124 - features/step_definitions/html_steps.rb | 9 - features/step_definitions/liquid_steps.rb | 79 - features/step_definitions/revision_steps.rb | 5 - features/step_definitions/theme_steps.rb | 43 - features/support/env.rb | 66 - features/support/usefulness.rb | 13 - landable.gemspec | 54 - .../collection/collection_generator.rb | 0 .../stylesheets/landable/%file_name%.less | 0 .../landable/%file_name%/mixins.less | 0 .../landable/%file_name%/variables.less | 0 .../landable/component/component_generator.rb | 0 .../javascripts/landable/%file_name%.less | 0 .../stylesheets/landable/%file_name%.less | 0 lib/generators/landable/install_generator.rb | 19 - lib/generators/landable/landable_generator.rb | 22 - lib/generators/templates/landable.rb | 34 - lib/landable.rb | 30 - lib/landable/configuration.rb | 115 - lib/landable/core_ext/ipaddr.rb | 18 - lib/landable/engine.rb | 69 - lib/landable/error.rb | 16 - lib/landable/inflections.rb | 4 - lib/landable/layout.rb | 60 - lib/landable/liquid.rb | 27 - lib/landable/liquid/asset_tags.rb | 76 - lib/landable/liquid/drops.rb | 46 - lib/landable/liquid/filters.rb | 11 - lib/landable/liquid/tags.rb | 91 - lib/landable/migration.rb | 40 - lib/landable/mime_types.rb | 15 - lib/landable/partial.rb | 46 - lib/landable/seeds.rb | 36 - lib/landable/traffic.rb | 34 - lib/landable/traffic/crawl_tracker.rb | 9 - lib/landable/traffic/noop_tracker.rb | 8 - lib/landable/traffic/ping_tracker.rb | 9 - lib/landable/traffic/scan_tracker.rb | 9 - lib/landable/traffic/scrape_tracker.rb | 9 - lib/landable/traffic/tracker.rb | 283 - lib/landable/traffic/user_tracker.rb | 65 - lib/landable/version.rb | 10 - lib/tasks/landable/cucumber.rake | 67 - lib/tasks/landable/data.rake | 166 - lib/tasks/landable/pgtap.rake | 26 - lib/tasks/landable/rdoc.rake | 11 - lib/tasks/landable/seed.rake | 16 - lib/tasks/landable/spec.rake | 15 - script/cucumber | 10 - spec/concerns/landable/has_assets_spec.rb | 75 - spec/concerns/landable/table_name_spec.rb | 15 - .../landable/traffic/table_name_spec.rb | 16 - .../landable/variables_concern_spec.rb | 66 - .../landable/api/assets_controller_spec.rb | 24 - .../api/categories_controller_spec.rb | 45 - .../api/directories_controller_spec.rb | 56 - .../api/page_revisions_controller_spec.rb | 29 - .../landable/api/pages_controller_spec.rb | 271 - .../landable/api_controller_spec.rb | 189 - .../preview/page_revisions_controller_spec.rb | 41 - .../public/preview/pages_controller_spec.rb | 36 - .../public/sitemap_controller_spec.rb | 25 - spec/decorators/page_decorator_spec.rb | 90 - spec/dummy/README.rdoc | 28 - spec/dummy/Rakefile | 6 - spec/dummy/app/assets/images/foo.jpg | 0 .../app/assets/javascripts/application.js | 13 - .../app/assets/stylesheets/application.css | 13 - .../app/controllers/application_controller.rb | 10 - spec/dummy/app/controllers/concerns/.keep | 0 .../app/controllers/priority_controller.rb | 7 - spec/dummy/app/helpers/application_helper.rb | 5 - spec/dummy/app/mailers/.keep | 0 spec/dummy/app/models/.keep | 0 spec/dummy/app/models/concerns/.keep | 0 .../app/views/layouts/application.html.erb | 14 - .../dummy/app/views/layouts/priority.html.erb | 18 - spec/dummy/app/views/partials/_foobazz.html | 1 - spec/dummy/app/views/priority/show.html.erb | 11 - spec/dummy/bin/bundle | 3 - spec/dummy/bin/rails | 4 - spec/dummy/bin/rake | 4 - spec/dummy/config.ru | 4 - spec/dummy/config/application.rb | 21 - spec/dummy/config/boot.rb | 5 - spec/dummy/config/database.yml | 60 - spec/dummy/config/environment.rb | 5 - spec/dummy/config/environments/development.rb | 29 - spec/dummy/config/environments/production.rb | 80 - spec/dummy/config/environments/test.rb | 42 - .../initializers/backtrace_silencers.rb | 7 - .../initializers/filter_parameter_logging.rb | 4 - spec/dummy/config/initializers/inflections.rb | 16 - spec/dummy/config/initializers/landable.rb | 22 - spec/dummy/config/initializers/mime_types.rb | 5 - .../dummy/config/initializers/secret_token.rb | 12 - .../config/initializers/session_store.rb | 3 - .../config/initializers/wrap_parameters.rb | 14 - spec/dummy/config/locales/en.yml | 23 - spec/dummy/config/routes.rb | 4 - spec/dummy/db/structure.sql | 3736 ------- spec/dummy/lib/assets/.keep | 0 spec/dummy/log/.keep | 0 spec/dummy/public/404.html | 58 - spec/dummy/public/422.html | 58 - spec/dummy/public/500.html | 57 - spec/dummy/public/favicon.ico | 0 spec/factories/asset.rb | 29 - spec/factories/authors.rb | 12 - spec/factories/category.rb | 6 - spec/factories/page_revision.rb | 6 - spec/factories/pages.rb | 33 - spec/factories/template.rb | 13 - spec/factories/theme.rb | 14 - spec/fixtures/assets/cthulhu.jpg | Bin 61114 -> 0 bytes spec/fixtures/assets/panda.png | Bin 20828 -> 0 bytes spec/fixtures/assets/sloth.png | Bin 364158 -> 0 bytes spec/fixtures/assets/small.pdf | Bin 107191 -> 0 bytes spec/helpers/pages_helper_spec.rb | 35 - spec/lib/landable/configuration_spec.rb | 20 - spec/lib/landable/layout_spec.rb | 25 - spec/lib/landable/liquid_spec.rb | 24 - spec/lib/landable/migration_spec.rb | 51 - spec/lib/landable/partial_spec.rb | 84 - spec/lib/landable/tracking_spec.rb | 62 - spec/lib/landable/traffic_spec.rb | 45 - spec/models/landable/access_token_spec.rb | 13 - spec/models/landable/asset_spec.rb | 48 - spec/models/landable/directory_spec.rb | 36 - spec/models/landable/page/errors_spec.rb | 30 - spec/models/landable/page_revision_spec.rb | 75 - spec/models/landable/page_spec.rb | 377 - spec/models/landable/template_spec.rb | 47 - spec/models/landable/theme_spec.rb | 8 - spec/responders/page_render_responder_spec.rb | 43 - spec/routing/public_page_route_spec.rb | 36 - .../landable/authentication_service_spec.rb | 61 - spec/services/landable/render_service_spec.rb | 103 - spec/services/landable/tidy_service_spec.rb | 157 - spec/spec_helper.rb | 38 - spec/support/behaviors.rb | 107 - spec/support/carrier_wave.rb | 17 - spec/support/categories.yml | 2 - spec/support/helpers.rb | 22 - 307 files changed, 16 insertions(+), 23057 deletions(-) delete mode 100644 CHANGELOG.md delete mode 100644 Gemfile delete mode 100644 MIT-LICENSE delete mode 100644 Rakefile delete mode 100644 app/controllers/concerns/landable/variables_concern.rb delete mode 100644 app/controllers/landable/api/access_tokens_controller.rb delete mode 100644 app/controllers/landable/api/assets_controller.rb delete mode 100644 app/controllers/landable/api/categories_controller.rb delete mode 100644 app/controllers/landable/api/directories_controller.rb delete mode 100644 app/controllers/landable/api/page_revisions_controller.rb delete mode 100644 app/controllers/landable/api/pages_controller.rb delete mode 100644 app/controllers/landable/api/templates_controller.rb delete mode 100644 app/controllers/landable/api/themes_controller.rb delete mode 100644 app/controllers/landable/api_controller.rb delete mode 100644 app/controllers/landable/application_controller.rb delete mode 100644 app/controllers/landable/public/pages_controller.rb delete mode 100644 app/controllers/landable/public/preview/page_revisions_controller.rb delete mode 100644 app/controllers/landable/public/preview/pages_controller.rb delete mode 100644 app/controllers/landable/public/sitemap_controller.rb delete mode 100644 app/decorators/landable/null_page_decorator.rb delete mode 100644 app/decorators/landable/page_decorator.rb delete mode 100644 app/helpers/landable/application_helper.rb delete mode 100644 app/helpers/landable/pages_helper.rb delete mode 100644 app/models/concerns/landable/has_assets.rb delete mode 100644 app/models/concerns/landable/table_name.rb delete mode 100644 app/models/concerns/landable/traffic/table_name.rb delete mode 100644 app/models/landable/access_token.rb delete mode 100644 app/models/landable/asset.rb delete mode 100644 app/models/landable/asset_search_engine.rb delete mode 100644 app/models/landable/author.rb delete mode 100644 app/models/landable/category.rb delete mode 100644 app/models/landable/directory.rb delete mode 100644 app/models/landable/page.rb delete mode 100644 app/models/landable/page_revision.rb delete mode 100644 app/models/landable/page_search_engine.rb delete mode 100644 app/models/landable/search_engine.rb delete mode 100644 app/models/landable/template.rb delete mode 100644 app/models/landable/theme.rb delete mode 100644 app/models/landable/traffic/access.rb delete mode 100644 app/models/landable/traffic/ad_group.rb delete mode 100644 app/models/landable/traffic/ad_type.rb delete mode 100644 app/models/landable/traffic/attribution.rb delete mode 100644 app/models/landable/traffic/bid_match_type.rb delete mode 100644 app/models/landable/traffic/browser.rb delete mode 100644 app/models/landable/traffic/campaign.rb delete mode 100644 app/models/landable/traffic/city.rb delete mode 100644 app/models/landable/traffic/content.rb delete mode 100644 app/models/landable/traffic/cookie.rb delete mode 100644 app/models/landable/traffic/country.rb delete mode 100644 app/models/landable/traffic/creative.rb delete mode 100644 app/models/landable/traffic/device.rb delete mode 100644 app/models/landable/traffic/device_type.rb delete mode 100644 app/models/landable/traffic/domain.rb delete mode 100644 app/models/landable/traffic/event.rb delete mode 100644 app/models/landable/traffic/event_type.rb delete mode 100644 app/models/landable/traffic/experiment.rb delete mode 100644 app/models/landable/traffic/http_method.rb delete mode 100644 app/models/landable/traffic/ip_address.rb delete mode 100644 app/models/landable/traffic/ip_lookup.rb delete mode 100644 app/models/landable/traffic/keyword.rb delete mode 100644 app/models/landable/traffic/location.rb delete mode 100644 app/models/landable/traffic/match_type.rb delete mode 100644 app/models/landable/traffic/medium.rb delete mode 100644 app/models/landable/traffic/mime_type.rb delete mode 100644 app/models/landable/traffic/network.rb delete mode 100644 app/models/landable/traffic/owner.rb delete mode 100644 app/models/landable/traffic/ownership.rb delete mode 100644 app/models/landable/traffic/page_view.rb delete mode 100644 app/models/landable/traffic/path.rb delete mode 100644 app/models/landable/traffic/placement.rb delete mode 100644 app/models/landable/traffic/platform.rb delete mode 100644 app/models/landable/traffic/position.rb delete mode 100644 app/models/landable/traffic/query_string.rb delete mode 100644 app/models/landable/traffic/referer.rb delete mode 100644 app/models/landable/traffic/region.rb delete mode 100644 app/models/landable/traffic/search_term.rb delete mode 100644 app/models/landable/traffic/source.rb delete mode 100644 app/models/landable/traffic/target.rb delete mode 100644 app/models/landable/traffic/user_agent.rb delete mode 100644 app/models/landable/traffic/user_agent_type.rb delete mode 100644 app/models/landable/traffic/visit.rb delete mode 100644 app/models/landable/traffic/visitor.rb delete mode 100644 app/responders/landable/api_responder.rb delete mode 100644 app/responders/landable/page_render_responder.rb delete mode 100644 app/serializers/landable/access_token_serializer.rb delete mode 100644 app/serializers/landable/asset_serializer.rb delete mode 100644 app/serializers/landable/author_serializer.rb delete mode 100644 app/serializers/landable/category_serializer.rb delete mode 100644 app/serializers/landable/directory_serializer.rb delete mode 100644 app/serializers/landable/page_revision_serializer.rb delete mode 100644 app/serializers/landable/page_serializer.rb delete mode 100644 app/serializers/landable/template_serializer.rb delete mode 100644 app/serializers/landable/theme_serializer.rb delete mode 100644 app/services/landable/authentication_service.rb delete mode 100644 app/services/landable/registration_service.rb delete mode 100644 app/services/landable/render_service.rb delete mode 100644 app/services/landable/tidy_service.rb delete mode 100644 app/uploaders/landable/asset_uploader.rb delete mode 100644 app/validators/path_validator.rb delete mode 100644 app/validators/url_validator.rb delete mode 100644 app/views/templates/preview.liquid delete mode 100755 bin/rails delete mode 100755 bin/redb delete mode 100644 config.ru delete mode 100644 config/cucumber.yml delete mode 100644 config/routes.rb delete mode 100644 db/migrate/20130510221424_create_landable_schema.rb delete mode 100644 db/migrate/20130909182713_landable_pages__add_updated_by.rb delete mode 100644 db/migrate/20130909182715_landable_page_revisions__break_out_snapshot.rb delete mode 100644 db/migrate/20130909191153_landable_pages__add_lock_version.rb delete mode 100644 db/migrate/20131002220041_file_based_themes.rb delete mode 100644 db/migrate/20131008164204_create_head_tag_on_page.rb delete mode 100644 db/migrate/20131008193544_drop_status_codes_model.rb delete mode 100644 db/migrate/20131028145652_add_traffic_schema.rb delete mode 100644 db/migrate/20131101213623_add_dnt_column_to_visits.rb delete mode 100644 db/migrate/20131104224120_add_meta_on_events.rb delete mode 100644 db/migrate/20131106185946_add_index_on_page_revisions_path.rb delete mode 100644 db/migrate/20131106193021_page_revisisons__path_status_code_index.rb delete mode 100644 db/migrate/20131108212501_traffic_owner_ids_are_serials.rb delete mode 100644 db/migrate/20131121150902_add_attribution_id_to_unique_index.rb delete mode 100644 db/migrate/20131216214027_drop_browser_screenshot_tables.rb delete mode 100644 db/migrate/20140128170659_file_backed_templates.rb delete mode 100644 db/migrate/20140205193757_fix_status_codes.rb delete mode 100644 db/migrate/20140206211322_add_response_time_to_traffic_page_views.rb delete mode 100644 db/migrate/20140220170324_add_slug_to_categories.rb delete mode 100644 db/migrate/20140220174630_add_abstract_and_hero_asset_to_pages_and_page_revisions.rb delete mode 100644 db/migrate/20140224205516_rename_traffic_schema.rb delete mode 100644 db/pgtap/pgtap.sql delete mode 100644 db/test/landable.access_tokens.sql delete mode 100644 db/test/landable.assets.sql delete mode 100644 db/test/landable.authors.sql delete mode 100644 db/test/landable.categories.sql delete mode 100644 db/test/landable.page_revisions.sql delete mode 100644 db/test/landable.pages.sql delete mode 100644 db/test/landable.templates.sql delete mode 100644 db/test/landable.themes.sql delete mode 100644 doc/schema/access_token.json delete mode 100644 doc/schema/asset.json delete mode 100644 doc/schema/author.json delete mode 100644 doc/schema/directory.json delete mode 100644 doc/schema/page.json delete mode 100644 doc/schema/page_revision.json delete mode 100644 doc/schema/theme.json delete mode 100644 doc/schema/uuid.json delete mode 100644 features/api/access_tokens.feature delete mode 100644 features/api/assets.feature delete mode 100644 features/api/cors.feature delete mode 100644 features/api/pages.feature delete mode 100644 features/api/preview.feature delete mode 100644 features/api/templates.feature delete mode 100644 features/api/themes.feature delete mode 100644 features/liquid/body.feature delete mode 100644 features/liquid/drops/categories.feature delete mode 100644 features/liquid/tags.feature delete mode 100644 features/public/content_types.feature delete mode 100644 features/public/publishing.feature delete mode 100644 features/public/status_codes.feature delete mode 100644 features/public/views.feature delete mode 100644 features/step_definitions/asset_steps.rb delete mode 100644 features/step_definitions/core_api_steps.rb delete mode 100644 features/step_definitions/debug_steps.rb delete mode 100644 features/step_definitions/factory_steps.rb delete mode 100644 features/step_definitions/html_steps.rb delete mode 100644 features/step_definitions/liquid_steps.rb delete mode 100644 features/step_definitions/revision_steps.rb delete mode 100644 features/step_definitions/theme_steps.rb delete mode 100644 features/support/env.rb delete mode 100644 features/support/usefulness.rb delete mode 100644 landable.gemspec delete mode 100644 lib/generators/landable/collection/collection_generator.rb delete mode 100644 lib/generators/landable/collection/templates/stylesheets/landable/%file_name%.less delete mode 100644 lib/generators/landable/collection/templates/stylesheets/landable/%file_name%/mixins.less delete mode 100644 lib/generators/landable/collection/templates/stylesheets/landable/%file_name%/variables.less delete mode 100644 lib/generators/landable/component/component_generator.rb delete mode 100644 lib/generators/landable/component/templates/javascripts/landable/%file_name%.less delete mode 100644 lib/generators/landable/component/templates/stylesheets/landable/%file_name%.less delete mode 100644 lib/generators/landable/install_generator.rb delete mode 100644 lib/generators/landable/landable_generator.rb delete mode 100644 lib/generators/templates/landable.rb delete mode 100644 lib/landable.rb delete mode 100644 lib/landable/configuration.rb delete mode 100644 lib/landable/core_ext/ipaddr.rb delete mode 100644 lib/landable/engine.rb delete mode 100644 lib/landable/error.rb delete mode 100644 lib/landable/inflections.rb delete mode 100644 lib/landable/layout.rb delete mode 100644 lib/landable/liquid.rb delete mode 100644 lib/landable/liquid/asset_tags.rb delete mode 100644 lib/landable/liquid/drops.rb delete mode 100644 lib/landable/liquid/filters.rb delete mode 100644 lib/landable/liquid/tags.rb delete mode 100644 lib/landable/migration.rb delete mode 100644 lib/landable/mime_types.rb delete mode 100644 lib/landable/partial.rb delete mode 100644 lib/landable/seeds.rb delete mode 100644 lib/landable/traffic.rb delete mode 100644 lib/landable/traffic/crawl_tracker.rb delete mode 100644 lib/landable/traffic/noop_tracker.rb delete mode 100644 lib/landable/traffic/ping_tracker.rb delete mode 100644 lib/landable/traffic/scan_tracker.rb delete mode 100644 lib/landable/traffic/scrape_tracker.rb delete mode 100644 lib/landable/traffic/tracker.rb delete mode 100644 lib/landable/traffic/user_tracker.rb delete mode 100644 lib/landable/version.rb delete mode 100644 lib/tasks/landable/cucumber.rake delete mode 100644 lib/tasks/landable/data.rake delete mode 100644 lib/tasks/landable/pgtap.rake delete mode 100644 lib/tasks/landable/rdoc.rake delete mode 100644 lib/tasks/landable/seed.rake delete mode 100644 lib/tasks/landable/spec.rake delete mode 100755 script/cucumber delete mode 100644 spec/concerns/landable/has_assets_spec.rb delete mode 100644 spec/concerns/landable/table_name_spec.rb delete mode 100644 spec/concerns/landable/traffic/table_name_spec.rb delete mode 100644 spec/controllers/concerns/landable/variables_concern_spec.rb delete mode 100644 spec/controllers/landable/api/assets_controller_spec.rb delete mode 100644 spec/controllers/landable/api/categories_controller_spec.rb delete mode 100644 spec/controllers/landable/api/directories_controller_spec.rb delete mode 100644 spec/controllers/landable/api/page_revisions_controller_spec.rb delete mode 100644 spec/controllers/landable/api/pages_controller_spec.rb delete mode 100644 spec/controllers/landable/api_controller_spec.rb delete mode 100644 spec/controllers/public/preview/page_revisions_controller_spec.rb delete mode 100644 spec/controllers/public/preview/pages_controller_spec.rb delete mode 100644 spec/controllers/public/sitemap_controller_spec.rb delete mode 100644 spec/decorators/page_decorator_spec.rb delete mode 100644 spec/dummy/README.rdoc delete mode 100644 spec/dummy/Rakefile delete mode 100644 spec/dummy/app/assets/images/foo.jpg delete mode 100644 spec/dummy/app/assets/javascripts/application.js delete mode 100644 spec/dummy/app/assets/stylesheets/application.css delete mode 100644 spec/dummy/app/controllers/application_controller.rb delete mode 100644 spec/dummy/app/controllers/concerns/.keep delete mode 100644 spec/dummy/app/controllers/priority_controller.rb delete mode 100644 spec/dummy/app/helpers/application_helper.rb delete mode 100644 spec/dummy/app/mailers/.keep delete mode 100644 spec/dummy/app/models/.keep delete mode 100644 spec/dummy/app/models/concerns/.keep delete mode 100644 spec/dummy/app/views/layouts/application.html.erb delete mode 100644 spec/dummy/app/views/layouts/priority.html.erb delete mode 100644 spec/dummy/app/views/partials/_foobazz.html delete mode 100644 spec/dummy/app/views/priority/show.html.erb delete mode 100755 spec/dummy/bin/bundle delete mode 100755 spec/dummy/bin/rails delete mode 100755 spec/dummy/bin/rake delete mode 100644 spec/dummy/config.ru delete mode 100644 spec/dummy/config/application.rb delete mode 100644 spec/dummy/config/boot.rb delete mode 100644 spec/dummy/config/database.yml delete mode 100644 spec/dummy/config/environment.rb delete mode 100644 spec/dummy/config/environments/development.rb delete mode 100644 spec/dummy/config/environments/production.rb delete mode 100644 spec/dummy/config/environments/test.rb delete mode 100644 spec/dummy/config/initializers/backtrace_silencers.rb delete mode 100644 spec/dummy/config/initializers/filter_parameter_logging.rb delete mode 100644 spec/dummy/config/initializers/inflections.rb delete mode 100644 spec/dummy/config/initializers/landable.rb delete mode 100644 spec/dummy/config/initializers/mime_types.rb delete mode 100644 spec/dummy/config/initializers/secret_token.rb delete mode 100644 spec/dummy/config/initializers/session_store.rb delete mode 100644 spec/dummy/config/initializers/wrap_parameters.rb delete mode 100644 spec/dummy/config/locales/en.yml delete mode 100644 spec/dummy/config/routes.rb delete mode 100644 spec/dummy/db/structure.sql delete mode 100644 spec/dummy/lib/assets/.keep delete mode 100644 spec/dummy/log/.keep delete mode 100644 spec/dummy/public/404.html delete mode 100644 spec/dummy/public/422.html delete mode 100644 spec/dummy/public/500.html delete mode 100644 spec/dummy/public/favicon.ico delete mode 100644 spec/factories/asset.rb delete mode 100644 spec/factories/authors.rb delete mode 100644 spec/factories/category.rb delete mode 100644 spec/factories/page_revision.rb delete mode 100644 spec/factories/pages.rb delete mode 100644 spec/factories/template.rb delete mode 100644 spec/factories/theme.rb delete mode 100644 spec/fixtures/assets/cthulhu.jpg delete mode 100644 spec/fixtures/assets/panda.png delete mode 100644 spec/fixtures/assets/sloth.png delete mode 100644 spec/fixtures/assets/small.pdf delete mode 100644 spec/helpers/pages_helper_spec.rb delete mode 100644 spec/lib/landable/configuration_spec.rb delete mode 100644 spec/lib/landable/layout_spec.rb delete mode 100644 spec/lib/landable/liquid_spec.rb delete mode 100644 spec/lib/landable/migration_spec.rb delete mode 100644 spec/lib/landable/partial_spec.rb delete mode 100644 spec/lib/landable/tracking_spec.rb delete mode 100644 spec/lib/landable/traffic_spec.rb delete mode 100644 spec/models/landable/access_token_spec.rb delete mode 100644 spec/models/landable/asset_spec.rb delete mode 100644 spec/models/landable/directory_spec.rb delete mode 100644 spec/models/landable/page/errors_spec.rb delete mode 100644 spec/models/landable/page_revision_spec.rb delete mode 100644 spec/models/landable/page_spec.rb delete mode 100644 spec/models/landable/template_spec.rb delete mode 100644 spec/models/landable/theme_spec.rb delete mode 100644 spec/responders/page_render_responder_spec.rb delete mode 100644 spec/routing/public_page_route_spec.rb delete mode 100644 spec/services/landable/authentication_service_spec.rb delete mode 100644 spec/services/landable/render_service_spec.rb delete mode 100644 spec/services/landable/tidy_service_spec.rb delete mode 100644 spec/spec_helper.rb delete mode 100644 spec/support/behaviors.rb delete mode 100644 spec/support/carrier_wave.rb delete mode 100644 spec/support/categories.yml delete mode 100644 spec/support/helpers.rb diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 93fe022..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,5 +0,0 @@ -# Changelog - -See README.md before updating this file. - -## Unreleased [#] \ No newline at end of file diff --git a/Gemfile b/Gemfile deleted file mode 100644 index 51c7238..0000000 --- a/Gemfile +++ /dev/null @@ -1,15 +0,0 @@ -source "http://gems.enova.com" -source "https://rubygems.org" - -# Declare your gem's dependencies in landable.gemspec. -# Bundler will treat runtime dependencies like base dependencies, and -# development dependencies will be added by default to the :development group. -gemspec - -# Declare any dependencies that are still in development here instead of in -# your gemspec. These might include edge Rails or gems from your path or -# Git. Remember to move these dependencies to your gemspec before releasing -# your gem to rubygems.org. - -# To use debugger -# gem 'debugger' diff --git a/MIT-LICENSE b/MIT-LICENSE deleted file mode 100644 index 71b0872..0000000 --- a/MIT-LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright 2013 Enova International - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index 3535f8d..b00ef29 100644 --- a/README.md +++ b/README.md @@ -1,56 +1,16 @@ -# Landable - -Landable is an API for building your CMS. It's implemented as a [Rails Engine](http://guides.rubyonrails.org/engines.html). We like to use Landable with [Publicist](https://github.com/enova/publicist), a great UI for managing content. - - -## Installation - -Landable requires [Postgres](https://github.com/ged/ruby-pg). Make sure you have Postgres installed and configured in your app. - -Add `gem 'landable'` to your project's Gemfile and run `bundle`. - -Run `bundle exec rails g landable:install`, and update the new landable initializer to taste. - -Open your routes file, and ensure that the engine is mounted properly. Typically, this will be your final, catch-all route: - -```ruby -My::Application.routes.draw do - mount Landable::Engine => '/' -end -``` -Install Landable's migrations: - -```sh -rake landable:install:migrations -rake db:migrate -``` - -Checkout the wiki for steps on [configuration](https://github.com/enova/landable/wiki/Configuration). - -## Visit Tracking -Landable includes the ability to track visits. - -```ruby -Landable.configure do |config| - # To enable tracking, put one of the following in your Landable initializer: - config.traffic_enabled = true # Enables tracking for all requests. (:all is also accepted here.) - config.traffic_enabled = :html # Enables tracking for only HTML requests. -end -``` - -## Development - -Run `./bin/redb` to refresh the dummy app's database. - -Run the test suite with `rake landable`. - -## Contributing -Contributions are welcome - submit a pull request. - -* Do include specs to back up all code changes. -* Do add your changes to the "unreleased" section of [CHANGELOG.md](CHANGELOG.md) (adding this section if it does not exist). Include the pull request number. -* Don't bump Landable's version number. - -## License - -Landable is released under the [MIT License](https://github.com/enova/landable/blob/master/MIT-LICENSE). +# NOPE. + ++ o + o + + o + + +o + + o + + + ++ o o + o +-_-_-_-_-_-_-_,------, o +_-_-_-_-_-_-_-| /\_/\ +-_-_-_-_-_-_-~|__( ^ .^) + + +_-_-_-_-_-_-_-"" "" ++ o o + o + + + +o o o o + + o + ++ + o o + \ No newline at end of file diff --git a/Rakefile b/Rakefile deleted file mode 100644 index b66dfd0..0000000 --- a/Rakefile +++ /dev/null @@ -1,22 +0,0 @@ -begin - require 'bundler/setup' -rescue LoadError - puts 'You must `gem install bundler` and `bundle install` to run rake tasks' -end - -APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__) -load 'rails/tasks/engine.rake' - -require "bundler_geminabox/gem_tasks" -Bundler::GemHelper.install_tasks - -Dir.glob(File.expand_path('../lib/tasks/landable/*.rake', __FILE__)).each { |f| load f } - -desc 'Landable test suite' -task :landable => [ - 'app:db:test:prepare', - 'landable:seed', - 'landable:spec', - 'landable:cucumber', - 'landable:pgtap' -] \ No newline at end of file diff --git a/app/controllers/concerns/landable/variables_concern.rb b/app/controllers/concerns/landable/variables_concern.rb deleted file mode 100644 index a63eddb..0000000 --- a/app/controllers/concerns/landable/variables_concern.rb +++ /dev/null @@ -1,38 +0,0 @@ -require 'active_support/concern' - -module Landable - module VariablesConcern - # includes - extend ActiveSupport::Concern - - included do - # attribute definitions - cattr_accessor :imported_variables do - {} - end - end - - # standard methods - - # custom methods - module ClassMethods - def register_landable_variable(variable_name, method_name = nil) - method_name ||= variable_name - - imported_variables[variable_name] = method_name - end - end - - def fetch_landable_variables - variables = {} - - imported_variables.each do |variable_name, method_name| - variables[variable_name] = send(method_name) - end - - variables.with_indifferent_access - end - - # end - end -end \ No newline at end of file diff --git a/app/controllers/landable/api/access_tokens_controller.rb b/app/controllers/landable/api/access_tokens_controller.rb deleted file mode 100644 index b3d5996..0000000 --- a/app/controllers/landable/api/access_tokens_controller.rb +++ /dev/null @@ -1,48 +0,0 @@ -require_dependency "landable/api_controller" - -module Landable - module Api - class AccessTokensController < ApiController - skip_before_filter :require_author!, only: [:create] - - def show - respond_with find_own_access_token - end - - def create - ident = AuthenticationService.call(asset_token_params[:username], asset_token_params[:password]) - author = RegistrationService.call(ident) - - respond_with AccessToken.create!(author: author), status: :created - rescue Landable::AuthenticationFailedError - head :unauthorized - end - - def update - token = find_own_access_token - token.refresh! - - respond_with token - end - - def destroy - token = find_own_access_token - token.destroy! - head :no_content - rescue ActiveRecord::RecordNotFound - head :unauthorized - end - - - private - - def find_own_access_token(id = params[:id]) - current_author.access_tokens.fresh.find(id) - end - - def asset_token_params - params.require(:access_token).permit(:username, :password) - end - end - end -end diff --git a/app/controllers/landable/api/assets_controller.rb b/app/controllers/landable/api/assets_controller.rb deleted file mode 100644 index 2be5e76..0000000 --- a/app/controllers/landable/api/assets_controller.rb +++ /dev/null @@ -1,55 +0,0 @@ -require_dependency "landable/api_controller" -require_dependency "landable/asset_search_engine" - -module Landable - module Api - class AssetsController < ApiController - def index - search = Landable::AssetSearchEngine.new search_params.merge(ids: params[:ids]) - respond_with search.results, meta: search.meta - end - - def show - respond_with Asset.find(params[:id]) - end - - def create - asset = Asset.new asset_params - - if original = asset.duplicate_of - head :moved_permanently, location: asset_url(original) - return - end - - Asset.transaction do - asset.author = current_author - asset.save! - end - - respond_with asset, status: :created, location: asset_url(asset) - end - - def update - asset = Asset.find(params[:id]) - - asset.update_attributes! asset_params - - respond_with asset - end - - private - - def search_params - @search_params ||= - begin - hash = params.permit(search: [:name]) - hash[:search] || {} - end - end - - def asset_params - params.require(:asset).permit(:id, :name, :description, :data, :file) - end - end - end -end diff --git a/app/controllers/landable/api/categories_controller.rb b/app/controllers/landable/api/categories_controller.rb deleted file mode 100644 index d27caf9..0000000 --- a/app/controllers/landable/api/categories_controller.rb +++ /dev/null @@ -1,13 +0,0 @@ -module Landable - module Api - class CategoriesController < ApiController - def index - respond_with Category.all - end - - def show - respond_with Category.find(params[:id]) - end - end - end -end diff --git a/app/controllers/landable/api/directories_controller.rb b/app/controllers/landable/api/directories_controller.rb deleted file mode 100644 index 7888a71..0000000 --- a/app/controllers/landable/api/directories_controller.rb +++ /dev/null @@ -1,19 +0,0 @@ -require_dependency "landable/api_controller" - -module Landable - module Api - class DirectoriesController < ApiController - def index - ids = params[:ids] if params[:ids].present? and params[:ids].is_a? Array - ids ||= ['/'] - - listings = ids.map { |id| Directory.listing id } - respond_with listings - end - - def show - respond_with Directory.listing(params[:id]) - end - end - end -end diff --git a/app/controllers/landable/api/page_revisions_controller.rb b/app/controllers/landable/api/page_revisions_controller.rb deleted file mode 100644 index a569237..0000000 --- a/app/controllers/landable/api/page_revisions_controller.rb +++ /dev/null @@ -1,38 +0,0 @@ -require_dependency "landable/api_controller" - -module Landable - module Api - class PageRevisionsController < ApiController - skip_before_filter :require_author!, if: proc { |c| - c.action_name == 'show' && c.request.format == :html - } - - def index - page = Page.find(params[:page_id]) - respond_with page.revisions.order(:ordinal).reverse - end - - def show - revision = PageRevision.find(params[:id]) - - respond_to do |format| - format.json { respond_with revision } - format.html { respond_with revision.snapshot, responder: Landable::PageRenderResponder } - end - end - - def revert_to - revision = PageRevision.find(params[:id]) - revision.page.revert_to! revision - respond_with revision - end - - def screenshots - Landable::ScreenshotService.call PageRevision.find(params[:id]) - - # "{}" is valid json, which jquery will accept as a successful response. "" is not. - render json: {}, status: 202 - end - end - end -end diff --git a/app/controllers/landable/api/pages_controller.rb b/app/controllers/landable/api/pages_controller.rb deleted file mode 100644 index d890d86..0000000 --- a/app/controllers/landable/api/pages_controller.rb +++ /dev/null @@ -1,96 +0,0 @@ -require_dependency "landable/api_controller" - -module Landable - module Api - class PagesController < ApiController - def index - search = Landable::PageSearchEngine.new search_params.merge(ids: params[:ids]), limit: 100 - respond_with search.results, meta: search.meta - end - - def create - page = Page.new page_params - page.updated_by_author = current_author - page.save! - respond_with page, status: :created, location: page_url(page) - end - - def show - respond_with Page.find(params[:id]) - end - - def update - page = Page.find params[:id] - page.updated_by_author = current_author - page.update_attributes! page_params - respond_with page - end - - def publish - page = Page.find params[:id] - page.publish! author_id: current_author.id, notes: params[:notes], is_minor: !!params[:is_minor] - respond_with page - end - - def preview - page = Page.where(page_id: page_params[:id]).first_or_initialize - page.attributes = page_params - - # run the validators and render - if page.valid? - if layout = page.theme.try(:file) || false - content = with_format(:html) do - render_to_string text: RenderService.call(page), layout: layout - end - else - content = RenderService.call(page, preview: true) - end - end - - respond_to do |format| - format.json do - render json: { - page: { - preview: content, - errors: page.errors, - } - } - end - end - end - - def screenshots - Landable::ScreenshotService.call Page.find(params[:id]) - - # "{}" is valid json, which jquery will accept as a successful response. "" is not. - render json: {}, status: 202 - end - - private - - def search_params - @search_params ||= - begin - hash = params.permit(search: [:path]) - hash[:search] || {} - end - end - - def page_params - params.require(:page).permit(:id, :path, :theme_id, :category_id, :title, :head_content, :body, :status_code, :redirect_url, :lock_version, :abstract, :hero_asset_name, - meta_tags: [:description, :keywords, :robots]) - end - - def with_format(format, &block) - old_formats = formats - - begin - self.formats = [format] - return block.call - ensure - self.formats = old_formats - end - end - end - end -end diff --git a/app/controllers/landable/api/templates_controller.rb b/app/controllers/landable/api/templates_controller.rb deleted file mode 100644 index 0ecd672..0000000 --- a/app/controllers/landable/api/templates_controller.rb +++ /dev/null @@ -1,33 +0,0 @@ -require_dependency "landable/api_controller" - -module Landable - module Api - class TemplatesController < ApiController - def index - respond_with Template.all - end - - def create - template = Template.new(template_params) - template.save! - respond_with template, status: :created, location: template_url(template) - end - - def show - respond_with Template.find(params[:id]) - end - - def update - template = Template.find(params[:id]) - template.update_attributes! template_params - respond_with template - end - - private - - def template_params - params.require(:template).permit(:id, :name, :body, :description, :thumbnail_url, :slug, :is_layout) - end - end - end -end diff --git a/app/controllers/landable/api/themes_controller.rb b/app/controllers/landable/api/themes_controller.rb deleted file mode 100644 index 1b9d7e6..0000000 --- a/app/controllers/landable/api/themes_controller.rb +++ /dev/null @@ -1,57 +0,0 @@ -require_dependency "landable/api_controller" - -module Landable - module Api - class ThemesController < ApiController - def index - respond_with Theme.all - end - - def create - theme = Theme.new(theme_params) - theme.save! - respond_with theme, status: :created, location: theme_url(theme) - end - - def show - respond_with Theme.find(params[:id]) - end - - def update - theme = Theme.find(params[:id]) - theme.update_attributes! theme_params - respond_with theme - end - - def preview - theme = Theme.new(theme_params) - page = Page.example(theme: theme) - - params[:theme][:asset_ids].try(:each) do |asset_id| - theme.attachments.add Asset.find(asset_id) - end - - content = render_to_string( - text: RenderService.call(page), - layout: page.theme.file || false - ) - - respond_to do |format| - format.html do - render text: content, layout: false, content_type: 'text/html' - end - - format.json do - render json: {theme: {preview: content}} - end - end - end - - private - - def theme_params - params.require(:theme).permit(:id, :name, :body, :description, :thumbnail_url) - end - end - end -end diff --git a/app/controllers/landable/api_controller.rb b/app/controllers/landable/api_controller.rb deleted file mode 100644 index 6b7bf92..0000000 --- a/app/controllers/landable/api_controller.rb +++ /dev/null @@ -1,75 +0,0 @@ -require_dependency "landable/application_controller" -require_dependency "landable/api_responder" -require_dependency "landable/author" - -module Landable - class ApiController < ApplicationController - # skip any of these that may have been inherited from ::ApplicationController - skip_before_filter :protect_from_forgery - skip_before_action :verify_authenticity_token - - # tracking is not necessary for API calls - skip_around_action :track_with_landable! - - before_filter :require_author! - - respond_to :json - self.responder = Landable::ApiResponder - - rescue_from ActiveRecord::RecordNotFound do |ex| - head 404 - end - - rescue_from ActiveRecord::RecordInvalid do |ex| - render json: { errors: ex.record.errors }, status: :unprocessable_entity - end - - rescue_from ActionController::UnknownFormat do |ex| - head :not_acceptable - end - - rescue_from ActiveRecord::StaleObjectError do |ex| - render json: { author: ex.record.updated_by_author }, status: 409 - end - - rescue_from PG::Error do |ex| - if ex.message =~ /invalid input syntax for uuid/ - head :not_found - else - raise ex - end - end - - - # here's looking at you, http://developer.github.com/v3/media/ - # mime type matching is still handled by rails - see lib/landable/mime_types.rb - - API_MEDIA_REGEX = /^application\/vnd\.landable(\.v(?[\w\-]+))?(\.(?(?:[\w\-]+)))?(\+(?[\w\-]+))?/ - - def api_media - @api_media ||= begin - accept = request.headers['Accept'].match(API_MEDIA_REGEX) || {} - - { - version: Landable::VERSION::STRING, - format: request.format.symbol, - param: accept['param'].presence, - } - end - end - - protected - - def require_author! - head :unauthorized if current_author.nil? - end - - def current_author - return @current_author if @current_author - authenticate_with_http_basic do |username, token| - @current_author = Author.authenticate!(username, token) - end - end - - end -end diff --git a/app/controllers/landable/application_controller.rb b/app/controllers/landable/application_controller.rb deleted file mode 100644 index da0699d..0000000 --- a/app/controllers/landable/application_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -module Landable - class ApplicationController < ::ApplicationController - end -end diff --git a/app/controllers/landable/public/pages_controller.rb b/app/controllers/landable/public/pages_controller.rb deleted file mode 100644 index 430c466..0000000 --- a/app/controllers/landable/public/pages_controller.rb +++ /dev/null @@ -1,25 +0,0 @@ -require_dependency "landable/application_controller" - -module Landable - module Public - class PagesController < ApplicationController - respond_to :html - - self.responder = Landable::PageRenderResponder - - def show - respond_with current_snapshot - end - - private - - def current_page - @current_page ||= Page.by_path(request.path) - end - - def current_snapshot - @current_snapshot ||= current_page.published_revision.try(:snapshot) or Page.missing - end - end - end -end diff --git a/app/controllers/landable/public/preview/page_revisions_controller.rb b/app/controllers/landable/public/preview/page_revisions_controller.rb deleted file mode 100644 index 070e494..0000000 --- a/app/controllers/landable/public/preview/page_revisions_controller.rb +++ /dev/null @@ -1,16 +0,0 @@ -require_dependency "landable/application_controller" - -module Landable - module Public - module Preview - class PageRevisionsController < ApplicationController - respond_to :html - - def show - revision = PageRevision.find params[:id] - respond_with revision.snapshot, responder: Landable::PageRenderResponder - end - end - end - end -end \ No newline at end of file diff --git a/app/controllers/landable/public/preview/pages_controller.rb b/app/controllers/landable/public/preview/pages_controller.rb deleted file mode 100644 index 0edaf48..0000000 --- a/app/controllers/landable/public/preview/pages_controller.rb +++ /dev/null @@ -1,16 +0,0 @@ -require_dependency "landable/application_controller" - -module Landable - module Public - module Preview - class PagesController < ApplicationController - respond_to :html - - def show - page = Page.find params[:id] - respond_with page, responder: Landable::PageRenderResponder, preview: true - end - end - end - end -end diff --git a/app/controllers/landable/public/sitemap_controller.rb b/app/controllers/landable/public/sitemap_controller.rb deleted file mode 100644 index f3f7cb6..0000000 --- a/app/controllers/landable/public/sitemap_controller.rb +++ /dev/null @@ -1,18 +0,0 @@ -require_dependency "landable/application_controller" - -module Landable - module Public - class SitemapController < ApplicationController - def index - sitemap = Landable::Page.generate_sitemap( - host: Landable.configuration.sitemap_host || request.host, - protocol: Landable.configuration.sitemap_protocol, - exclude_categories: Landable.configuration.sitemap_exclude_categories, - sitemap_additional_paths: Landable.configuration.sitemap_additional_paths, - ) - - render xml: sitemap - end - end - end -end diff --git a/app/decorators/landable/null_page_decorator.rb b/app/decorators/landable/null_page_decorator.rb deleted file mode 100644 index 386c9ee..0000000 --- a/app/decorators/landable/null_page_decorator.rb +++ /dev/null @@ -1,26 +0,0 @@ -module Landable - class NullPageDecorator < Landable::PageDecorator - def initialize - end - - def title - # Obviously, this should instead be configured with Landable in some way, - # such that you can register the titles you want everywhere. Or, of course, - # a more reasonable way to bypass Landable entirely yet still use the - # `landable` helper. Just waiting to tease out what features we need. - content_tag('title', 'No current page; default title') - end - - def meta_tags - '' - end - - def path - '' - end - - def body - '' - end - end -end diff --git a/app/decorators/landable/page_decorator.rb b/app/decorators/landable/page_decorator.rb deleted file mode 100644 index 1087cb9..0000000 --- a/app/decorators/landable/page_decorator.rb +++ /dev/null @@ -1,40 +0,0 @@ -module Landable - class PageDecorator - include ActionView::Helpers::TagHelper - - def initialize(page) - raise TypeError.new("Use Landable::NullPageDecorator") if page.nil? - @page = page - end - - def title - content_tag('title', page.title) if page.title? - end - - def path - page.path - end - - def body - page.body.try(:html_safe) - end - - def head_content - page.head_content.try(:html_safe) - end - - def meta_tags - return unless tags = page.meta_tags - Rails.logger.info "Meta tags string: #{tags}" if tags.is_a? String - return if tags.empty? or !tags.is_a? Hash - - tags.map { |name, value| - tag('meta', name: name, content: value) if value.present? - }.compact.join("\n").html_safe - end - - private - - attr_reader :page # Keeping it private until there's a compelling reason not to - end -end diff --git a/app/helpers/landable/application_helper.rb b/app/helpers/landable/application_helper.rb deleted file mode 100644 index 0798d1b..0000000 --- a/app/helpers/landable/application_helper.rb +++ /dev/null @@ -1,13 +0,0 @@ -module Landable - module ApplicationHelper - def method_missing(method, *args, &block) - return main_app.send(method, *args) if method =~ /_(path|url)$/ && main_app.respond_to?(method) - super - end - - def respond_to?(method) - return true if method =~ /_(path|url)$/ && main_app.respond_to?(method) - super - end - end -end diff --git a/app/helpers/landable/pages_helper.rb b/app/helpers/landable/pages_helper.rb deleted file mode 100644 index 6be0f9e..0000000 --- a/app/helpers/landable/pages_helper.rb +++ /dev/null @@ -1,20 +0,0 @@ -module Landable - module PagesHelper - def landable(page = current_page) - return Landable::NullPageDecorator.new if page.nil? - @landable ||= Landable::PageDecorator.new(page) - end - - def current_page - if params[:controller] == "landable/public/preview/page_revisions" - current_page = PageRevision.find(params[:id]) - elsif params[:controller] == "landable/public/preview/pages" - current_page = Page.find(params[:id]) - else - current_page = Page.by_path(request.path) - end - - @current_page ||= current_page - end - end -end diff --git a/app/models/concerns/landable/has_assets.rb b/app/models/concerns/landable/has_assets.rb deleted file mode 100644 index 09fa88c..0000000 --- a/app/models/concerns/landable/has_assets.rb +++ /dev/null @@ -1,74 +0,0 @@ -# Pages, page revisions, and themes are all renderable. Rendering potentially -# involves assets. Rather than having to query for each asset as it's -# discovered, this concern allows retrieval of all asset names for a given -# body (#asset_names), and commits the habtm relation on save (#save_assets!; -# allows us to say "this asset belongs to 3 pages"). #assets is overridden to -# ensure that the assets returned /always/ reflect assets present in the Liquid -# template. - -require_dependency 'landable/liquid' - -module Landable - module HasAssets - extend ActiveSupport::Concern - - included do - has_and_belongs_to_many :assets, class_name: 'Landable::Asset', join_table: assets_join_table_name - - before_save :save_assets! - - def asset_names - # sticking with what we know about liquid, rather than doing regex. - # (though regex may be faster, should we need that optimization later.) - @asset_names ||= begin - template = ::Liquid::Template.parse(body) - asset_names_for_node template.root - end - end - - def assets - Landable::Asset.where(name: asset_names) - end - - # {asset_name: asset} - def assets_as_hash - Hash[assets.map { |asset| [asset.name, asset] }] - end - - # passthrough for body=; clears the asset_names cache in the process - def body= body_val - @asset_names = nil - self[:body] = body_val - end - - # this looks weird; I swear it works - def save_assets! - self.assets = self.assets - end - - - private - - def asset_names_for_node node, names = [] - # set up a recursing function to search for asset tags - if node.is_a? Landable::Liquid::AssetTag - names << node.asset_name unless names.include? node.asset_name - end - - if node.respond_to? :nodelist and node.nodelist - node.nodelist.each { |node| asset_names_for_node node, names } - end - - names - end - - end - - module ClassMethods - def assets_join_table_name - "#{Landable.configuration.database_schema_prefix}landable.#{self.name.underscore.split('/').last}_assets" - end - end - - end -end diff --git a/app/models/concerns/landable/table_name.rb b/app/models/concerns/landable/table_name.rb deleted file mode 100644 index 09ab75b..0000000 --- a/app/models/concerns/landable/table_name.rb +++ /dev/null @@ -1,12 +0,0 @@ -module Landable - module TableName - extend ActiveSupport::Concern - - included do - model_name = self.model_name.element.pluralize - schema_name = "#{Landable.configuration.database_schema_prefix}landable" - self.table_name = "#{schema_name}.#{model_name}" - end - - end -end \ No newline at end of file diff --git a/app/models/concerns/landable/traffic/table_name.rb b/app/models/concerns/landable/traffic/table_name.rb deleted file mode 100644 index 2dc3f4d..0000000 --- a/app/models/concerns/landable/traffic/table_name.rb +++ /dev/null @@ -1,14 +0,0 @@ -module Landable - module Traffic - module TableName - extend ActiveSupport::Concern - - included do - model_name = self.model_name.element.pluralize - schema_name = "#{Landable.configuration.database_schema_prefix}landable_traffic" - self.table_name = "#{schema_name}.#{model_name}" - end - - end - end -end \ No newline at end of file diff --git a/app/models/landable/access_token.rb b/app/models/landable/access_token.rb deleted file mode 100644 index dc18784..0000000 --- a/app/models/landable/access_token.rb +++ /dev/null @@ -1,20 +0,0 @@ -module Landable - class AccessToken < ActiveRecord::Base - include Landable::TableName - - belongs_to :author - validates_presence_of :author_id - validates_presence_of :expires_at - - before_validation do |token| - token.expires_at ||= 8.hours.from_now - end - - scope :fresh, -> { where('expires_at > ?', Time.zone.now) } - scope :expired, -> { where('expires_at <= ?', Time.zone.now) } - - def refresh! - update_column :expires_at, 8.hours.from_now - end - end -end diff --git a/app/models/landable/asset.rb b/app/models/landable/asset.rb deleted file mode 100644 index f890f33..0000000 --- a/app/models/landable/asset.rb +++ /dev/null @@ -1,63 +0,0 @@ -require_dependency 'landable/asset_uploader' - -require 'carrierwave/orm/activerecord' -require 'digest/md5' - -module Landable - class Asset < ActiveRecord::Base - include Landable::TableName - - mount_uploader :data, Landable::AssetUploader - alias :file :data - alias :file= :data= - - # This bit of indirection allows us to generate predictable - # URLs in the test environment. - def self.url_generator - @url_generator ||= proc { |asset| asset.data.try(:url) } - end - - belongs_to :author - has_and_belongs_to_many :pages, join_table: Page.assets_join_table_name - has_and_belongs_to_many :page_revisions, join_table: PageRevision.assets_join_table_name - has_and_belongs_to_many :themes, join_table: Theme.assets_join_table_name - - before_validation :write_metadata, on: :create - - validates_presence_of :data, :author - validates_presence_of :name, :mime_type, :md5sum, :file_size - validates_uniqueness_of :md5sum - validates_numericality_of :file_size, only_integer: true - validates_format_of :name, :with => /^[\w\._-]+$/, :on => :create, :multiline => true, :message => 'can only contain alphanumeric characters, periods, underscores, and dashes' - - def public_url - self.class.url_generator.call(self) - end - - def duplicate_of - return unless data.present? - self.class.where(md5sum: calculate_md5sum).first - end - - def associated_pages - paths = [] - Page.where("body like ?", "%#{self.name}%").each do |page| - paths.push(page.path) - end - paths - end - - private - - def calculate_md5sum - Digest::MD5.hexdigest(data.read) if data.present? - end - - def write_metadata - return unless data.present? - self.md5sum = calculate_md5sum - self.mime_type = data.file.content_type.presence || 'application/octet-stream' - self.file_size = data.file.size - end - end -end diff --git a/app/models/landable/asset_search_engine.rb b/app/models/landable/asset_search_engine.rb deleted file mode 100644 index 27f9a50..0000000 --- a/app/models/landable/asset_search_engine.rb +++ /dev/null @@ -1,20 +0,0 @@ -require_dependency "landable/search_engine" -require_dependency "landable/asset" - -module Landable - class AssetSearchEngine < SearchEngine - def initialize(filters) - super Asset.all, filters - end - - def filter_by!(filters) - if ids = as_array(filters[:ids]) - @scope = @scope.where(asset_id: ids) - end - - if name = filters[:name].presence - @scope = @scope.where('LOWER(name) LIKE ?', "%#{name}%".downcase) - end - end - end -end diff --git a/app/models/landable/author.rb b/app/models/landable/author.rb deleted file mode 100644 index 603a89e..0000000 --- a/app/models/landable/author.rb +++ /dev/null @@ -1,12 +0,0 @@ -module Landable - class Author < ActiveRecord::Base - include Landable::TableName - has_many :access_tokens - - def self.authenticate!(username, token_id) - return unless author = where(username: username).first - return unless author.access_tokens.fresh.exists?(token_id) - author - end - end -end diff --git a/app/models/landable/category.rb b/app/models/landable/category.rb deleted file mode 100644 index 46464f8..0000000 --- a/app/models/landable/category.rb +++ /dev/null @@ -1,27 +0,0 @@ -module Landable - class Category < ActiveRecord::Base - include Landable::TableName - - has_many :pages - - validates_uniqueness_of :name, case_sensitive: false - validates_uniqueness_of :slug - - before_validation :set_slug - - def to_liquid - { - 'name' => name, - 'pages' => pages.published, - } - end - - - protected - - def set_slug - self.slug = name.downcase.gsub(/[^\w]/, '_').gsub(/_{2,}/, '_') - end - - end -end diff --git a/app/models/landable/directory.rb b/app/models/landable/directory.rb deleted file mode 100644 index 8ab1b4b..0000000 --- a/app/models/landable/directory.rb +++ /dev/null @@ -1,23 +0,0 @@ -module Landable - class Directory - include ActiveModel::SerializerSupport - - def self.listing(parent) - parent_with_slash = parent.gsub(/^(.*?)\/?$/, '\1/') - pages = Page.where('path LIKE ?', "#{parent_with_slash}%").to_a - subdirs = pages.group_by { |page| page.directory_after(parent_with_slash) } - notdirs = subdirs.delete(nil) || [] - subdirs = subdirs.map { |name, contents| Directory.new("#{parent}/#{name}") } - Directory.new(parent, subdirs.sort_by(&:path), notdirs.sort_by(&:path)) - end - - attr_reader :path, :subdirectories, :pages - alias_attribute :id, :path - - def initialize(path, subdirectories = [], pages = []) - @path = path.squeeze '/' - @subdirectories = subdirectories - @pages = pages - end - end -end diff --git a/app/models/landable/page.rb b/app/models/landable/page.rb deleted file mode 100644 index 1ed7a45..0000000 --- a/app/models/landable/page.rb +++ /dev/null @@ -1,259 +0,0 @@ -require_dependency 'landable/theme' -require_dependency 'landable/page_revision' -require_dependency 'landable/category' -require_dependency 'landable/has_assets' -require_dependency 'landable/author' - -module Landable - class Page < ActiveRecord::Base - include ActionView::Helpers::TagHelper - include Landable::HasAssets - include Landable::Engine.routes.url_helpers - include Landable::TableName - - validates_presence_of :path, :status_code - validates_presence_of :redirect_url, if: -> page { page.redirect? } - - validates_inclusion_of :status_code, in: [200, 301, 302, 410] - - validates_with PathValidator, fields: [:path] - validates_uniqueness_of :path - validates :path, presence: true - - validate :forbid_changing_path, on: :update - - validate :body_strip_search - validates :redirect_url, url: true, allow_blank: true - validate :hero_asset_existence - - belongs_to :theme, class_name: 'Landable::Theme', inverse_of: :pages - belongs_to :published_revision, class_name: 'Landable::PageRevision' - belongs_to :category, class_name: 'Landable::Category' - belongs_to :updated_by_author, class_name: 'Landable::Author' - belongs_to :hero_asset, class_name: 'Landable::Asset' - has_many :revisions, class_name: 'Landable::PageRevision' - has_many :screenshots, class_name: 'Landable::Screenshot', as: :screenshotable - - scope :imported, -> { where("imported_at IS NOT NULL") } - scope :sitemappable, -> { where("COALESCE(meta_tags -> 'robots' NOT LIKE '%noindex%', TRUE)") - .where(status_code: 200)} - scope :published, -> { where("published_revision_id is NOT NULL") } - - before_validation :downcase_path! - - before_save -> page { - page.lock_version ||= 0 - page.is_publishable = true unless page.published_revision_id_changed? - } - - class << self - def missing - new(status_code: 410) - end - - def by_path(path) - where(path: path).first || missing - end - - def by_path!(path) - where(path: path).first! - end - - def with_fuzzy_path(path) - select("*, similarity(path, #{Page.sanitize path}) _sml"). - where('path LIKE ?', "%#{path}%"). - order('_sml DESC, path ASC') - end - - def example(attrs) - defaults = { - title: 'Example page', - body: '
Example page contents would live here
' - } - - new defaults.merge(attrs) - end - - - def generate_sitemap(options = {}) - pages = Landable::Page.sitemappable - xml = Builder::XmlMarkup.new( :indent => 2 ) - xml.instruct! :xml, encoding: "UTF-8" - xml.urlset(xmlns: "http://www.sitemaps.org/schemas/sitemap/0.9") do |xml| - pages.each do |page| - next if options[:exclude_categories].to_a.include? page.category.try(:name) - xml.url do |p| - p.loc "#{options[:protocol]}://#{options[:host]}#{page.path}" - p.lastmod page.updated_at.to_time.iso8601 - p.changefreq 'weekly' - p.priority '1' - end - end - - if options[:sitemap_additional_paths].present? - options[:sitemap_additional_paths].each do |page| - xml.url do |p| - p.loc "#{options[:protocol]}://#{options[:host]}#{page}" - p.changefreq 'weekly' - p.priority '1' - end - end - end - end - end - end - - def downcase_path! - path.try :downcase! - end - - def path_extension - path.match(/\.(\w{2,})$/).try(:[], 1) if path - end - - def content_type - case path_extension - when nil, 'htm', 'html' - 'text/html' - when 'json' - 'application/json' - when 'xml' - 'application/xml' - else - 'text/plain' - end - end - - def html? - content_type == 'text/html' - end - - def directory_after(prefix) - remainder = path.gsub(/^#{prefix}\/?/, '') - segments = remainder.split('/', 2) - if segments.length == 1 - nil - else - segments.first - end - end - - def redirect? - status_code == 301 || status_code == 302 - end - - def path=(name) - # if not present, add a leading slash for a non-empty path - if name and not name.empty? - name = name.gsub(/^\/?(.*)/, '/\1') - end - - self[:path] = name - end - - def hero_asset_name - self.hero_asset.try(:name) - end - - def hero_asset_name=(name) - @hero_asset_name = name - asset = Asset.find_by_name(name) - self.hero_asset_id = asset.try(:asset_id) - end - - def hero_asset_url - self.hero_asset.try(:public_url) - end - - def publish!(options) - transaction do - published_revision.unpublish! if published_revision - revision = revisions.create! options - update_attributes!(published_revision: revision, is_publishable: false) - end - end - - def published? - published_revision.present? - end - - def revert_to!(revision) - self.title = revision.title - self.path = revision.path - self.body = revision.body - self.head_content = revision.head_content - self.category_id = revision.category_id - self.theme_id = revision.theme_id - self.status_code = revision.status_code - self.meta_tags = revision.meta_tags - self.redirect_url = revision.redirect_url - - save! - end - - def preview_path - public_preview_page_path(self) - end - - def preview_url - public_preview_page_url(self) - end - - def forbid_changing_path - errors[:path] = "can not be changed!" if self.path_changed? - end - - def body_strip_search - begin - RenderService.call(self) - rescue ::Liquid::Error => error - errors[:body] = 'contains a Liquid syntax error' - rescue StandardError => error - errors[:body] = 'had a problem: ' + error.message - end - end - - def hero_asset_existence - return true if @hero_asset_name.blank? - unless Asset.find_by_name(@hero_asset_name) - errors[:hero_asset_name] = "System can't find an asset with this name" - end - end - - def to_liquid - { - "title" => title, - "url" => path, - "hero_asset" => hero_asset ? true : false, - "hero_asset_url" => hero_asset_url, - "abstract" => abstract - } - end - - module Errors - extend ActiveSupport::Concern - - class GoneError < Error - STATUS_CODE = 410 - end - - def error? - (400..599).cover? status_code - end - - def error - return nil unless error? - - case status_code - when 410 - GoneError.new - else - Landable::Error.new "Missing a Page error class for #{status_code}" - end - end - end - - include Errors - - end -end diff --git a/app/models/landable/page_revision.rb b/app/models/landable/page_revision.rb deleted file mode 100644 index 4348450..0000000 --- a/app/models/landable/page_revision.rb +++ /dev/null @@ -1,74 +0,0 @@ -require_dependency 'landable/has_assets' - -module Landable - class PageRevision < ActiveRecord::Base - include Landable::Engine.routes.url_helpers - include Landable::HasAssets - include Landable::TableName - - @@ignored_page_attributes = [ - 'page_id', - 'imported_at', - 'created_at', - 'updated_at', - 'published_revision_id', - 'is_publishable', - 'updated_by_author_id', - 'lock_version' - ] - - cattr_accessor :ignored_page_attributes - - belongs_to :author - belongs_to :page, inverse_of: :revisions - has_many :screenshots, class_name: 'Landable::Screenshot', as: :screenshotable - - def page_id=(id) - # set the value - self[:page_id] = id - - # copy grab attributes from the page - self.title = page.title - self.body = page.body - self.head_content = page.head_content - self.path = page.path - self.status_code = page.status_code - self.category_id = page.category_id - self.theme_id = page.theme_id - self.meta_tags = page.meta_tags - self.redirect_url = page.redirect_url - self.abstract = page.abstract - self.hero_asset_id = page.hero_asset_id - end - - def snapshot - Page.new(title: self.title, - meta_tags: page.meta_tags, - head_content: page.head_content, - body: self.body, - path: self.path, - redirect_url: self.redirect_url, - status_code: self.status_code, - theme_id: self.theme_id, - category_id: self.category_id, - abstract: self.abstract, - hero_asset_id: self.hero_asset_id) - end - - def publish! - update_attribute :is_published, true - end - - def unpublish! - update_attribute :is_published, false - end - - def preview_url - public_preview_page_revision_url(self) - end - - def preview_path - public_preview_page_revision_path(self) - end - end -end diff --git a/app/models/landable/page_search_engine.rb b/app/models/landable/page_search_engine.rb deleted file mode 100644 index ee87dcf..0000000 --- a/app/models/landable/page_search_engine.rb +++ /dev/null @@ -1,20 +0,0 @@ -require_dependency 'landable/search_engine' -require_dependency 'landable/page' - -module Landable - class PageSearchEngine < SearchEngine - def initialize(filters, options = {}) - super Page.all, filters, options - end - - def filter_by!(filters) - if ids = as_array(filters[:ids]) - @scope = @scope.where(page_id: ids) - end - - if path = filters[:path].presence - @scope = @scope.with_fuzzy_path(path) - end - end - end -end diff --git a/app/models/landable/search_engine.rb b/app/models/landable/search_engine.rb deleted file mode 100644 index ee8ced8..0000000 --- a/app/models/landable/search_engine.rb +++ /dev/null @@ -1,39 +0,0 @@ -module Landable - class SearchEngine - def initialize(base_scope, filters, options = {}) - @scope = base_scope - - order! options[:order] - limit! options[:limit] - - filter_by!(filters) - end - - def results - @scope - end - - def meta - { search: { total_results: @scope.count } } - end - - def filter_by!(filters) - raise NotImplementedError - end - - def order!(order) - @scope = @scope.order(order) if order - end - - def limit!(limit) - @scope = @scope.limit(limit) if limit - end - - protected - - def as_array(value) - array = Array(value) - array if array.any? - end - end -end diff --git a/app/models/landable/template.rb b/app/models/landable/template.rb deleted file mode 100644 index b322c1e..0000000 --- a/app/models/landable/template.rb +++ /dev/null @@ -1,24 +0,0 @@ -module Landable - class Template < ActiveRecord::Base - include Landable::TableName - - validates_presence_of :name, :slug, :description - validates_uniqueness_of :name, case_sensitive: false - validates_uniqueness_of :slug, case_sensitive: false - - def name= val - self[:name] = val - self[:slug] ||= (val && val.underscore.gsub(/[^\w_]/, '_').gsub(/_{2,}/, '_')) - end - - def partial? - file.present? - end - - class << self - def create_from_partials! - Partial.all.map(&:to_template) - end - end - end -end diff --git a/app/models/landable/theme.rb b/app/models/landable/theme.rb deleted file mode 100644 index b830984..0000000 --- a/app/models/landable/theme.rb +++ /dev/null @@ -1,20 +0,0 @@ -require_dependency 'landable/has_assets' - -module Landable - class Theme < ActiveRecord::Base - include Landable::TableName - include Landable::HasAssets - - validates_presence_of :name, :description - validates_uniqueness_of :name, case_sensitive: false - - has_many :pages, inverse_of: :theme - - class << self - def create_from_layouts! - return unless table_exists? - Layout.all.map(&:to_theme) - end - end - end -end diff --git a/app/models/landable/traffic/access.rb b/app/models/landable/traffic/access.rb deleted file mode 100644 index 78fdc2e..0000000 --- a/app/models/landable/traffic/access.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class Access < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_for :path, class_name: Path - - belongs_to :visitor - end - end -end diff --git a/app/models/landable/traffic/ad_group.rb b/app/models/landable/traffic/ad_group.rb deleted file mode 100644 index ad69571..0000000 --- a/app/models/landable/traffic/ad_group.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class AdGroup < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :ad_group, cache: 50, find_or_create: true - - has_many :attributions - end - end -end diff --git a/app/models/landable/traffic/ad_type.rb b/app/models/landable/traffic/ad_type.rb deleted file mode 100644 index d3f5826..0000000 --- a/app/models/landable/traffic/ad_type.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class AdType < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :ad_type, cache: 50, find_or_create: true - - has_many :attributions - end - end -end diff --git a/app/models/landable/traffic/attribution.rb b/app/models/landable/traffic/attribution.rb deleted file mode 100644 index 5463099..0000000 --- a/app/models/landable/traffic/attribution.rb +++ /dev/null @@ -1,38 +0,0 @@ -module Landable - module Traffic - class Attribution < ActiveRecord::Base - include Landable::Traffic::TableName - KEYS = %w[ad_type ad_group bid_match_type campaign content creative device_type experiment keyword match_type medium network placement position search_term source target] - - self.record_timestamps = false - - KEYS.each do |key| - lookup_for key.to_sym, class_name: "Landable::Traffic::#{key.classify}".constantize - end - - has_many :visits - - class << self - def transform(parameters) - hash = parameters.slice(*KEYS) - - filter = {} - - hash.each do |k, v| - filter[k.foreign_key] = "Landable::Traffic::#{k.classify}".constantize[v] - end - - filter - end - - def lookup(parameters) - where(transform(parameters)).first_or_create - end - - def digest(parameters) - Digest::SHA2.base64digest transform(parameters).values.join - end - end - end - end -end diff --git a/app/models/landable/traffic/bid_match_type.rb b/app/models/landable/traffic/bid_match_type.rb deleted file mode 100644 index 8960165..0000000 --- a/app/models/landable/traffic/bid_match_type.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class BidMatchType < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :bid_match_type, cache: 50, find_or_create: true - - has_many :attributions - end - end -end diff --git a/app/models/landable/traffic/browser.rb b/app/models/landable/traffic/browser.rb deleted file mode 100644 index 01209bd..0000000 --- a/app/models/landable/traffic/browser.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class Browser < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :browser, cache: 50, find_or_create: true - - has_many :user_agents - end - end -end diff --git a/app/models/landable/traffic/campaign.rb b/app/models/landable/traffic/campaign.rb deleted file mode 100644 index 9e3b49d..0000000 --- a/app/models/landable/traffic/campaign.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class Campaign < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :campaign, cache: 50, find_or_create: true - - has_many :attributions - end - end -end diff --git a/app/models/landable/traffic/city.rb b/app/models/landable/traffic/city.rb deleted file mode 100644 index 9d582e0..0000000 --- a/app/models/landable/traffic/city.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class City < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :city, cache: 50, find_or_create: true - - has_many :locations - end - end -end diff --git a/app/models/landable/traffic/content.rb b/app/models/landable/traffic/content.rb deleted file mode 100644 index 6e14c66..0000000 --- a/app/models/landable/traffic/content.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class Content < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :content, cache: 50, find_or_create: true - - has_many :attributions - end - end -end diff --git a/app/models/landable/traffic/cookie.rb b/app/models/landable/traffic/cookie.rb deleted file mode 100644 index 1d91a8b..0000000 --- a/app/models/landable/traffic/cookie.rb +++ /dev/null @@ -1,16 +0,0 @@ -module Landable - module Traffic - class Cookie < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :cookie_id, cache: 100, find: true - - has_many :ownerships - has_many :visits - - after_initialize do - self.id ||= SecureRandom.uuid - end - end - end -end diff --git a/app/models/landable/traffic/country.rb b/app/models/landable/traffic/country.rb deleted file mode 100644 index 62cb799..0000000 --- a/app/models/landable/traffic/country.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class Country < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :country, cache: true, find_or_create: true - - has_many :locations - end - end -end diff --git a/app/models/landable/traffic/creative.rb b/app/models/landable/traffic/creative.rb deleted file mode 100644 index b677ac9..0000000 --- a/app/models/landable/traffic/creative.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class Creative < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :creative, cache: 50, find_or_create: true - - has_many :attributions - end - end -end diff --git a/app/models/landable/traffic/device.rb b/app/models/landable/traffic/device.rb deleted file mode 100644 index a1ced34..0000000 --- a/app/models/landable/traffic/device.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class Device < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :device, cache: 50, find_or_create: true - - has_many :user_agents - end - end -end diff --git a/app/models/landable/traffic/device_type.rb b/app/models/landable/traffic/device_type.rb deleted file mode 100644 index ce5d3d2..0000000 --- a/app/models/landable/traffic/device_type.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class DeviceType < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :device_type, cache: 50, find_or_create: true - - has_many :attributions - end - end -end diff --git a/app/models/landable/traffic/domain.rb b/app/models/landable/traffic/domain.rb deleted file mode 100644 index 7452db0..0000000 --- a/app/models/landable/traffic/domain.rb +++ /dev/null @@ -1,12 +0,0 @@ -module Landable - module Traffic - class Domain < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :domain, cache: 50, find_or_create: true - - has_many :ip_lookups - has_many :referers - end - end -end diff --git a/app/models/landable/traffic/event.rb b/app/models/landable/traffic/event.rb deleted file mode 100644 index ebc1064..0000000 --- a/app/models/landable/traffic/event.rb +++ /dev/null @@ -1,12 +0,0 @@ -module Landable - module Traffic - class Event < ActiveRecord::Base - include Landable::Traffic::TableName - self.record_timestamps = false - - lookup_for :event_type, class_name: EventType, symbolize: true - - belongs_to :visit - end - end -end diff --git a/app/models/landable/traffic/event_type.rb b/app/models/landable/traffic/event_type.rb deleted file mode 100644 index 86866a1..0000000 --- a/app/models/landable/traffic/event_type.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class EventType < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :event_type, cache: true, find_or_create: true - - has_many :events - end - end -end diff --git a/app/models/landable/traffic/experiment.rb b/app/models/landable/traffic/experiment.rb deleted file mode 100644 index 0c89bfe..0000000 --- a/app/models/landable/traffic/experiment.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class Experiment < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :experiment, cache: 50, find_or_create: true - - has_many :attributions - end - end -end diff --git a/app/models/landable/traffic/http_method.rb b/app/models/landable/traffic/http_method.rb deleted file mode 100644 index 7dc03ed..0000000 --- a/app/models/landable/traffic/http_method.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class HTTPMethod < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :http_method, cache: true, find_or_create: true - - has_many :page_views - end - end -end diff --git a/app/models/landable/traffic/ip_address.rb b/app/models/landable/traffic/ip_address.rb deleted file mode 100644 index 5f88792..0000000 --- a/app/models/landable/traffic/ip_address.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class IpAddress < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :ip_address, cache: 50, find_or_create: true - - has_many :visitors - end - end -end diff --git a/app/models/landable/traffic/ip_lookup.rb b/app/models/landable/traffic/ip_lookup.rb deleted file mode 100644 index 91a2805..0000000 --- a/app/models/landable/traffic/ip_lookup.rb +++ /dev/null @@ -1,12 +0,0 @@ -module Landable - module Traffic - class IpLookup < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_for :ip_address, class_name: IpAddress - lookup_for :domain, class_name: Domain - - belongs_to :location - end - end -end diff --git a/app/models/landable/traffic/keyword.rb b/app/models/landable/traffic/keyword.rb deleted file mode 100644 index 6f11dcc..0000000 --- a/app/models/landable/traffic/keyword.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class Keyword < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :keyword, cache: 50, find_or_create: true - - has_many :attributions - end - end -end diff --git a/app/models/landable/traffic/location.rb b/app/models/landable/traffic/location.rb deleted file mode 100644 index 7689551..0000000 --- a/app/models/landable/traffic/location.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class Location < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_for :country, class_name: Country - lookup_for :region, class_name: Region - lookup_for :city, class_name: City - end - end -end diff --git a/app/models/landable/traffic/match_type.rb b/app/models/landable/traffic/match_type.rb deleted file mode 100644 index 66b5b14..0000000 --- a/app/models/landable/traffic/match_type.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class MatchType < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :match_type, cache: 50, find_or_create: true - - has_many :attributions - end - end -end diff --git a/app/models/landable/traffic/medium.rb b/app/models/landable/traffic/medium.rb deleted file mode 100644 index 84e6f0e..0000000 --- a/app/models/landable/traffic/medium.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class Medium < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :medium, cache: 50, find_or_create: true - - has_many :attributions - end - end -end diff --git a/app/models/landable/traffic/mime_type.rb b/app/models/landable/traffic/mime_type.rb deleted file mode 100644 index a19fb21..0000000 --- a/app/models/landable/traffic/mime_type.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class MimeType < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :mime_type, cache: 50, find_or_create: true - - has_many :page_views - end - end -end diff --git a/app/models/landable/traffic/network.rb b/app/models/landable/traffic/network.rb deleted file mode 100644 index ea867e6..0000000 --- a/app/models/landable/traffic/network.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class Network < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :network, cache: 50, find_or_create: true - - has_many :attributions - end - end -end diff --git a/app/models/landable/traffic/owner.rb b/app/models/landable/traffic/owner.rb deleted file mode 100644 index db61bc7..0000000 --- a/app/models/landable/traffic/owner.rb +++ /dev/null @@ -1,10 +0,0 @@ -module Landable - module Traffic - class Owner < ActiveRecord::Base - include Landable::Traffic::TableName - - has_many :ownerships - has_many :visits - end - end -end diff --git a/app/models/landable/traffic/ownership.rb b/app/models/landable/traffic/ownership.rb deleted file mode 100644 index 701c27a..0000000 --- a/app/models/landable/traffic/ownership.rb +++ /dev/null @@ -1,10 +0,0 @@ -module Landable - module Traffic - class Ownership < ActiveRecord::Base - include Landable::Traffic::TableName - - belongs_to :cookie - belongs_to :owner - end - end -end diff --git a/app/models/landable/traffic/page_view.rb b/app/models/landable/traffic/page_view.rb deleted file mode 100644 index fa200c1..0000000 --- a/app/models/landable/traffic/page_view.rb +++ /dev/null @@ -1,24 +0,0 @@ -module Landable - module Traffic - class PageView < ActiveRecord::Base - include Landable::Traffic::TableName - self.record_timestamps = false - - belongs_to :visit - - lookup_for :mime_type, class_name: MimeType - lookup_for :http_method, class_name: HTTPMethod - lookup_for :path, class_name: Path - lookup_for :query_string, class_name: QueryString - - before_create :set_page_revision - - protected - - def set_page_revision - page = Landable::Page.where(path: path).select(:published_revision_id).first - self.page_revision_id = page.try(:published_revision_id) - end - end - end -end diff --git a/app/models/landable/traffic/path.rb b/app/models/landable/traffic/path.rb deleted file mode 100644 index 284bc8f..0000000 --- a/app/models/landable/traffic/path.rb +++ /dev/null @@ -1,13 +0,0 @@ -module Landable - module Traffic - class Path < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :path, cache: 50, find_or_create: true - - has_many :accesses - has_many :page_views - has_many :referers - end - end -end diff --git a/app/models/landable/traffic/placement.rb b/app/models/landable/traffic/placement.rb deleted file mode 100644 index 32835f3..0000000 --- a/app/models/landable/traffic/placement.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class Placement < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :placement, cache: 50, find_or_create: true - - has_many :attributions - end - end -end diff --git a/app/models/landable/traffic/platform.rb b/app/models/landable/traffic/platform.rb deleted file mode 100644 index 3814a6c..0000000 --- a/app/models/landable/traffic/platform.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class Platform < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :platform, cache: 50, find_or_create: true - - has_many :user_agents - end - end -end diff --git a/app/models/landable/traffic/position.rb b/app/models/landable/traffic/position.rb deleted file mode 100644 index 6687fc8..0000000 --- a/app/models/landable/traffic/position.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class Position < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :position, cache: 50, find_or_create: true - - has_many :attributions - end - end -end diff --git a/app/models/landable/traffic/query_string.rb b/app/models/landable/traffic/query_string.rb deleted file mode 100644 index 50e1c96..0000000 --- a/app/models/landable/traffic/query_string.rb +++ /dev/null @@ -1,12 +0,0 @@ -module Landable - module Traffic - class QueryString < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :query_string, cache: 50, find_or_create: true, allow_blank: true - - has_many :page_views - has_many :referers - end - end -end diff --git a/app/models/landable/traffic/referer.rb b/app/models/landable/traffic/referer.rb deleted file mode 100644 index 2f8f11b..0000000 --- a/app/models/landable/traffic/referer.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class Referer < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_for :domain, class_name: Domain - lookup_for :path, class_name: Path - lookup_for :query_string, class_name: QueryString - end - end -end diff --git a/app/models/landable/traffic/region.rb b/app/models/landable/traffic/region.rb deleted file mode 100644 index ff3ee87..0000000 --- a/app/models/landable/traffic/region.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class Region < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :region, cache: 50, find_or_create: true - - has_many :locations - end - end -end diff --git a/app/models/landable/traffic/search_term.rb b/app/models/landable/traffic/search_term.rb deleted file mode 100644 index 922c09d..0000000 --- a/app/models/landable/traffic/search_term.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class SearchTerm < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :search_term, cache: 50, find_or_create: true - - has_many :attributions - end - end -end diff --git a/app/models/landable/traffic/source.rb b/app/models/landable/traffic/source.rb deleted file mode 100644 index fdbb4ee..0000000 --- a/app/models/landable/traffic/source.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class Source < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :source, cache: 50, find_or_create: true - - has_many :attributions - end - end -end diff --git a/app/models/landable/traffic/target.rb b/app/models/landable/traffic/target.rb deleted file mode 100644 index 479e358..0000000 --- a/app/models/landable/traffic/target.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class Target < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :target, cache: 50, find_or_create: true - - has_many :attributions - end - end -end diff --git a/app/models/landable/traffic/user_agent.rb b/app/models/landable/traffic/user_agent.rb deleted file mode 100644 index 2e7cc1f..0000000 --- a/app/models/landable/traffic/user_agent.rb +++ /dev/null @@ -1,28 +0,0 @@ -module Landable - module Traffic - class UserAgent < ActiveRecord::Base - include Landable::Traffic::TableName - self.record_timestamps = false - - lookup_by :user_agent, cache: 50, find_or_create: true - - lookup_for :user_agent_type, class_name: UserAgentType - lookup_for :device, class_name: Device - lookup_for :platform, class_name: Platform - lookup_for :browser, class_name: Traffic::Browser - - has_many :visitors - - before_save do - self.user_agent_type ||= case user_agent - when /pingdom|newrelicpinger/i - 'ping' - when /scanalert|tinfoilsecurity/i - 'scan' - when /bot|crawl|spider/i - 'crawl' - end - end - end - end -end diff --git a/app/models/landable/traffic/user_agent_type.rb b/app/models/landable/traffic/user_agent_type.rb deleted file mode 100644 index 35582bb..0000000 --- a/app/models/landable/traffic/user_agent_type.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Landable - module Traffic - class UserAgentType < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_by :user_agent_type, cache: true - - has_many :user_agents - end - end -end diff --git a/app/models/landable/traffic/visit.rb b/app/models/landable/traffic/visit.rb deleted file mode 100644 index 95fce32..0000000 --- a/app/models/landable/traffic/visit.rb +++ /dev/null @@ -1,15 +0,0 @@ -module Landable - module Traffic - class Visit < ActiveRecord::Base - include Landable::Traffic::TableName - self.record_timestamps = false - - belongs_to :attribution - belongs_to :cookie - belongs_to :owner - belongs_to :visitor - - has_many :page_views - end - end -end diff --git a/app/models/landable/traffic/visitor.rb b/app/models/landable/traffic/visitor.rb deleted file mode 100644 index 97e6330..0000000 --- a/app/models/landable/traffic/visitor.rb +++ /dev/null @@ -1,13 +0,0 @@ -module Landable - module Traffic - class Visitor < ActiveRecord::Base - include Landable::Traffic::TableName - - lookup_for :ip_address, class_name: IpAddress - lookup_for :user_agent, class_name: UserAgent - - has_many :accesses - has_many :visits - end - end -end diff --git a/app/responders/landable/api_responder.rb b/app/responders/landable/api_responder.rb deleted file mode 100644 index 4543cdc..0000000 --- a/app/responders/landable/api_responder.rb +++ /dev/null @@ -1,76 +0,0 @@ -module Landable - class ApiResponder < ActionController::Responder - def to_format - controller.response.headers['X-Landable-Media-Type'] = api_media_type - - if serializer = resource_serializer - options[collection_resource? ? :each_serializer : :serializer] = serializer - controller.response.headers['X-Landable-Serializer'] = serializer.name if leaky? - end - - if leaky? && format == :json && schema = json_schema - key = collection_resource? ? resource_name.pluralize : resource_name - link = "<#{schema}>; rel=\"describedby\"; anchor=\"#/#{key}\"" - link = "#{link}; collection=\"collection\"" if collection_resource? - controller.response.headers['Link'] = link - end - - # For updates, rails defaults to returning 204 No Content; - # we would actually prefer that the updated record be returned, - # in case an update to one key necessitates an automatic update to another. - if patch? || put? - display resource - else - super - end - end - - private - - def leaky? - Rails.env.development? || Rails.env.test? - end - - def collection_resource? - Array === resource || ActiveRecord::Relation === resource - end - - def json_schema - path = Landable::Engine.root.join('doc', 'schema', "#{resource_name}.json") - return unless path.exist? - "file://#{path}#" - end - - def resource_name - @resource_name ||= resource_class.name.demodulize.underscore - end - - def resource_class - @resource_class ||= - case resource - when Array then resource.first.class - when ActiveRecord::Relation then resource.klass - else resource.class - end - end - - def resource_serializer - return if @resource_serializer == false - @resource_serializer ||= "#{resource_class}Serializer".constantize - rescue NameError - @resource_serializer = false - nil - end - - def api_media_type - api_media = controller.api_media - - h = [] - h << "landable.v#{api_media[:version]}" - h << "param=#{api_media[:param]}" if api_media[:param] - h << "format=#{api_media[:format]}" - - h.join('; ') - end - end -end diff --git a/app/responders/landable/page_render_responder.rb b/app/responders/landable/page_render_responder.rb deleted file mode 100644 index 35b966a..0000000 --- a/app/responders/landable/page_render_responder.rb +++ /dev/null @@ -1,15 +0,0 @@ -module Landable - class PageRenderResponder < ActionController::Responder - def to_html - page = resource - - case page.status_code - when 200 then render text: RenderService.call(page, preview: options[:preview], responder: self), - content_type: page.content_type, - layout: (page.theme.try(:file) || false) - when 301, 302 then redirect_to page.redirect_url, status: page.status_code - else raise page.error - end - end - end -end diff --git a/app/serializers/landable/access_token_serializer.rb b/app/serializers/landable/access_token_serializer.rb deleted file mode 100644 index bd8e60b..0000000 --- a/app/serializers/landable/access_token_serializer.rb +++ /dev/null @@ -1,6 +0,0 @@ -module Landable - class AccessTokenSerializer < ActiveModel::Serializer - attributes :id, :expires_at - has_one :author, embed: :object - end -end diff --git a/app/serializers/landable/asset_serializer.rb b/app/serializers/landable/asset_serializer.rb deleted file mode 100644 index 0a8e77d..0000000 --- a/app/serializers/landable/asset_serializer.rb +++ /dev/null @@ -1,14 +0,0 @@ -module Landable - class AssetSerializer < ActiveModel::Serializer - attributes :id, :name, :description - attributes :file_size, :mime_type, :md5sum - attributes :created_at, :updated_at - attributes :public_url - - embed :ids - - has_one :author, include: true, serializer: AuthorSerializer - has_many :pages - has_many :themes - end -end diff --git a/app/serializers/landable/author_serializer.rb b/app/serializers/landable/author_serializer.rb deleted file mode 100644 index 1cbba01..0000000 --- a/app/serializers/landable/author_serializer.rb +++ /dev/null @@ -1,5 +0,0 @@ -module Landable - class AuthorSerializer < ActiveModel::Serializer - attributes :id, :username, :email, :first_name, :last_name - end -end diff --git a/app/serializers/landable/category_serializer.rb b/app/serializers/landable/category_serializer.rb deleted file mode 100644 index 3e49055..0000000 --- a/app/serializers/landable/category_serializer.rb +++ /dev/null @@ -1,5 +0,0 @@ -module Landable - class CategorySerializer < ActiveModel::Serializer - attributes :id, :name, :description - end -end diff --git a/app/serializers/landable/directory_serializer.rb b/app/serializers/landable/directory_serializer.rb deleted file mode 100644 index 6d25c16..0000000 --- a/app/serializers/landable/directory_serializer.rb +++ /dev/null @@ -1,8 +0,0 @@ -module Landable - class DirectorySerializer < ActiveModel::Serializer - attributes :id, :path - - has_many :subdirectories, embed: :ids, embed_key: :path - has_many :pages, embed: :ids - end -end diff --git a/app/serializers/landable/page_revision_serializer.rb b/app/serializers/landable/page_revision_serializer.rb deleted file mode 100644 index cd40571..0000000 --- a/app/serializers/landable/page_revision_serializer.rb +++ /dev/null @@ -1,15 +0,0 @@ -require_dependency 'landable/author_serializer' -require_dependency 'landable/theme' - -module Landable - class PageRevisionSerializer < ActiveModel::Serializer - attributes :id, :ordinal, :notes, :is_minor, :is_published - attributes :created_at, :updated_at - attributes :preview_path - - embed :ids - has_one :page - has_one :author, include: true, serializer: AuthorSerializer - - end -end diff --git a/app/serializers/landable/page_serializer.rb b/app/serializers/landable/page_serializer.rb deleted file mode 100644 index dc93a79..0000000 --- a/app/serializers/landable/page_serializer.rb +++ /dev/null @@ -1,31 +0,0 @@ -module Landable - class PageSerializer < ActiveModel::Serializer - attributes :id - attributes :path - attributes :title - attributes :body - attributes :head_content - attributes :redirect_url - attributes :meta_tags - attributes :is_publishable - attributes :preview_path - attributes :lock_version - attributes :status_code - attributes :abstract - attributes :hero_asset_name - - embed :ids - has_one :theme - has_one :published_revision - has_one :category - has_one :updated_by_author, root: :authors, include: true, serializer: AuthorSerializer - - def category - object.category || Landable::Category.where(name: 'Uncategorized').first - end - - def meta_tags - object.meta_tags || {} - end - end -end diff --git a/app/serializers/landable/template_serializer.rb b/app/serializers/landable/template_serializer.rb deleted file mode 100644 index 814ad7f..0000000 --- a/app/serializers/landable/template_serializer.rb +++ /dev/null @@ -1,5 +0,0 @@ -module Landable - class TemplateSerializer < ActiveModel::Serializer - attributes :id, :name, :body, :description, :thumbnail_url, :slug, :is_layout, :editable, :file - end -end diff --git a/app/serializers/landable/theme_serializer.rb b/app/serializers/landable/theme_serializer.rb deleted file mode 100644 index 49d61fa..0000000 --- a/app/serializers/landable/theme_serializer.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Landable - class ThemeSerializer < ActiveModel::Serializer - attributes :id, :name, :editable, :body, :description, :thumbnail_url - - embed :ids - end -end diff --git a/app/services/landable/authentication_service.rb b/app/services/landable/authentication_service.rb deleted file mode 100644 index 9d7aca7..0000000 --- a/app/services/landable/authentication_service.rb +++ /dev/null @@ -1,44 +0,0 @@ -module Landable - AuthenticationFailedError = Class.new(StandardError) - - module AuthenticationService - def self.call(username, password) - strategies = Landable.configuration.authenticators - - strategies.each do |strategy| - ident = strategy.call username, password - return ident if ident - end - - raise AuthenticationFailedError - end - - class EchoAuthenticator - def self.call(username, password) - new(nil, nil).call(username, password) - end - - def initialize(username, password) - @username = username - @password = password - end - - def call(username, password) - return unless acceptable_environment? - return echo_author(username) if @username.nil? && password != 'fail' - return echo_author(username) if @username == username && @password == password - end - - private - - def acceptable_environment? - defined?(::Rails) && (Rails.env.development? || Rails.env.test?) - end - - def echo_author(username) - { username: username, email: "#{username}@example.com", - first_name: 'Trogdor', last_name: 'McBurninator' } - end - end - end -end diff --git a/app/services/landable/registration_service.rb b/app/services/landable/registration_service.rb deleted file mode 100644 index 9d01c67..0000000 --- a/app/services/landable/registration_service.rb +++ /dev/null @@ -1,13 +0,0 @@ -require_dependency "landable/author" - -module Landable - class RegistrationService - def self.call(attributes) - if author = Author.where(username: attributes[:username]).first - author - else - Author.create!(attributes.slice(:username, :email, :first_name, :last_name)) - end - end - end -end diff --git a/app/services/landable/render_service.rb b/app/services/landable/render_service.rb deleted file mode 100644 index 376dc7c..0000000 --- a/app/services/landable/render_service.rb +++ /dev/null @@ -1,86 +0,0 @@ -# TODO Handle layouts-as-themes here - -require_dependency 'landable/liquid' - -module Landable - class RenderService - def self.call(page, options = nil) - new(page, page.theme, options).render! - end - - def initialize(page, theme, options = nil) - @page = page - @theme = theme - @options = options || {} - end - - def render! - variables = options[:responder].try(:controller).try(:fetch_landable_variables) - variables ||= {} - - content = render_template(page.body, variables, registers: { - page: page, - assets: assets_for_page, - responder: options[:responder], - }) - - if layout? - content = render_template(theme.body, {'body' => content}, registers: { - page: page, - assets: assets_for_theme, - }) - end - - # not completely happy about this - if options[:preview] - if page.html? - # fancy! - preview_template = File.open(Landable::Engine.root.join('app', 'views', 'templates', 'preview.liquid')).read - - content = render_template(preview_template, { - 'content' => content, - 'is_redirect' => page.redirect?, - 'is_html' => page.html?, - 'status_code' => page.status_code, - 'redirect_url' => page.redirect_url, - }) - else - # non-html stuff just gets rendered as plaintext for a preview - content = '
' + CGI::escapeHTML(content) + '
' - end - end - - content - end - - private - - attr_reader :page, :theme, :options - - def layout? - theme && theme.body.present? && theme.file.blank? && page.html? - end - - def parse(body) - ::Liquid::Template.parse(body) - end - - def assets_for_page - @assets_for_page ||= - begin - from_theme = theme ? theme.assets_as_hash : {} - from_theme.merge page.assets_as_hash - end - end - - def assets_for_theme - @assets_for_theme ||= theme ? theme.assets_as_hash : {} - end - - def render_template template, variables = {}, liquid_options = {} - variables['categories'] = Liquid::CategoriesDrop.new - - parse(template).render!(variables, liquid_options) - end - end -end diff --git a/app/services/landable/tidy_service.rb b/app/services/landable/tidy_service.rb deleted file mode 100644 index fee28c3..0000000 --- a/app/services/landable/tidy_service.rb +++ /dev/null @@ -1,155 +0,0 @@ -module Landable - module TidyService - - class TidyError < StandardError; end - - mattr_accessor :options - @@options = [ - # is what we have - '-utf8', - - # two-space soft indents - '-indent', - - # no wrapping - '--wrap 0', - - # make some guesses about how the code should look - '--clean true', - - # kill microsoft word crap - '--bare true', - - # quote 'em up - '--quote-ampersand true', - - # whitespace niceness - '--break-before-br true', - - # allow
- '--merge-divs false', - - # silence will fall - '--quiet true', - '--show-warnings false', - ] - - # list of liquid tags that also render tags - things that we should - # consider to be element-level, and therefore to be tidied along with the - # rest of the dom - mattr_accessor :liquid_elements - @@liquid_elements = [ - 'template', - 'title_tag', - 'meta_tags', - 'img_tag', - ] - - - def self.call! input - self.call input, raise_on_error: true - end - - def self.call input, runtime_options={} - if not tidyable? - raise TidyError, 'Your system doesn\'t seem to have tidy installed. Please see https://github.com/w3c/tidy-html5.' - end - - # wrapping known liquid in a span to allow tidy to format them nicely - input = wrap_liquid input - - # off to tidy - output = IO.popen("tidy #{options.join(' ')}", 'r+') do |io| - io.puts input - io.close_write - io.read - end - - # 0: success - # 1: warning - # 2: error - # 3: ??? - # 4: profit - if $?.exitstatus >= 2 and runtime_options[:raise_on_error] - raise TidyError, "Tidy exited with status #{$?} - check stderr." - end - - # unnwrapping the liquid that we wrapped earlier - output = unwrap_liquid output - - # create and return a Result, allowing access to specific bits of the output - Result.new output - end - - def self.tidyable? - @@is_tidyable ||= Kernel.system('which tidy > /dev/null') - end - - protected - - def self.wrap_liquid input - output = input.dup - - output.scan(/(\s*(\{% *(?:#{liquid_elements.join('|')}) *.*?%})\s*)/).each do |match, liquid| - # encode and stash in a div, inserted between newlines, to allow tidy - # to nudge this element around as appropriate - encoded = Base64.encode64(liquid).strip - output.gsub! match, "
" - end - - output - end - - def self.unwrap_liquid input - output = input.dup - - output.scan(/(
<\/div>)/).each do |match, liquid| - # ensure we match utf8 for utf8 - decoded = Base64.decode64(liquid).force_encoding(match.encoding) - output.gsub! match, decoded - end - - output - end - - - class Result < Object - def initialize source - @source = source - end - - def to_s - @source - end - - def body - if match = @source.match(/]*)?>(.*)<\/body>/m) - deindent match[1] - end - end - - def head - if match = @source.match(/(.*)<\/head>/m) - deindent match[1] - end - end - - def css - links = head.try :scan, /]*type=['"]text\/css['"][^>]*>/ - styles = head.try :scan, /]*>.*?<\/style>/m - [links.to_a, styles.to_a].flatten.join("\n\n") - end - - protected - - def deindent string - if match = string.match(/^([ \t]*)[^\s]/) - string.gsub(/^#{match[1]}/, '').strip - else - string.strip - end - end - end - - end -end \ No newline at end of file diff --git a/app/uploaders/landable/asset_uploader.rb b/app/uploaders/landable/asset_uploader.rb deleted file mode 100644 index 144407d..0000000 --- a/app/uploaders/landable/asset_uploader.rb +++ /dev/null @@ -1,9 +0,0 @@ -# encoding: utf-8 -require 'carrierwave' - -module Landable - class AssetUploader < CarrierWave::Uploader::Base - include CarrierWave::MimeTypes - process :set_content_type - end -end diff --git a/app/validators/path_validator.rb b/app/validators/path_validator.rb deleted file mode 100644 index 43853d4..0000000 --- a/app/validators/path_validator.rb +++ /dev/null @@ -1,12 +0,0 @@ -class PathValidator < ActiveModel::Validator - def validate(record) - if match?(record.path) - record.errors[:path] << "is Reserved!" - end - end - - def match?(path) - # See if the applying path matches any reserved_paths via a Regex - Landable.configuration.reserved_paths.any? { |reserved| Regexp.new("^#{reserved}$", 'i').match(path) } - end -end diff --git a/app/validators/url_validator.rb b/app/validators/url_validator.rb deleted file mode 100644 index 8c6a28d..0000000 --- a/app/validators/url_validator.rb +++ /dev/null @@ -1,13 +0,0 @@ -class UrlValidator < ActiveModel::EachValidator - - def validate_each(record, attribute, value) - valid = begin - value =~ /^[a-z]+\:\/\// or value =~ /^\// - end - - unless valid - record.errors[attribute] << ("Invalid URL! Make sure it starts with http:// or /") - end - end - -end \ No newline at end of file diff --git a/app/views/templates/preview.liquid b/app/views/templates/preview.liquid deleted file mode 100644 index 2b09a57..0000000 --- a/app/views/templates/preview.liquid +++ /dev/null @@ -1,122 +0,0 @@ - {% if is_redirect %} - - - - - - -
-
-

- This page will redirect ({{ status_code }}) to: - - {{ redirect_url }} - -

-

(preview mode)

-
-
-