virgo 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +37 -0
- data/app/assets/javascripts/tinymce/manifest.coffee +1 -0
- data/app/assets/javascripts/tinymce/plugins/image_manager/plugin.coffee +234 -0
- data/app/assets/javascripts/virgo/admin/page_modules/edit_form.coffee +4 -0
- data/app/assets/javascripts/virgo/admin/page_modules/edit_subject_form.coffee +29 -0
- data/app/assets/javascripts/virgo/admin/posts/edit_locking.coffee +35 -0
- data/app/assets/javascripts/virgo/admin/posts/form.coffee +183 -0
- data/app/assets/javascripts/virgo/admin/slides/form.coffee +27 -0
- data/app/assets/javascripts/virgo/admin/slideshows/form.coffee +26 -0
- data/app/assets/javascripts/virgo/admin_only.coffee +1 -0
- data/app/assets/javascripts/virgo/application.coffee +51 -0
- data/app/assets/javascripts/virgo/common.coffee +83 -0
- data/app/assets/javascripts/virgo/common/character_counter.coffee +27 -0
- data/app/assets/javascripts/virgo/components/header.coffee +47 -0
- data/app/assets/javascripts/virgo/components/media_modal.coffee +151 -0
- data/app/assets/javascripts/virgo/components/share_bar.coffee +53 -0
- data/app/assets/javascripts/virgo/components/slideshow.coffee +35 -0
- data/app/assets/javascripts/virgo/lib/jquery-ui-multiselect.js +342 -0
- data/app/assets/javascripts/virgo/lib/jquery.browser.js +184 -0
- data/app/assets/javascripts/virgo/lib/jquery.cookie.js +114 -0
- data/app/assets/javascripts/virgo/lib/jquery.pjax.js +932 -0
- data/app/assets/javascripts/virgo/lib/jquery_ext.coffee +0 -0
- data/app/assets/javascripts/virgo/lib/manifest.coffee +5 -0
- data/app/assets/javascripts/virgo/lib/ouibounce.js +194 -0
- data/app/assets/javascripts/virgo/page_modules.coffee +175 -0
- data/app/assets/javascripts/virgo/posts/show.coffee +32 -0
- data/app/assets/stylesheets/tinymce/skin.sass +2 -0
- data/app/assets/stylesheets/tinymce/skins/railspress/content.min.sass +82 -0
- data/app/assets/stylesheets/tinymce/skins/railspress/fonts/tinymce-small.eot +0 -0
- data/app/assets/stylesheets/tinymce/skins/railspress/fonts/tinymce-small.svg +62 -0
- data/app/assets/stylesheets/tinymce/skins/railspress/fonts/tinymce-small.ttf +0 -0
- data/app/assets/stylesheets/tinymce/skins/railspress/fonts/tinymce-small.woff +0 -0
- data/app/assets/stylesheets/tinymce/skins/railspress/fonts/tinymce.eot +0 -0
- data/app/assets/stylesheets/tinymce/skins/railspress/fonts/tinymce.svg +63 -0
- data/app/assets/stylesheets/tinymce/skins/railspress/fonts/tinymce.ttf +0 -0
- data/app/assets/stylesheets/tinymce/skins/railspress/fonts/tinymce.woff +0 -0
- data/app/assets/stylesheets/tinymce/skins/railspress/img/anchor.gif +0 -0
- data/app/assets/stylesheets/tinymce/skins/railspress/img/loader.gif +0 -0
- data/app/assets/stylesheets/tinymce/skins/railspress/img/object.gif +0 -0
- data/app/assets/stylesheets/tinymce/skins/railspress/img/trans.gif +0 -0
- data/app/assets/stylesheets/tinymce/skins/railspress/skin.min.sass +1703 -0
- data/app/assets/stylesheets/virgo/_common.sass +65 -0
- data/app/assets/stylesheets/virgo/admin.sass +301 -0
- data/app/assets/stylesheets/virgo/admin/columns.sass +3 -0
- data/app/assets/stylesheets/virgo/admin/images.sass +14 -0
- data/app/assets/stylesheets/virgo/admin/media_modal.sass +72 -0
- data/app/assets/stylesheets/virgo/admin/post.sass +102 -0
- data/app/assets/stylesheets/virgo/admin/slideshow.sass +35 -0
- data/app/assets/stylesheets/virgo/admin/users.sass +2 -0
- data/app/assets/stylesheets/virgo/admin_only.sass +1 -0
- data/app/assets/stylesheets/virgo/application.sass +605 -0
- data/app/assets/stylesheets/virgo/columns.sass +51 -0
- data/app/assets/stylesheets/virgo/install.sass +15 -0
- data/app/assets/stylesheets/virgo/lib/bootstrap/bootstrap-imports.sass +9 -0
- data/app/assets/stylesheets/virgo/lib/bootstrap/bootstrap-overrides.sass +51 -0
- data/app/assets/stylesheets/virgo/lib/bootstrap/bootstrap-variables.sass +27 -0
- data/app/assets/stylesheets/virgo/lib/jquery-ui-multiselect.css +30 -0
- data/app/assets/stylesheets/virgo/lib/manifest.sass +3 -0
- data/app/assets/stylesheets/virgo/lib/ouibounce.css +222 -0
- data/app/assets/stylesheets/virgo/lib/select2-imports.sass +8 -0
- data/app/assets/stylesheets/virgo/page_modules.sass +54 -0
- data/app/assets/stylesheets/virgo/pages/authors.sass +30 -0
- data/app/assets/stylesheets/virgo/posts.sass +782 -0
- data/app/assets/stylesheets/virgo/search.sass +36 -0
- data/app/assets/stylesheets/virgo/ui.sass +434 -0
- data/app/assets/stylesheets/virgo/users.sass +9 -0
- data/app/controllers/virgo/admin/base_controller.rb +22 -0
- data/app/controllers/virgo/admin/categories_controller.rb +90 -0
- data/app/controllers/virgo/admin/columns_controller.rb +65 -0
- data/app/controllers/virgo/admin/images_controller.rb +89 -0
- data/app/controllers/virgo/admin/media_modal_controller.rb +101 -0
- data/app/controllers/virgo/admin/newsletters_controller.rb +37 -0
- data/app/controllers/virgo/admin/page_modules_controller.rb +62 -0
- data/app/controllers/virgo/admin/pages_controller.rb +6 -0
- data/app/controllers/virgo/admin/posts_controller.rb +173 -0
- data/app/controllers/virgo/admin/sites_controller.rb +31 -0
- data/app/controllers/virgo/admin/slides_controller.rb +71 -0
- data/app/controllers/virgo/admin/slideshows_controller.rb +66 -0
- data/app/controllers/virgo/admin/tags_controller.rb +98 -0
- data/app/controllers/virgo/admin/users/sessions_controller.rb +21 -0
- data/app/controllers/virgo/admin/users_controller.rb +84 -0
- data/app/controllers/virgo/application_controller.rb +151 -0
- data/app/controllers/virgo/categories_controller.rb +20 -0
- data/app/controllers/virgo/columns_controller.rb +24 -0
- data/app/controllers/virgo/images_controller.rb +9 -0
- data/app/controllers/virgo/install_controller.rb +46 -0
- data/app/controllers/virgo/page_modules_controller.rb +23 -0
- data/app/controllers/virgo/pages_controller.rb +29 -0
- data/app/controllers/virgo/posts_controller.rb +101 -0
- data/app/controllers/virgo/search_controller.rb +35 -0
- data/app/controllers/virgo/subscribers_controller.rb +54 -0
- data/app/controllers/virgo/tags_controller.rb +15 -0
- data/app/controllers/virgo/users/confirmations_controller.rb +18 -0
- data/app/controllers/virgo/users/passwords_controller.rb +31 -0
- data/app/controllers/virgo/users/registrations_controller.rb +41 -0
- data/app/controllers/virgo/users/sessions_controller.rb +32 -0
- data/app/controllers/virgo/users_controller.rb +15 -0
- data/app/helpers/virgo/admin/post_helper.rb +54 -0
- data/app/helpers/virgo/admin_helper.rb +15 -0
- data/app/helpers/virgo/application_helper.rb +124 -0
- data/app/helpers/virgo/hooks_helper.rb +30 -0
- data/app/helpers/virgo/page_modules_helper.rb +4 -0
- data/app/helpers/virgo/post_helper.rb +159 -0
- data/app/helpers/virgo/render_helper.rb +33 -0
- data/app/helpers/virgo/search_helper.rb +49 -0
- data/app/helpers/virgo/shortcode_helper.rb +7 -0
- data/app/helpers/virgo/text_helper.rb +12 -0
- data/app/helpers/virgo/video_helper.rb +34 -0
- data/app/models/concerns/virgo/common/slug_history.rb +36 -0
- data/app/models/concerns/virgo/common/uuid.rb +22 -0
- data/app/models/concerns/virgo/post/recommendations.rb +15 -0
- data/app/models/concerns/virgo/post/search.rb +100 -0
- data/app/models/concerns/virgo/user/search.rb +39 -0
- data/app/models/virgo/ability.rb +59 -0
- data/app/models/virgo/category.rb +44 -0
- data/app/models/virgo/column.rb +25 -0
- data/app/models/virgo/form_model.rb +19 -0
- data/app/models/virgo/image.rb +63 -0
- data/app/models/virgo/page_module.rb +42 -0
- data/app/models/virgo/page_module_post.rb +8 -0
- data/app/models/virgo/post.rb +391 -0
- data/app/models/virgo/post_category.rb +8 -0
- data/app/models/virgo/post_search.rb +7 -0
- data/app/models/virgo/post_tag.rb +10 -0
- data/app/models/virgo/site.rb +36 -0
- data/app/models/virgo/slide.rb +23 -0
- data/app/models/virgo/slideshow.rb +37 -0
- data/app/models/virgo/slug_history.rb +5 -0
- data/app/models/virgo/subscriber.rb +5 -0
- data/app/models/virgo/tag.rb +34 -0
- data/app/models/virgo/user.rb +145 -0
- data/app/uploaders/virgo/application_uploader.rb +11 -0
- data/app/uploaders/virgo/avatar_uploader.rb +21 -0
- data/app/uploaders/virgo/featured_image_uploader.rb +28 -0
- data/app/uploaders/virgo/image_uploader.rb +40 -0
- data/app/uploaders/virgo/slide_uploader.rb +19 -0
- data/app/views/layouts/virgo/admin.haml +16 -0
- data/app/views/layouts/virgo/admin/site_settings.haml +14 -0
- data/app/views/layouts/virgo/application.haml +63 -0
- data/app/views/layouts/virgo/errors.haml +42 -0
- data/app/views/layouts/virgo/main.haml +5 -0
- data/app/views/layouts/virgo/posts.haml +10 -0
- data/app/views/virgo/admin/categories/_form.haml +19 -0
- data/app/views/virgo/admin/categories/edit.haml +7 -0
- data/app/views/virgo/admin/categories/index.haml +38 -0
- data/app/views/virgo/admin/categories/modal_form.haml +11 -0
- data/app/views/virgo/admin/categories/new.haml +7 -0
- data/app/views/virgo/admin/categories/success_modal.haml +14 -0
- data/app/views/virgo/admin/columns/_form.haml +30 -0
- data/app/views/virgo/admin/columns/edit.haml +1 -0
- data/app/views/virgo/admin/columns/index.haml +30 -0
- data/app/views/virgo/admin/columns/new.haml +1 -0
- data/app/views/virgo/admin/images/_form.haml +46 -0
- data/app/views/virgo/admin/images/edit.haml +1 -0
- data/app/views/virgo/admin/images/index.haml +32 -0
- data/app/views/virgo/admin/images/new.haml +1 -0
- data/app/views/virgo/admin/media_modal/_image_settings.haml +17 -0
- data/app/views/virgo/admin/media_modal/_library_panel.haml +26 -0
- data/app/views/virgo/admin/media_modal/_upload_panel.haml +21 -0
- data/app/views/virgo/admin/media_modal/_upload_success.haml +7 -0
- data/app/views/virgo/admin/media_modal/index.haml +19 -0
- data/app/views/virgo/admin/newsletters/changelog.haml +25 -0
- data/app/views/virgo/admin/newsletters/edit.haml +6 -0
- data/app/views/virgo/admin/page_modules/edit.haml +33 -0
- data/app/views/virgo/admin/page_modules/edit_subject.haml +43 -0
- data/app/views/virgo/admin/pages/help.haml +114 -0
- data/app/views/virgo/admin/posts/_author_dropdown.haml +1 -0
- data/app/views/virgo/admin/posts/_categories_form.haml +7 -0
- data/app/views/virgo/admin/posts/_category.haml +22 -0
- data/app/views/virgo/admin/posts/_form.haml +201 -0
- data/app/views/virgo/admin/posts/_revisions.haml +40 -0
- data/app/views/virgo/admin/posts/edit.haml +9 -0
- data/app/views/virgo/admin/posts/index.haml +59 -0
- data/app/views/virgo/admin/posts/new.haml +1 -0
- data/app/views/virgo/admin/posts/revision_detail.haml +28 -0
- data/app/views/virgo/admin/posts/revisions.haml +3 -0
- data/app/views/virgo/admin/sites/edit.haml +12 -0
- data/app/views/virgo/admin/slides/_form.haml +41 -0
- data/app/views/virgo/admin/slides/edit.haml +1 -0
- data/app/views/virgo/admin/slides/new.haml +1 -0
- data/app/views/virgo/admin/slideshows/_form.haml +49 -0
- data/app/views/virgo/admin/slideshows/edit.haml +1 -0
- data/app/views/virgo/admin/slideshows/index.haml +43 -0
- data/app/views/virgo/admin/slideshows/new.haml +1 -0
- data/app/views/virgo/admin/tags/_form.haml +16 -0
- data/app/views/virgo/admin/tags/edit.haml +7 -0
- data/app/views/virgo/admin/tags/index.haml +33 -0
- data/app/views/virgo/admin/tags/modal_form.haml +12 -0
- data/app/views/virgo/admin/tags/new.haml +7 -0
- data/app/views/virgo/admin/tags/success_modal.haml +14 -0
- data/app/views/virgo/admin/users/_form.haml +62 -0
- data/app/views/virgo/admin/users/edit.haml +1 -0
- data/app/views/virgo/admin/users/index.haml +34 -0
- data/app/views/virgo/admin/users/new.haml +1 -0
- data/app/views/virgo/application/sitemap.xml.builder +0 -0
- data/app/views/virgo/authors/_profile_long.haml +13 -0
- data/app/views/virgo/authors/_profile_short.haml +10 -0
- data/app/views/virgo/categories/show.haml +24 -0
- data/app/views/virgo/columns/index.haml +19 -0
- data/app/views/virgo/columns/show.haml +18 -0
- data/app/views/virgo/common/_admin_navbar.haml +100 -0
- data/app/views/virgo/common/_alerts.haml +40 -0
- data/app/views/virgo/common/_analytics.html.erb +1 -0
- data/app/views/virgo/common/_base_errors.haml +8 -0
- data/app/views/virgo/common/_category_heading.haml +26 -0
- data/app/views/virgo/common/_disqus.html.erb +24 -0
- data/app/views/virgo/common/_disqus_comment_count.html.erb +12 -0
- data/app/views/virgo/common/_fb_api.html.erb +30 -0
- data/app/views/virgo/common/_fonts.html.erb +1 -0
- data/app/views/virgo/common/_footer.haml +13 -0
- data/app/views/virgo/common/_footer_javascript.html.erb +0 -0
- data/app/views/virgo/common/_header_analytics.html.erb +9 -0
- data/app/views/virgo/common/_list_signup.haml +20 -0
- data/app/views/virgo/common/_ouibounce_modal.haml +26 -0
- data/app/views/virgo/common/_public_nav.haml +58 -0
- data/app/views/virgo/common/_search_form.haml +8 -0
- data/app/views/virgo/common/_share_bar.haml +45 -0
- data/app/views/virgo/common/_user_vars.haml +2 -0
- data/app/views/virgo/errors/404.haml +10 -0
- data/app/views/virgo/errors/500.haml +10 -0
- data/app/views/virgo/images/_shortcode.haml +4 -0
- data/app/views/virgo/install/index.haml +58 -0
- data/app/views/virgo/install/success.haml +12 -0
- data/app/views/virgo/page_modules/_latest_posts.haml +29 -0
- data/app/views/virgo/page_modules/_popular_posts.haml +51 -0
- data/app/views/virgo/pages/authors.haml +8 -0
- data/app/views/virgo/pages/home.haml +0 -0
- data/app/views/virgo/pages/show.haml +6 -0
- data/app/views/virgo/posts/_author_info.haml +16 -0
- data/app/views/virgo/posts/_post_full.haml +63 -0
- data/app/views/virgo/posts/_post_short.haml +30 -0
- data/app/views/virgo/posts/_post_thumb_box.haml +13 -0
- data/app/views/virgo/posts/_recommendations.haml +12 -0
- data/app/views/virgo/posts/_sidebar_thumb.haml +4 -0
- data/app/views/virgo/posts/index.haml +22 -0
- data/app/views/virgo/posts/latest.haml +16 -0
- data/app/views/virgo/posts/more.haml +10 -0
- data/app/views/virgo/posts/rss.xml.builder +17 -0
- data/app/views/virgo/posts/show.haml +17 -0
- data/app/views/virgo/search/_form.haml +5 -0
- data/app/views/virgo/search/_item.haml +22 -0
- data/app/views/virgo/search/index.haml +11 -0
- data/app/views/virgo/search/new.haml +4 -0
- data/app/views/virgo/shortcode_templates/blockquote.haml +9 -0
- data/app/views/virgo/shortcode_templates/h1.haml +1 -0
- data/app/views/virgo/shortcode_templates/h2.haml +1 -0
- data/app/views/virgo/shortcode_templates/h3.haml +1 -0
- data/app/views/virgo/shortcode_templates/h4.haml +1 -0
- data/app/views/virgo/shortcode_templates/image.haml +17 -0
- data/app/views/virgo/shortcode_templates/pullquote.haml +3 -0
- data/app/views/virgo/shortcode_templates/slideshow.haml +35 -0
- data/app/views/virgo/shortcode_templates/tweet.haml +3 -0
- data/app/views/virgo/shortcode_templates/video.haml +8 -0
- data/app/views/virgo/subscribers/_success_modal.haml +13 -0
- data/app/views/virgo/subscribers/modal.haml +15 -0
- data/app/views/virgo/tags/show.haml +16 -0
- data/app/views/virgo/users/confirmations/new.html.haml +10 -0
- data/app/views/virgo/users/devise_mailer/confirmation_instructions.html.erb +7 -0
- data/app/views/virgo/users/devise_mailer/reset_password_instructions.html.haml +6 -0
- data/app/views/virgo/users/devise_mailer/unlock_instructions.html.haml +5 -0
- data/app/views/virgo/users/passwords/edit.html.haml +14 -0
- data/app/views/virgo/users/passwords/new.html.haml +14 -0
- data/app/views/virgo/users/registrations/edit.html.haml +30 -0
- data/app/views/virgo/users/registrations/new.html.haml +13 -0
- data/app/views/virgo/users/sessions/new.html.haml +12 -0
- data/app/views/virgo/users/shared/_links.haml +26 -0
- data/app/views/virgo/users/show.haml +11 -0
- data/app/views/virgo/users/unlocks/new.html.haml +9 -0
- data/config/initializers/action_mailer.rb +7 -0
- data/config/initializers/active_record.rb +72 -0
- data/config/initializers/active_record_symbolize.rb +18 -0
- data/config/initializers/assets.rb +17 -0
- data/config/initializers/backtrace_silencers.rb +7 -0
- data/config/initializers/carrierwave.rb +36 -0
- data/config/initializers/cookies_serializer.rb +3 -0
- data/config/initializers/devise.rb +257 -0
- data/config/initializers/filter_parameter_logging.rb +4 -0
- data/config/initializers/hash.rb +5 -0
- data/config/initializers/inflections.rb +16 -0
- data/config/initializers/mime_types.rb +4 -0
- data/config/initializers/nil_class.rb +13 -0
- data/config/initializers/non_digest_assets.rb +3 -0
- data/config/initializers/paper_trail.rb +30 -0
- data/config/initializers/schema_plus.rb +5 -0
- data/config/initializers/session_store.rb +3 -0
- data/config/initializers/shortcode.rb +12 -0
- data/config/initializers/simple_form.rb +170 -0
- data/config/initializers/simple_form_bootstrap.rb +136 -0
- data/config/initializers/string.rb +5 -0
- data/config/initializers/time_formatting.rb +23 -0
- data/config/initializers/wrap_parameters.rb +14 -0
- data/config/locales/devise.en.yml +60 -0
- data/config/routes.rb +96 -0
- data/config/schedule.rb +3 -0
- data/db/migrate/20150729174510_create_virgo_schema.rb +225 -0
- data/lib/generators/virgo/install/install_generator.rb +16 -0
- data/lib/generators/virgo/views/views_generator.rb +22 -0
- data/lib/tasks/virgo_tasks.rake +7 -0
- data/lib/virgo.rb +4 -0
- data/lib/virgo/development_mail_interceptor.rb +6 -0
- data/lib/virgo/email_validator.rb +6 -0
- data/lib/virgo/engine.rb +73 -0
- data/lib/virgo/reduce_validator.rb +6 -0
- data/lib/virgo/upload_helpers.rb +89 -0
- data/lib/virgo/version.rb +3 -0
- data/lib/virgo/view_help.rb +3 -0
- metadata +1051 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Virgo
|
|
2
|
+
class Admin::Users::SessionsController < Admin::BaseController
|
|
3
|
+
include Devise::Controllers::Helpers
|
|
4
|
+
|
|
5
|
+
before_filter :find_user, only: [:create]
|
|
6
|
+
|
|
7
|
+
def create
|
|
8
|
+
sign_out(current_user)
|
|
9
|
+
|
|
10
|
+
sign_in(@user)
|
|
11
|
+
|
|
12
|
+
redirect_to root_path, flash: {notice: "You have been logged in as #{@user.email}"}
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
def find_user
|
|
18
|
+
@user = User.friendly.find(params[:user_id])
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
module Virgo
|
|
2
|
+
class Admin::UsersController < Admin::BaseController
|
|
3
|
+
before_action :set_user, only: member_actions
|
|
4
|
+
|
|
5
|
+
handles_sortable_columns
|
|
6
|
+
|
|
7
|
+
helper_method :filter_params
|
|
8
|
+
|
|
9
|
+
def index
|
|
10
|
+
authorize! :index, User
|
|
11
|
+
@users = User.search(filter_params).with_post_count.order(sort_order).page(page_param)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def new
|
|
15
|
+
@user = User.new
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def create
|
|
19
|
+
@user = User.new(user_params)
|
|
20
|
+
|
|
21
|
+
if @user.save
|
|
22
|
+
flash[:notice] = "Account created successfully"
|
|
23
|
+
redirect_to admin_users_path
|
|
24
|
+
else
|
|
25
|
+
render :new
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def edit
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def update
|
|
33
|
+
_is_user = current_user == @user
|
|
34
|
+
|
|
35
|
+
if @user.update(user_params)
|
|
36
|
+
flash[:notice] = "Profile updated successfully"
|
|
37
|
+
redirect_to edit_admin_user_path(@user)
|
|
38
|
+
|
|
39
|
+
# required to keep user signed in (thanks to oddball default
|
|
40
|
+
# devise policy of signing out a user who updates pw)
|
|
41
|
+
sign_in @user, bypass: true if _is_user
|
|
42
|
+
else
|
|
43
|
+
render :edit
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def destroy
|
|
48
|
+
@user.destroy
|
|
49
|
+
|
|
50
|
+
flash[:notice] = "User successfully deleted"
|
|
51
|
+
|
|
52
|
+
redirect_to admin_users_path
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
private
|
|
56
|
+
|
|
57
|
+
def set_user
|
|
58
|
+
@user = User.friendly.find(id_param)
|
|
59
|
+
authorize! :manage, @user
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def user_params
|
|
63
|
+
params.permit(user: [:first_name, :last_name, :byline, :email, :role, :username, :about, :avatar])[:user]
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def user_params
|
|
67
|
+
if params[:user].try(:[], :password).blank?
|
|
68
|
+
params[:user].delete(:password)
|
|
69
|
+
params[:user].delete(:password_confirmation)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
params.permit(user: [:first_name, :last_name, :byline,
|
|
73
|
+
:show_on_authors_page, :author_page_weight,
|
|
74
|
+
:email, :role, :username, :about, :avatar,
|
|
75
|
+
:password, :password_confirmation,
|
|
76
|
+
:facebook_id, :twitter_id, :instagram_id,
|
|
77
|
+
:snapchat_id, :linkedin_id, :public_email])[:user]
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def filter_params
|
|
81
|
+
params.permit(filters: [:term])[:filters]
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
module Virgo
|
|
2
|
+
class ApplicationController < ActionController::Base
|
|
3
|
+
include Virgo::RenderHelper, Virgo::ApplicationHelper, ActionView::Helpers::SanitizeHelper, ActionView::Helpers::TextHelper
|
|
4
|
+
|
|
5
|
+
layout 'virgo/main'
|
|
6
|
+
|
|
7
|
+
protect_from_forgery with: :exception
|
|
8
|
+
|
|
9
|
+
before_action :init
|
|
10
|
+
|
|
11
|
+
before_action :configure_permitted_parameters, if: :devise_controller?
|
|
12
|
+
|
|
13
|
+
before_action :set_client_id
|
|
14
|
+
|
|
15
|
+
helper_method :render_to_string, :sort_param, :page_param, :just_confirmed?, :deploy_key, :id_param, :popular_posts_page_param, :filter_params
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
if Rails.env.production? || Rails.env.test?
|
|
19
|
+
rescue_from Exception, with: :render_500
|
|
20
|
+
rescue_from ActiveRecord::RecordNotFound, with: :render_404
|
|
21
|
+
rescue_from CanCan::AccessDenied, with: :render_404
|
|
22
|
+
rescue_from ActionController::RoutingError, with: :render_404
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def sitemap
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
protected
|
|
29
|
+
|
|
30
|
+
def configure_permitted_parameters
|
|
31
|
+
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:username, :email, :password, :password_confirmation, :remember_me) }
|
|
32
|
+
devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:login, :username, :email, :password, :remember_me) }
|
|
33
|
+
devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:username, :email, :password, :password_confirmation, :current_password) }
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def default_url_options
|
|
37
|
+
{:host => Rails.application.config.domain}
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
def self.member_actions(*extras)
|
|
43
|
+
[:show, :edit, :update, :destroy] + extras
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def self.collection_actions(*extras)
|
|
47
|
+
[:index, :new, :create] + extras
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def page_param
|
|
51
|
+
params.permit(:page)[:page]
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def sort_param
|
|
55
|
+
params.permit(:sort)[:sort]
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def id_param
|
|
59
|
+
params.permit(:id)[:id]
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def self.default_sort_order(val)
|
|
63
|
+
@_default_sort_order = val
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def sort_order
|
|
67
|
+
order = sortable_column_order do |column, direction|
|
|
68
|
+
# make the sort on these select string columns case-insensitive w/ LOWER function
|
|
69
|
+
if column && column.in?(['name', 'headline'])
|
|
70
|
+
"LOWER(#{column}) #{direction}"
|
|
71
|
+
elsif column
|
|
72
|
+
"#{column} #{direction}"
|
|
73
|
+
else
|
|
74
|
+
@_default_sort_order || "updated_at DESC"
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def set_calendar
|
|
80
|
+
@calendar = Calendar.friendly.find(params[:id] || params[:calendar_id])
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def just_confirmed_param
|
|
84
|
+
params.permit(:just_confirmed)[:just_confirmed]
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def just_confirmed?
|
|
88
|
+
just_confirmed_param && (just_confirmed_param.in?([true, 'true']))
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def render_500(exception)
|
|
92
|
+
logger.error exception.backtrace.join("\n")
|
|
93
|
+
notify_exception(request.env, exception)
|
|
94
|
+
render "virgo/errors/500", layout: "virgo/errors", status: 500
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def render_404
|
|
98
|
+
if request.format.json? || request.format.js?
|
|
99
|
+
render(json: {status: "Not found"}, status: 404)
|
|
100
|
+
else
|
|
101
|
+
render "virgo/errors/404", layout: "virgo/errors", status: 404
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def notify_exception(env, exception)
|
|
106
|
+
if ['production', 'staging'].include?(Rails.env)
|
|
107
|
+
env["airbrake.error_id"] = notify_airbrake(exception)
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def self.deploy_key
|
|
112
|
+
Rails.application.config.deploy_key
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def deploy_key
|
|
116
|
+
self.class.deploy_key
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def after_sign_out_path_for(resource_or_scope)
|
|
120
|
+
virgo.new_user_session_path
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def set_client_id
|
|
124
|
+
cookies[:client_id] ||= SecureRandom.hex(14)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def client_id
|
|
128
|
+
cookies[:client_id]
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def filter_params
|
|
132
|
+
params.permit(filters: [:term])[:filters]
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def popular_posts_page_param
|
|
136
|
+
params.permit(:popular_posts_page)[:popular_posts_page]
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def init
|
|
140
|
+
@_large_nav = false
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def enable_large_nav
|
|
144
|
+
@_large_nav = true
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def current_ability
|
|
148
|
+
@current_ability ||= ::Virgo::Ability.new(current_user)
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Virgo
|
|
2
|
+
class CategoriesController < ApplicationController
|
|
3
|
+
caches_action :show, if: ->{ current_user.nil? && flash.empty? },
|
|
4
|
+
cache_path: ->(o){ "#{deploy_key}/#{site_key}/categories/show/#{params[:id]}/#{category_timestamp(params[:id])}/#{params[:page]}" }
|
|
5
|
+
|
|
6
|
+
def show
|
|
7
|
+
set_category
|
|
8
|
+
|
|
9
|
+
@posts = @category.posts.order(publish_at: :desc).page(page_param)
|
|
10
|
+
|
|
11
|
+
render layout: 'virgo/posts'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
def set_category
|
|
17
|
+
@category = Category.friendly.find(id_param)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Virgo
|
|
2
|
+
class ColumnsController < ApplicationController
|
|
3
|
+
caches_action :show, if: ->{ current_user.nil? && flash.empty? },
|
|
4
|
+
cache_path: ->(o){ "#{deploy_key}/#{site_key}/columns/show/#{params[:id]}/#{column_timestamp(params[:id])}/#{params[:page]}" }
|
|
5
|
+
|
|
6
|
+
before_action :set_column, only: [:show]
|
|
7
|
+
|
|
8
|
+
def index
|
|
9
|
+
@columns = Column.by_weight
|
|
10
|
+
|
|
11
|
+
render layout: 'virgo/posts'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def show
|
|
15
|
+
@posts = @column.posts.latest.page(page_param)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def set_column
|
|
21
|
+
@column = Column.friendly.find(id_param)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
module Virgo
|
|
2
|
+
class InstallController < ApplicationController
|
|
3
|
+
before_action :deny_if_accounts_exist, except: :success
|
|
4
|
+
|
|
5
|
+
helper_method :site_params, :user_params
|
|
6
|
+
|
|
7
|
+
def index
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def create
|
|
11
|
+
@user = User.new(user_params.merge(role: :admin))
|
|
12
|
+
@site = Site.instance
|
|
13
|
+
|
|
14
|
+
@site.attributes = site_params
|
|
15
|
+
|
|
16
|
+
if @site.valid? && @user.valid?
|
|
17
|
+
@site.save!
|
|
18
|
+
@user.save!
|
|
19
|
+
@site.generate_dummy_data!
|
|
20
|
+
redirect_to success_install_index_path
|
|
21
|
+
else
|
|
22
|
+
render :index
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def success
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def deny_if_accounts_exist
|
|
32
|
+
if User.where(role: :admin).any?
|
|
33
|
+
flash[:notice] = "An admin account already exists for this site"
|
|
34
|
+
redirect_to(root_path) and return
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def user_params
|
|
39
|
+
params.permit(user: [:username, :byline, :email, :password, :password_confirmation])[:user]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def site_params
|
|
43
|
+
params.permit(site: [:name, :tagline, :disqus_app_id])[:site]
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Virgo
|
|
2
|
+
class PageModulesController < ApplicationController
|
|
3
|
+
caches_action :popular_posts,
|
|
4
|
+
expires_in: 3.minutes,
|
|
5
|
+
cache_path: ->(o){ "#{deploy_key}/#{site_key}/page_modules/popular_posts/#{params[:category_id]}/#{params[:page]}" }
|
|
6
|
+
|
|
7
|
+
def popular_posts
|
|
8
|
+
@category = Category.friendly.find(category_id_param) if category_id_param.present?
|
|
9
|
+
@tabbed = @category.present? ? true : false
|
|
10
|
+
@tab = @category.present? ? :category : :all
|
|
11
|
+
|
|
12
|
+
render json: {
|
|
13
|
+
html: render_content(partial: '/virgo/page_modules/popular_posts', locals: {category: @category, tab: @tab, tabbed: @tabbed})
|
|
14
|
+
}
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def category_id_param
|
|
20
|
+
params.permit(:category_id)[:category_id]
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Virgo
|
|
2
|
+
class PagesController < ApplicationController
|
|
3
|
+
before_action :set_page, only: :show
|
|
4
|
+
|
|
5
|
+
def show
|
|
6
|
+
render layout: 'virgo/application'
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def home
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def authors
|
|
13
|
+
@authors = User.where(show_on_authors_page: true).order(author_page_weight: :asc)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def help
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def set_page
|
|
22
|
+
@page = Post.pages.friendly.find(slug_param)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def slug_param
|
|
26
|
+
params.permit(:slug)[:slug]
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
module Virgo
|
|
2
|
+
class PostsController < ApplicationController
|
|
3
|
+
before_action :enable_large_nav, only: [:index]
|
|
4
|
+
|
|
5
|
+
if Rails.application.config.caching == :aggressive
|
|
6
|
+
caches_action :show, if: ->{ current_user.nil? && flash.empty? },
|
|
7
|
+
cache_path: ->(o){ "#{deploy_key}/#{site_key}/posts/#{category_id_param}/#{params[:id]}/#{post_timestamp(params[:id])}" }
|
|
8
|
+
|
|
9
|
+
caches_action :index, if: ->{ current_user.nil? && flash.empty? },
|
|
10
|
+
cache_path: ->(o){ "#{deploy_key}/#{site_key}/posts/index/#{params[:page]}" }
|
|
11
|
+
|
|
12
|
+
caches_action :latest, if: ->{ current_user.nil? && flash.empty? },
|
|
13
|
+
cache_path: ->(o){ "#{deploy_key}/#{site_key}/posts/latest/#{params[:page]}" }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def index
|
|
17
|
+
@posts = Post.posts.publicly_viewable.order(publish_at: :desc).page(page_param)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def more
|
|
21
|
+
@posts = Post.order(publish_at: :desc).page(page_param).per(6).padding(6)
|
|
22
|
+
render json: {
|
|
23
|
+
html: render_content('/virgo/posts/more', layout: false)
|
|
24
|
+
}
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def latest
|
|
28
|
+
@posts = Post.posts.publicly_viewable.order(publish_at: :desc).page(page_param)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def show
|
|
32
|
+
# call this in the action so it doesn't run before the action cache wrapper
|
|
33
|
+
set_post
|
|
34
|
+
|
|
35
|
+
if old_path?
|
|
36
|
+
redirect_to(post_detail_path(@post), status: :moved_permanently) and return
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
if @post.page?
|
|
40
|
+
@page = @post
|
|
41
|
+
render "/virgo/pages/show", layout: "virgo/application"
|
|
42
|
+
else
|
|
43
|
+
render layout: '/virgo/posts'
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def popular
|
|
48
|
+
render json: {html: render_content(partial: "/virgo/page_modules/popular_posts")}
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def rss
|
|
52
|
+
@limit = Rails.env.production? ? 50 : 5
|
|
53
|
+
|
|
54
|
+
render 'rss.xml', layout: false, content_type: Mime::XML
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def track
|
|
58
|
+
# note: we keep a transient/compact hash record of recent tracks in a hash
|
|
59
|
+
# in memcached to prevent abuse of this endpoint (i.e. the same user
|
|
60
|
+
# can't slam this endpoint w/ js ajax requests to artificially pump up a story)
|
|
61
|
+
tracked = JSON::load(Rails.cache.fetch("tracks[#{client_id}]") || '{}')
|
|
62
|
+
|
|
63
|
+
unless tracked[id_param]
|
|
64
|
+
set_post
|
|
65
|
+
@post.track_view!
|
|
66
|
+
tracked[@post.id.to_s] = 1
|
|
67
|
+
Rails.cache.write("tracks[#{client_id}]", JSON::dump(tracked))
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
head :ok
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
private
|
|
74
|
+
|
|
75
|
+
def set_post
|
|
76
|
+
# there have been instances where url shorteners append querystring
|
|
77
|
+
# params w/ a leading "&" instead of w/ a leading "?"
|
|
78
|
+
# (assuming there are alread querystring params on the
|
|
79
|
+
# article url I guess) - adding a catch for this here.
|
|
80
|
+
post_id = id_param
|
|
81
|
+
|
|
82
|
+
post_id = (post_id.present? && post_id.include?("&")) ? post_id.slice(0..(post_id.index('&') - 1)) : post_id
|
|
83
|
+
|
|
84
|
+
@post = Post.find_by_id_or_historic_slug!(post_id)
|
|
85
|
+
|
|
86
|
+
if category_id_param.present?
|
|
87
|
+
@category = Category.friendly.find(category_id_param)
|
|
88
|
+
else
|
|
89
|
+
@category = @post.primary_category
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
authorize! :read, @post
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def old_path?
|
|
96
|
+
if @post && id_param != @post.slug && id_param.to_i != @post.id
|
|
97
|
+
true
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|