Code cleanups (#659)
* Initial automatic cleanup with rubocop * Fix syntax error introduced by rubocop * Cleanup seeds file * Cleanup lib folder * Exclude bin folder because it contains auto generated files * Make Rubocop a little bit more chatty * Block length should not include comments in the count * Cleanup config folder * Cleanup specs * Updated Rubocop version and generated a todo file * Fix broken ArticlesApi spec * Fix tests * Restored rubocop pre-commit hook
This commit is contained in:
parent
2cae371044
commit
e588fa7ece
321 changed files with 2850 additions and 2389 deletions
10
.rubocop.yml
10
.rubocop.yml
|
|
@ -1,3 +1,5 @@
|
|||
inherit_from: .rubocop_todo.yml
|
||||
|
||||
require: rubocop-rspec
|
||||
|
||||
# our custom config
|
||||
|
|
@ -19,7 +21,13 @@ Metrics/LineLength:
|
|||
|
||||
AllCops:
|
||||
Exclude:
|
||||
- bin/**/*
|
||||
- db/schema.rb
|
||||
- db/migrate/*.rb
|
||||
- node_modules/**/*
|
||||
DisplayStyleGuide: true
|
||||
ExtraDetails: true
|
||||
TargetRubyVersion: 2.5
|
||||
|
||||
Naming/AccessorMethodName:
|
||||
Description: Check the naming of accessor methods for get_/set_.
|
||||
|
|
@ -110,7 +118,7 @@ Metrics/AbcSize:
|
|||
Enabled: false
|
||||
|
||||
Metrics/BlockLength:
|
||||
CountComments: true # count full line comments?
|
||||
CountComments: false # count full line comments?
|
||||
Max: 25
|
||||
ExcludedMethods: []
|
||||
Exclude:
|
||||
|
|
|
|||
200
.rubocop_todo.yml
Normal file
200
.rubocop_todo.yml
Normal file
|
|
@ -0,0 +1,200 @@
|
|||
# This configuration was generated by
|
||||
# `rubocop --auto-gen-config`
|
||||
# on 2018-08-05 17:42:25 +0200 using RuboCop version 0.58.2.
|
||||
# The point is for the user to remove these configuration records
|
||||
# one by one as the offenses are removed from the code base.
|
||||
# Note that changes in the inspected code, or installation of new
|
||||
# versions of RuboCop, may require this file to be generated again.
|
||||
|
||||
# Offense count: 9
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity.
|
||||
# SupportedStylesAlignWith: keyword, variable, start_of_line
|
||||
Layout/EndAlignment:
|
||||
Exclude:
|
||||
- 'app/controllers/api/v0/articles_controller.rb'
|
||||
- 'app/controllers/articles_controller.rb'
|
||||
- 'app/controllers/chat_channels_controller.rb'
|
||||
- 'app/controllers/image_uploads_controller.rb'
|
||||
- 'app/helpers/application_helper.rb'
|
||||
- 'app/models/user.rb'
|
||||
- 'app/services/article_api_index_service.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets.
|
||||
# SupportedStyles: space, no_space, compact
|
||||
# SupportedStylesForEmptyBrackets: space, no_space
|
||||
Layout/SpaceInsideArrayLiteralBrackets:
|
||||
Exclude:
|
||||
- 'app/dashboards/email_message_dashboard.rb'
|
||||
|
||||
# Offense count: 3
|
||||
Lint/AmbiguousBlockAssociation:
|
||||
Exclude:
|
||||
- 'app/controllers/podcast_episodes_controller.rb'
|
||||
- 'app/views/api/v0/articles/show.json.jbuilder'
|
||||
|
||||
# Offense count: 4
|
||||
Lint/IneffectiveAccessModifier:
|
||||
Exclude:
|
||||
- 'app/black_box/black_box.rb'
|
||||
- 'app/models/tweet.rb'
|
||||
|
||||
# Offense count: 3
|
||||
Lint/ShadowingOuterLocalVariable:
|
||||
Exclude:
|
||||
- 'app/views/api/v0/comments/index.json.jbuilder'
|
||||
- 'app/views/api/v0/comments/show.json.jbuilder'
|
||||
|
||||
# Offense count: 2
|
||||
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
|
||||
Lint/UselessAccessModifier:
|
||||
Exclude:
|
||||
- 'app/black_box/black_box.rb'
|
||||
- 'app/models/tweet.rb'
|
||||
|
||||
# Offense count: 10
|
||||
Lint/UselessAssignment:
|
||||
Exclude:
|
||||
- 'app/controllers/stories_controller.rb'
|
||||
- 'app/labor/cache_buster.rb'
|
||||
- 'app/labor/markdown_parser.rb'
|
||||
- 'app/labor/rate_limit_checker.rb'
|
||||
- 'app/liquid_tags/comment_tag.rb'
|
||||
- 'app/liquid_tags/glitch_tag.rb'
|
||||
- 'app/liquid_tags/tweet_tag.rb'
|
||||
|
||||
# Offense count: 8
|
||||
# Configuration parameters: CountComments, ExcludedMethods.
|
||||
# ExcludedMethods: refine
|
||||
Metrics/BlockLength:
|
||||
Max: 68
|
||||
|
||||
# Offense count: 132
|
||||
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
||||
# URISchemes: http, https
|
||||
Metrics/LineLength:
|
||||
Max: 274
|
||||
|
||||
# Offense count: 14
|
||||
Metrics/PerceivedComplexity:
|
||||
Max: 16
|
||||
|
||||
# Offense count: 1
|
||||
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
|
||||
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
|
||||
Naming/MemoizedInstanceVariableName:
|
||||
Exclude:
|
||||
- 'app/controllers/admin/application_controller.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: snake_case, camelCase
|
||||
Naming/MethodName:
|
||||
Exclude:
|
||||
- 'app/helpers/articles_helper.rb'
|
||||
- 'app/liquid_tags/podcast_tag.rb'
|
||||
|
||||
# Offense count: 4
|
||||
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist, MethodDefinitionMacros.
|
||||
# NamePrefix: is_, has_, have_
|
||||
# NamePrefixBlacklist: is_, has_, have_
|
||||
# NameWhitelist: is_a?
|
||||
# MethodDefinitionMacros: define_method, define_singleton_method
|
||||
Naming/PredicateName:
|
||||
Exclude:
|
||||
- 'spec/**/*'
|
||||
- 'app/controllers/application_controller.rb'
|
||||
- 'app/helpers/articles_helper.rb'
|
||||
- 'app/models/user.rb'
|
||||
|
||||
# Offense count: 9
|
||||
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
||||
# AllowedNames: io, id, to, by, on, in, at, ip
|
||||
Naming/UncommunicativeMethodParamName:
|
||||
Exclude:
|
||||
- 'app/controllers/followed_articles_controller.rb'
|
||||
- 'app/controllers/internal/dogfood_controller.rb'
|
||||
- 'app/labor/mailchimp_bot.rb'
|
||||
- 'app/labor/podcast_feed.rb'
|
||||
- 'app/models/chat_channel.rb'
|
||||
- 'app/models/tweet.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: snake_case, camelCase
|
||||
Naming/VariableName:
|
||||
Exclude:
|
||||
- 'app/liquid_tags/github_tag/github_issue_tag.rb'
|
||||
|
||||
# Offense count: 3
|
||||
Security/Open:
|
||||
Exclude:
|
||||
- 'app/labor/podcast_feed.rb'
|
||||
- 'app/labor/rss_reader.rb'
|
||||
|
||||
# Offense count: 14
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: AutoCorrect, EnforcedStyle.
|
||||
# SupportedStyles: nested, compact
|
||||
Style/ClassAndModuleChildren:
|
||||
Exclude:
|
||||
- 'app/controllers/api/v0/api_controller.rb'
|
||||
- 'app/controllers/internal/application_controller.rb'
|
||||
- 'app/controllers/internal/articles_controller.rb'
|
||||
- 'app/controllers/internal/broadcasts_controller.rb'
|
||||
- 'app/controllers/internal/buffer_updates_controller.rb'
|
||||
- 'app/controllers/internal/comments_controller.rb'
|
||||
- 'app/controllers/internal/dogfood_controller.rb'
|
||||
- 'app/controllers/internal/feedback_messages_controller.rb'
|
||||
- 'app/controllers/internal/members_controller.rb'
|
||||
- 'app/controllers/internal/tags_controller.rb'
|
||||
- 'app/controllers/internal/users_controller.rb'
|
||||
- 'app/controllers/internal/welcome_controller.rb'
|
||||
- 'app/controllers/notifications/counts_controller.rb'
|
||||
- 'app/controllers/notifications/reads_controller.rb'
|
||||
|
||||
# Offense count: 1
|
||||
Style/DateTime:
|
||||
Exclude:
|
||||
- 'app/controllers/comments_controller.rb'
|
||||
|
||||
# Offense count: 1
|
||||
Style/EvalWithLocation:
|
||||
Exclude:
|
||||
- 'app/controllers/omniauth_callbacks_controller.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: each, for
|
||||
Style/For:
|
||||
Exclude:
|
||||
- 'app/views/articles/feed.rss.builder'
|
||||
|
||||
# Offense count: 1
|
||||
Style/IfInsideElse:
|
||||
Exclude:
|
||||
- 'app/models/comment.rb'
|
||||
|
||||
# Offense count: 3
|
||||
Style/MixinUsage:
|
||||
Exclude:
|
||||
- 'app/models/organization.rb'
|
||||
- 'app/models/podcast_episode.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: AutoCorrect, EnforcedStyle.
|
||||
# SupportedStyles: predicate, comparison
|
||||
Style/NumericPredicate:
|
||||
Exclude:
|
||||
- 'spec/**/*'
|
||||
- 'app/liquid_tags/github_tag/github_issue_tag.rb'
|
||||
|
||||
# Offense count: 3
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: AllowAsExpressionSeparator.
|
||||
Style/Semicolon:
|
||||
Exclude:
|
||||
- 'app/controllers/stories_controller.rb'
|
||||
2
Gemfile
2
Gemfile
|
|
@ -10,7 +10,7 @@ git_source(:github) do |repo_name|
|
|||
end
|
||||
|
||||
group :production do
|
||||
gem 'nakayoshi_fork'
|
||||
gem "nakayoshi_fork"
|
||||
end
|
||||
|
||||
gem "actionpack-action_caching", "~> 1.2"
|
||||
|
|
|
|||
|
|
@ -617,7 +617,7 @@ GEM
|
|||
parallel (1.12.1)
|
||||
parallel_tests (2.21.3)
|
||||
parallel
|
||||
parser (2.5.1.0)
|
||||
parser (2.5.1.2)
|
||||
ast (~> 2.4.0)
|
||||
pg (0.21.0)
|
||||
powerpack (0.1.2)
|
||||
|
|
@ -736,10 +736,10 @@ GEM
|
|||
rspec-retry (0.6.1)
|
||||
rspec-core (> 3.3)
|
||||
rspec-support (3.7.1)
|
||||
rubocop (0.57.2)
|
||||
rubocop (0.58.2)
|
||||
jaro_winkler (~> 1.5.1)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 2.5)
|
||||
parser (>= 2.5, != 2.5.1.1)
|
||||
powerpack (~> 0.1)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
ignore([%r{^bin/*}, %r{^config/*}, %r{^db/*}, %r{^lib/*}, %r{^log/*}, %r{^public/*}, %r{^tmp/*}, %r{^node_modules/*}])
|
||||
|
||||
rspec_options = {
|
||||
results_file: File.expand_path('tmp/guard_rspec_results.txt'),
|
||||
results_file: File.expand_path("tmp/guard_rspec_results.txt"),
|
||||
#############################
|
||||
# BECAUSE spring doesn't seem to work well with simplecov, choose
|
||||
# between the following two.
|
||||
|
|
@ -37,7 +37,7 @@ rspec_options = {
|
|||
cmd: "bin/spring rspec -p",
|
||||
#############################
|
||||
failed_mode: :focus,
|
||||
bundler_env: :clean_env
|
||||
bundler_env: :clean_env,
|
||||
}
|
||||
|
||||
guard :rspec, rspec_options do
|
||||
|
|
@ -65,7 +65,7 @@ guard :rspec, rspec_options do
|
|||
[
|
||||
rspec.spec.call("routing/#{m[1]}_routing"),
|
||||
rspec.spec.call("controllers/#{m[1]}_controller"),
|
||||
rspec.spec.call("acceptance/#{m[1]}")
|
||||
rspec.spec.call("acceptance/#{m[1]}"),
|
||||
]
|
||||
end
|
||||
|
||||
|
|
|
|||
2
Rakefile
2
Rakefile
|
|
@ -1,6 +1,6 @@
|
|||
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
||||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
||||
|
||||
require File.expand_path('../config/application', __FILE__)
|
||||
require File.expand_path("config/application", __dir__)
|
||||
|
||||
Rails.application.load_tasks
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
class BlackBox
|
||||
def self.article_hotness_score(article)
|
||||
return (article.featured_number|| 10000)/10000 unless Rails.env.production?
|
||||
return (article.featured_number || 10000) / 10000 unless Rails.env.production?
|
||||
reaction_points = article.reactions.sum(:points)
|
||||
recency_bonus = article.published_at > 12.hours.ago ? 50 : 0
|
||||
today_bonus = article.published_at > 36.hours.ago ? 250 : 0
|
||||
FunctionCaller.new("blackbox-production-articleHotness",
|
||||
{article: article, user: article.user}.to_json).call +
|
||||
{ article: article, user: article.user }.to_json).call +
|
||||
reaction_points + recency_bonus + today_bonus
|
||||
end
|
||||
|
||||
def self.comment_quality_score(comment)
|
||||
descendants_points = (comment.descendants.size/2)
|
||||
descendants_points = (comment.descendants.size / 2)
|
||||
rep_points = comment.reactions.sum(:points)
|
||||
bonus_points = calculate_bonus_score(comment.body_markdown)
|
||||
spaminess_rating = calculate_spaminess(comment)
|
||||
|
|
@ -18,18 +18,18 @@ class BlackBox
|
|||
end
|
||||
|
||||
def self.calculate_spaminess(story)
|
||||
#accepts comment or article as story
|
||||
# accepts comment or article as story
|
||||
return 0 unless Rails.env.production?
|
||||
return 100 unless story.user
|
||||
FunctionCaller.new("blackbox-production-spamScore",
|
||||
{story: story, user: story.user}.to_json).call
|
||||
{ story: story, user: story.user }.to_json).call
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def self.calculate_bonus_score(body_markdown)
|
||||
size_bonus = body_markdown.size > 200 ? 2 : 0
|
||||
code_bonus = body_markdown.include?('`') ? 1 : 0
|
||||
code_bonus = body_markdown.include?("`") ? 1 : 0
|
||||
size_bonus + code_bonus
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ class AdditionalContentBoxesController < ApplicationController
|
|||
@boosted_article = Suggester::Articles::Boosted.new(
|
||||
current_user,
|
||||
@article,
|
||||
{not_ids: (article_ids + [@for_user_article&.id]), area: "additional_articles"},
|
||||
not_ids: (article_ids + [@for_user_article&.id]), area: "additional_articles",
|
||||
).suggest
|
||||
else
|
||||
@alt_classic = Suggester::Articles::Classic.
|
||||
new(@article, {not_ids: (article_ids + [@for_user_article&.id])}).get
|
||||
new(@article, not_ids: (article_ids + [@for_user_article&.id])).get
|
||||
end
|
||||
set_surrogate_key_header "additional_content_boxes_" + params.to_s unless current_user
|
||||
render "boxes", layout: false
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ module Admin
|
|||
before_action :authorize_admin
|
||||
|
||||
def order
|
||||
@_order ||= Administrate::Order.new(params[:order] || "id",params[:direction] || "desc")
|
||||
@_order ||= Administrate::Order.new(params[:order] || "id", params[:direction] || "desc")
|
||||
end
|
||||
|
||||
def valid_request_origin?
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
class Api::V0::ApiController < ApplicationController
|
||||
def cors_set_access_control_headers
|
||||
headers['Access-Control-Allow-Origin'] = '*'
|
||||
headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS'
|
||||
headers['Access-Control-Allow-Headers'] = 'Origin, Content-Type, Accept, Authorization, Token'
|
||||
headers['Access-Control-Max-Age'] = "1728000"
|
||||
headers["Access-Control-Allow-Origin"] = "*"
|
||||
headers["Access-Control-Allow-Methods"] = "POST, GET, PUT, DELETE, OPTIONS"
|
||||
headers["Access-Control-Allow-Headers"] = "Origin, Content-Type, Accept, Authorization, Token"
|
||||
headers["Access-Control-Max-Age"] = "1728000"
|
||||
end
|
||||
|
||||
def cors_preflight_check
|
||||
if request.method == 'OPTIONS'
|
||||
headers['Access-Control-Allow-Origin'] = '*'
|
||||
headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS'
|
||||
headers['Access-Control-Allow-Headers'] = 'X-Requested-With, X-Prototype-Version, Token'
|
||||
headers['Access-Control-Max-Age'] = '1728000'
|
||||
if request.method == "OPTIONS"
|
||||
headers["Access-Control-Allow-Origin"] = "*"
|
||||
headers["Access-Control-Allow-Methods"] = "POST, GET, PUT, DELETE, OPTIONS"
|
||||
headers["Access-Control-Allow-Headers"] = "X-Requested-With, X-Prototype-Version, Token"
|
||||
headers["Access-Control-Max-Age"] = "1728000"
|
||||
|
||||
render :text => '', :content_type => 'text/plain'
|
||||
render text: "", content_type: "text/plain"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -55,9 +55,9 @@ module Api
|
|||
def update
|
||||
@article = Article.find(params[:id])
|
||||
render json: if @article.update(article_params)
|
||||
@article.to_json(only: [:id], methods: [:current_state_path])
|
||||
else
|
||||
@article.errors.to_json
|
||||
@article.to_json(only: [:id], methods: [:current_state_path])
|
||||
else
|
||||
@article.errors.to_json
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,27 +1,25 @@
|
|||
module Api
|
||||
module V0
|
||||
class CommentsController < ApplicationController
|
||||
|
||||
# before_action :set_cache_control_headers, only: [:index, :show]
|
||||
caches_action :index,
|
||||
:cache_path => Proc.new { |c| c.params.permit! },
|
||||
:expires_in => 10.minutes
|
||||
cache_path: Proc.new { |c| c.params.permit! },
|
||||
expires_in: 10.minutes
|
||||
respond_to :json
|
||||
|
||||
caches_action :show,
|
||||
:cache_path => Proc.new { |c| c.params.permit! },
|
||||
:expires_in => 10.minutes
|
||||
cache_path: Proc.new { |c| c.params.permit! },
|
||||
expires_in: 10.minutes
|
||||
respond_to :json
|
||||
|
||||
def index
|
||||
@commentable = Article.find(params[:a_id])# or not_found
|
||||
@commentable = Article.find(params[:a_id]) # or not_found
|
||||
@commentable_type = "Article"
|
||||
end
|
||||
|
||||
def show
|
||||
@comment = Comment.find(params[:id].to_i(26)) or not_found
|
||||
(@comment = Comment.find(params[:id].to_i(26))) || not_found
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@ module Api
|
|||
return unless user_signed_in?
|
||||
users = JSON.parse(params[:users])
|
||||
users.each do |user_hash|
|
||||
followable = User.find(user_hash['id'])
|
||||
followable = User.find(user_hash["id"])
|
||||
current_user.delay.follow(followable)
|
||||
end
|
||||
render json: { outcome: "followed 50 users" }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,16 +1,15 @@
|
|||
module Api
|
||||
module V0
|
||||
class PodcastEpisodesController < ApiController
|
||||
|
||||
# before_action :set_cache_control_headers, only: [:index, :show]
|
||||
caches_action :index,
|
||||
:cache_path => Proc.new { |c| c.params.permit! },
|
||||
:expires_in => 10.minutes
|
||||
cache_path: Proc.new { |c| c.params.permit! },
|
||||
expires_in: 10.minutes
|
||||
respond_to :json
|
||||
|
||||
caches_action :show,
|
||||
:cache_path => Proc.new { |c| c.params.permit! },
|
||||
:expires_in => 10.minutes
|
||||
cache_path: Proc.new { |c| c.params.permit! },
|
||||
expires_in: 10.minutes
|
||||
respond_to :json
|
||||
|
||||
before_action :cors_preflight_check
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ module Api
|
|||
def create
|
||||
@user = valid_user
|
||||
unless @user
|
||||
render json: { message: "invalid_user" }, :status => 422
|
||||
render json: { message: "invalid_user" }, status: 422
|
||||
return
|
||||
end
|
||||
Rails.cache.delete "count_for_reactable-#{params[:reactable_type]}-#{params[:reactable_id]}"
|
||||
|
|
|
|||
|
|
@ -16,11 +16,11 @@ module Api
|
|||
end
|
||||
|
||||
def show
|
||||
if params[:id] == "by_username"
|
||||
@user = User.find_by_username(params[:url])
|
||||
else
|
||||
@user = User.find(params[:id])
|
||||
end
|
||||
@user = if params[:id] == "by_username"
|
||||
User.find_by_username(params[:url])
|
||||
else
|
||||
User.find(params[:id])
|
||||
end
|
||||
end
|
||||
|
||||
def less_than_one_day_old?(user)
|
||||
|
|
|
|||
|
|
@ -50,10 +50,10 @@ class ArticlesController < ApplicationController
|
|||
if params[:state] == "v2" || Rails.env.development?
|
||||
Article.new
|
||||
else
|
||||
Article.new(
|
||||
body_markdown: "---\ntitle: \npublished: false\ndescription: \ntags: \n---\n\n",
|
||||
processed_html: "",
|
||||
)
|
||||
Article.new(
|
||||
body_markdown: "---\ntitle: \npublished: false\ndescription: \ntags: \n---\n\n",
|
||||
processed_html: "",
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -163,11 +163,7 @@ class ArticlesController < ApplicationController
|
|||
end
|
||||
|
||||
def set_article
|
||||
owner = if User.find_by_username(params[:username])
|
||||
User.find_by_username(params[:username])
|
||||
else
|
||||
Organization.find_by_slug(params[:username])
|
||||
end
|
||||
owner = User.find_by_username(params[:username]) || Organization.find_by_slug(params[:username])
|
||||
found_article = if params[:slug]
|
||||
owner.articles.includes(:user).find_by_slug(params[:slug])
|
||||
else
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ class AsyncInfoController < ApplicationController
|
|||
flash.discard(:notice)
|
||||
unless user_signed_in?
|
||||
render json: {
|
||||
param: request_forgery_protection_token,
|
||||
token: form_authenticity_token,
|
||||
param: request_forgery_protection_token,
|
||||
token: form_authenticity_token,
|
||||
}
|
||||
return
|
||||
end
|
||||
|
|
@ -22,7 +22,7 @@ class AsyncInfoController < ApplicationController
|
|||
render json: {
|
||||
param: request_forgery_protection_token,
|
||||
token: form_authenticity_token,
|
||||
user: user_data.to_json
|
||||
user: user_data.to_json,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
@ -36,7 +36,7 @@ class AsyncInfoController < ApplicationController
|
|||
username: @user.username,
|
||||
profile_image_90: ProfileImage.new(@user).get(90),
|
||||
followed_tag_names: @user.cached_followed_tag_names,
|
||||
followed_tags: @user.cached_followed_tags.to_json(only: [:id,:name,:bg_color_hex,:text_color_hex]),
|
||||
followed_tags: @user.cached_followed_tags.to_json(only: %i[id name bg_color_hex text_color_hex]),
|
||||
followed_user_ids: @user.cached_following_users_ids,
|
||||
reading_list_ids: ReadingList.new(@user).cached_ids_of_articles,
|
||||
saw_onboarding: @user.saw_onboarding,
|
||||
|
|
@ -44,7 +44,7 @@ class AsyncInfoController < ApplicationController
|
|||
checked_code_of_conduct: @user.checked_code_of_conduct,
|
||||
number_of_comments: @user.comments.count,
|
||||
display_sponsors: @user.display_sponsors,
|
||||
trusted: @user.trusted
|
||||
trusted: @user.trusted,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
class BlocksController < ApplicationController
|
||||
before_action :set_block, only: [:show, :edit, :update, :destroy]
|
||||
before_action :set_block, only: %i[show edit update destroy]
|
||||
|
||||
after_action :verify_authorized
|
||||
|
||||
|
||||
# GET /blocks
|
||||
# GET /blocks.json
|
||||
def index
|
||||
|
|
@ -80,5 +79,4 @@ class BlocksController < ApplicationController
|
|||
def set_block
|
||||
@block = Block.find(params[:id])
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class ChatChannelMembershipsController < ApplicationController
|
|||
ChatChannelMembership.create(
|
||||
user_id: permitted_params[:user_id],
|
||||
chat_channel_id: @chat_channel.id,
|
||||
status: "pending"
|
||||
status: "pending",
|
||||
)
|
||||
@chat_channel.index!
|
||||
end
|
||||
|
|
@ -41,4 +41,4 @@ class ChatChannelMembershipsController < ApplicationController
|
|||
def permitted_params
|
||||
params.require(:chat_channel_membership).permit(:user_id, :chat_channel_id, :user_action, :id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class ChatChannelsController < ApplicationController
|
|||
authorize ChatChannel
|
||||
@chat_channel = ChatChannelCreationService.new(current_user, params[:chat_channel]).create
|
||||
if @chat_channel.valid?
|
||||
render json: { status: "success", chat_channel: @chat_channel.to_json(only: [:channel_name,:slug]) }, status: 200
|
||||
render json: { status: "success", chat_channel: @chat_channel.to_json(only: %i[channel_name slug]) }, status: 200
|
||||
else
|
||||
render json: { errors: @chat_channel.errors.full_messages }
|
||||
end
|
||||
|
|
@ -35,7 +35,7 @@ class ChatChannelsController < ApplicationController
|
|||
authorize @chat_channel
|
||||
ChatChannelUpdateService.new(@chat_channel, chat_channel_params).update
|
||||
if @chat_channel.valid?
|
||||
render json: { status: "success", chat_channel: @chat_channel.to_json(only: [:channel_name,:slug]) }, status: 200
|
||||
render json: { status: "success", chat_channel: @chat_channel.to_json(only: %i[channel_name slug]) }, status: 200
|
||||
else
|
||||
render json: { errors: @chat_channel.errors.full_messages }
|
||||
end
|
||||
|
|
@ -101,25 +101,24 @@ class ChatChannelsController < ApplicationController
|
|||
end
|
||||
|
||||
def render_pending_json_response
|
||||
if current_user
|
||||
@chat_channels_memberships = current_user.
|
||||
chat_channel_memberships.includes(:chat_channel).
|
||||
where(status: "pending").
|
||||
order("chat_channel_memberships.updated_at DESC")
|
||||
else
|
||||
@chat_channels_memberships = []
|
||||
end
|
||||
@chat_channels_memberships = if current_user
|
||||
current_user.
|
||||
chat_channel_memberships.includes(:chat_channel).
|
||||
where(status: "pending").
|
||||
order("chat_channel_memberships.updated_at DESC")
|
||||
else
|
||||
[]
|
||||
end
|
||||
render "index.json"
|
||||
end
|
||||
|
||||
|
||||
def render_channels_html
|
||||
return unless current_user
|
||||
if params[:slug]
|
||||
slug = if params[:slug] && params[:slug].start_with?("@")
|
||||
[current_user.username, params[:slug].gsub("@", "")].sort.join("/")
|
||||
else
|
||||
params[:slug]
|
||||
slug = if params[:slug]&.start_with?("@")
|
||||
[current_user.username, params[:slug].gsub("@", "")].sort.join("/")
|
||||
else
|
||||
params[:slug]
|
||||
end
|
||||
@active_channel = ChatChannel.find_by_slug(slug)
|
||||
@active_channel.current_user = current_user if @active_channel
|
||||
|
|
@ -130,9 +129,9 @@ class ChatChannelsController < ApplicationController
|
|||
|
||||
def generate_algolia_search_key
|
||||
current_user_id = current_user.id
|
||||
params = {filters: "viewable_by:#{current_user_id} AND status: active"}
|
||||
params = { filters: "viewable_by:#{current_user_id} AND status: active" }
|
||||
@secured_algolia_key = Algolia.generate_secured_api_key(
|
||||
ApplicationConfig["ALGOLIASEARCH_SEARCH_ONLY_KEY"], params,
|
||||
ApplicationConfig["ALGOLIASEARCH_SEARCH_ONLY_KEY"], params
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class DashboardsController < ApplicationController
|
|||
elsif params[:which] == "user_followers"
|
||||
@follows = Follow.where(followable_id: @user.id, followable_type: "User").
|
||||
includes(:follower).order("created_at DESC").limit(80)
|
||||
elsif @user&.organization && @user.org_admin && params[:which] == "organization"
|
||||
elsif @user&.organization && @user&.org_admin && params[:which] == "organization"
|
||||
@articles = @user.organization.articles.order("created_at DESC").decorate
|
||||
elsif @user
|
||||
@articles = @user.articles.order("created_at DESC").decorate
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ class FollowedArticlesController < ApplicationController
|
|||
# No authorization required for entirely public controller
|
||||
|
||||
caches_action :index,
|
||||
:cache_path => Proc.new { "followed_articles_#{current_user.id}__#{current_user.updated_at}__#{user_signed_in?.to_s}" },
|
||||
:expires_in => 35.minutes
|
||||
cache_path: Proc.new { "followed_articles_#{current_user.id}__#{current_user.updated_at}__#{user_signed_in?}" },
|
||||
expires_in: 35.minutes
|
||||
|
||||
def index
|
||||
if current_user
|
||||
|
|
@ -26,9 +26,9 @@ class FollowedArticlesController < ApplicationController
|
|||
classic_article = Suggester::Articles::Classic.new(current_user).get
|
||||
response.headers["Cache-Control"] = "public, max-age=150"
|
||||
render json: {
|
||||
articles: @articles,
|
||||
classic_article: (article_json(classic_article) if classic_article),
|
||||
}.to_json
|
||||
articles: @articles,
|
||||
classic_article: (article_json(classic_article) if classic_article),
|
||||
}.to_json
|
||||
end
|
||||
|
||||
def inappropriate_hiring_instance(article)
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class GithubReposController < ApplicationController
|
|||
def create_octokit_client
|
||||
current_user_token = current_user.identities.where(provider: "github").last.token
|
||||
client = Octokit::Client.new(access_token: current_user_token)
|
||||
client.repositories.sort_by!(&:name) if client
|
||||
client&.repositories&.sort_by!(&:name)
|
||||
client
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -56,57 +56,57 @@ class GiveawaysController < ApplicationController
|
|||
end
|
||||
|
||||
private
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def user_params
|
||||
accessible = [
|
||||
:email,
|
||||
:shipping_name,
|
||||
:shipping_company,
|
||||
:shipping_address,
|
||||
:shipping_address_line_2,
|
||||
:shipping_city,
|
||||
:shipping_state,
|
||||
:shipping_country,
|
||||
:shipping_postal_code,
|
||||
:shipping_validated,
|
||||
:top_languages,
|
||||
:experience_level,
|
||||
:specialty,
|
||||
:tabs_or_spaces,
|
||||
:onboarding_package_requested,
|
||||
:onboarding_package_form_submmitted_at,
|
||||
:personal_data_updated_at,
|
||||
:shirt_size,
|
||||
:shirt_gender,
|
||||
]
|
||||
params.require(:user).permit(accessible)
|
||||
end
|
||||
|
||||
def confirm_presence
|
||||
unless user_params[:shipping_name].present?
|
||||
@errors << "You need a shipping name"
|
||||
@invalid_form = true
|
||||
end
|
||||
unless user_params[:shipping_address].present?
|
||||
@errors << "You need a shipping address"
|
||||
@invalid_form = true
|
||||
end
|
||||
unless user_params[:shipping_city].present?
|
||||
@errors << "You need a shipping city"
|
||||
@invalid_form = true
|
||||
end
|
||||
unless user_params[:shipping_country].present?
|
||||
@errors << "You need a shipping country"
|
||||
@invalid_form = true
|
||||
end
|
||||
unless user_params[:top_languages].present?
|
||||
@errors << "You need to include your favorite languages. It's a spam filter."
|
||||
@invalid_form = true
|
||||
end
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def user_params
|
||||
accessible = %i[
|
||||
email
|
||||
shipping_name
|
||||
shipping_company
|
||||
shipping_address
|
||||
shipping_address_line_2
|
||||
shipping_city
|
||||
shipping_state
|
||||
shipping_country
|
||||
shipping_postal_code
|
||||
shipping_validated
|
||||
top_languages
|
||||
experience_level
|
||||
specialty
|
||||
tabs_or_spaces
|
||||
onboarding_package_requested
|
||||
onboarding_package_form_submmitted_at
|
||||
personal_data_updated_at
|
||||
shirt_size
|
||||
shirt_gender
|
||||
]
|
||||
params.require(:user).permit(accessible)
|
||||
end
|
||||
|
||||
def confirm_presence
|
||||
unless user_params[:shipping_name].present?
|
||||
@errors << "You need a shipping name"
|
||||
@invalid_form = true
|
||||
end
|
||||
unless user_params[:shipping_address].present?
|
||||
@errors << "You need a shipping address"
|
||||
@invalid_form = true
|
||||
end
|
||||
unless user_params[:shipping_city].present?
|
||||
@errors << "You need a shipping city"
|
||||
@invalid_form = true
|
||||
end
|
||||
unless user_params[:shipping_country].present?
|
||||
@errors << "You need a shipping country"
|
||||
@invalid_form = true
|
||||
end
|
||||
unless user_params[:top_languages].present?
|
||||
@errors << "You need to include your favorite languages. It's a spam filter."
|
||||
@invalid_form = true
|
||||
end
|
||||
end
|
||||
|
||||
def prevent_request_if_requested_twice
|
||||
return if current_user.onboarding_package_requested_again
|
||||
end
|
||||
def prevent_request_if_requested_twice
|
||||
return if current_user.onboarding_package_requested_again
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ class ImageUploadsController < ApplicationController
|
|||
authorize :image_upload
|
||||
uploader = ArticleImageUploader.new
|
||||
uploader.store!(params[:image])
|
||||
link = if params[:wrap_cloudinary]
|
||||
ApplicationController.helpers.cloud_cover_url(uploader.url)
|
||||
else
|
||||
uploader.url
|
||||
link = if params[:wrap_cloudinary]
|
||||
ApplicationController.helpers.cloud_cover_url(uploader.url)
|
||||
else
|
||||
uploader.url
|
||||
end
|
||||
respond_to do |format|
|
||||
format.json { render json: { link: link }, status: 200 }
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
class Internal::ApplicationController < ApplicationController
|
||||
before_action :authorize_admin
|
||||
before_action :authorize_admin
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def authorize_admin
|
||||
authorize :admin, :show?
|
||||
end
|
||||
def authorize_admin
|
||||
authorize :admin, :show?
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ class Internal::ArticlesController < Internal::ApplicationController
|
|||
page(params[:page]).
|
||||
per(100).
|
||||
limited_columns_internal_select
|
||||
else #MIX
|
||||
else # MIX
|
||||
@articles = Article.
|
||||
where(published: true).
|
||||
order("published_at DESC").
|
||||
|
|
|
|||
|
|
@ -11,4 +11,4 @@ class Internal::BufferUpdatesController < Internal::ApplicationController
|
|||
render body: nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
class Internal::CommentsController < Internal::ApplicationController
|
||||
layout 'internal'
|
||||
layout "internal"
|
||||
|
||||
def index
|
||||
if params[:state]&.start_with?("toplast-")
|
||||
@comments = Comment.
|
||||
includes(:user).
|
||||
includes(:commentable).
|
||||
includes(:reactions).
|
||||
order("positive_reactions_count DESC").
|
||||
where("created_at > ?", params[:state].split("-").last.to_i.days.ago).
|
||||
page(params[:page] || 1).per(50)
|
||||
else
|
||||
@comments = Comment
|
||||
.includes(:user)
|
||||
.includes(:commentable)
|
||||
.includes(:reactions)
|
||||
.order("created_at DESC")
|
||||
.page(params[:page] || 1).per(50)
|
||||
end
|
||||
@comments = if params[:state]&.start_with?("toplast-")
|
||||
Comment.
|
||||
includes(:user).
|
||||
includes(:commentable).
|
||||
includes(:reactions).
|
||||
order("positive_reactions_count DESC").
|
||||
where("created_at > ?", params[:state].split("-").last.to_i.days.ago).
|
||||
page(params[:page] || 1).per(50)
|
||||
else
|
||||
Comment.
|
||||
includes(:user).
|
||||
includes(:commentable).
|
||||
includes(:reactions).
|
||||
order("created_at DESC").
|
||||
page(params[:page] || 1).per(50)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class Internal::DogfoodController < Internal::ApplicationController
|
|||
@team_members = User.where(username: usernames)
|
||||
@comments_this_week = Comment.where(user_id: @team_members.pluck(:id)).where("created_at > ?", Date.today.beginning_of_week).pluck(:user_id)
|
||||
@comment_totals_this_week = frequency(@comments_this_week)
|
||||
@comments_24_hours = Comment.where(user_id: @team_members.pluck(:id)).where("created_at > ?",24.hours.ago).pluck(:user_id)
|
||||
@comments_24_hours = Comment.where(user_id: @team_members.pluck(:id)).where("created_at > ?", 24.hours.ago).pluck(:user_id)
|
||||
@comment_totals_24_hours = frequency(@comments_24_hours)
|
||||
end
|
||||
|
||||
|
|
@ -22,5 +22,4 @@ class Internal::DogfoodController < Internal::ApplicationController
|
|||
{ number_of_comments: values.size, username: User.find(key).username }
|
||||
end.sort_by { |hsh| hsh[:number_of_comments] }.reverse!
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class Internal::FeedbackMessagesController < Internal::ApplicationController
|
|||
def feedback_message_params
|
||||
params[:feedback_message].permit(
|
||||
:status, :reviewer_id,
|
||||
note: [:content, :reason],
|
||||
note: %i[content reason]
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
class Internal::TagsController < Internal::ApplicationController
|
||||
layout 'internal'
|
||||
layout "internal"
|
||||
|
||||
def index
|
||||
if params[:state] == "supported"
|
||||
@tags = Tag.where(supported: true).order("taggings_count DESC").limit(120)
|
||||
elsif params[:state] == "unsupported"
|
||||
@tags = Tag.where(supported: false).order("taggings_count DESC").limit(120)
|
||||
else
|
||||
@tags = Tag.order("taggings_count DESC").limit(120)
|
||||
end
|
||||
@tags = if params[:state] == "supported"
|
||||
Tag.where(supported: true).order("taggings_count DESC").limit(120)
|
||||
elsif params[:state] == "unsupported"
|
||||
Tag.where(supported: false).order("taggings_count DESC").limit(120)
|
||||
else
|
||||
Tag.order("taggings_count DESC").limit(120)
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@tag = Tag.find(params[:id])
|
||||
@tag.update!(tag_params)
|
||||
redirect_to(action: :index)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
|
@ -27,5 +27,4 @@ class Internal::TagsController < Internal::ApplicationController
|
|||
:bg_color_hex,
|
||||
:text_color_hex)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
class Internal::UsersController < Internal::ApplicationController
|
||||
layout 'internal'
|
||||
layout "internal"
|
||||
|
||||
def index
|
||||
@users = User.where.not(feed_url: nil)
|
||||
|
|
@ -52,7 +52,7 @@ class Internal::UsersController < Internal::ApplicationController
|
|||
user.remove_from_index!
|
||||
user.save!
|
||||
user.update!(old_username: nil)
|
||||
rescue => e
|
||||
rescue StandardError => e
|
||||
flash[:error] = e.message
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class MessagesController < ApplicationController
|
|||
message: new_message.message_html,
|
||||
timestamp: Time.now,
|
||||
color: new_message.preferred_user_color,
|
||||
reception_method: "pushed"
|
||||
reception_method: "pushed",
|
||||
}.to_json
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class Notifications::ReadsController < ApplicationController
|
||||
|
||||
def create
|
||||
result = ""
|
||||
result = ReadNotificationsService.new(current_user).mark_as_read if current_user
|
||||
|
|
|
|||
|
|
@ -65,4 +65,4 @@ module StreamRails
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
class PagesController < ApplicationController
|
||||
# No authorization required for entirely public controller
|
||||
before_action :set_cache_control_headers, only: [:rlyweb, :now, :events, :membership, :survey]
|
||||
before_action :set_cache_control_headers, only: %i[rlyweb now events membership survey]
|
||||
|
||||
def now
|
||||
set_surrogate_key_header "now_page"
|
||||
|
|
@ -49,7 +49,8 @@ class PagesController < ApplicationController
|
|||
def live
|
||||
@active_channel = ChatChannel.find_by_channel_name("Workshop")
|
||||
@chat_channels = [@active_channel].to_json(
|
||||
only: [:channel_name,:channel_type,:last_message_at,:slug, :status, :id])
|
||||
only: %i[channel_name channel_type last_message_at slug status id],
|
||||
)
|
||||
end
|
||||
|
||||
private # helpers
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@ class PodcastEpisodesController < ApplicationController
|
|||
@podcasts = Podcast.order("title asc")
|
||||
@podcast_episodes = PodcastEpisode.order("published_at desc").first(20)
|
||||
unless params[:q].present?
|
||||
set_surrogate_key_header 'podcast_episodes_all '+params[:q].to_s, @podcast_episodes.map { |e| e["record_key"]}
|
||||
set_surrogate_key_header "podcast_episodes_all " + params[:q].to_s, @podcast_episodes.map { |e| e["record_key"] }
|
||||
end
|
||||
@featured_story = Article.new
|
||||
@podcast_index = true
|
||||
@article_index = true
|
||||
@list_of = "podcast-episodes"
|
||||
render :template => 'articles/index'
|
||||
render template: "articles/index"
|
||||
end
|
||||
|
||||
private
|
||||
|
|
@ -26,7 +26,4 @@ class PodcastEpisodesController < ApplicationController
|
|||
:remote_social_image_url,
|
||||
:quote)
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
class PusherController < ApplicationController
|
||||
|
||||
def auth
|
||||
if valid_channel
|
||||
response = Pusher.authenticate(params[:channel_name], params[:socket_id], {
|
||||
user_id: current_user.id, # => required
|
||||
})
|
||||
response = Pusher.authenticate(params[:channel_name], params[:socket_id],
|
||||
user_id: current_user.id) # => required
|
||||
render json: response
|
||||
else
|
||||
render json: { text: 'Forbidden', status: '403' }
|
||||
render json: { text: "Forbidden", status: "403" }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@ class ReactionsController < ApplicationController
|
|||
{
|
||||
current_user: { id: efficient_current_user_id },
|
||||
article_reaction_counts: Reaction.count_for_reactable(article),
|
||||
reactions: reactions
|
||||
reactions: reactions,
|
||||
}.to_json
|
||||
else
|
||||
comments = Comment.where(
|
||||
commentable_id: params[:commentable_id],
|
||||
commentable_type: params[:commentable_type],
|
||||
).select([:id, :positive_reactions_count])
|
||||
).select(%i[id positive_reactions_count])
|
||||
comment_ids = comments.map(&:id)
|
||||
reaction_counts = comments.map { |c| { id: c.id, count: c.positive_reactions_count } }
|
||||
reactions = current_user ? cached_user_positive_reactions(current_user).where(reactable_id: comment_ids) : []
|
||||
|
|
@ -32,7 +32,7 @@ class ReactionsController < ApplicationController
|
|||
{
|
||||
current_user: { id: current_user&.id },
|
||||
positive_reaction_counts: reaction_counts,
|
||||
reactions: reactions
|
||||
reactions: reactions,
|
||||
}.to_json
|
||||
end
|
||||
set_surrogate_key_header params.to_s unless current_user
|
||||
|
|
@ -66,7 +66,7 @@ class ReactionsController < ApplicationController
|
|||
def cached_user_positive_reactions(user)
|
||||
Rails.cache.fetch("cached_user_reactions-#{user.id}-#{user.updated_at}", expires_in: 24.hours) do
|
||||
Reaction.where(user_id: user.id).
|
||||
where("points > ?", 0)
|
||||
where("points > ?", 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
class RegistrationsController < Devise::RegistrationsController
|
||||
prepend_before_action :require_no_authentication, :only => []
|
||||
prepend_before_action :require_no_authentication, only: []
|
||||
# No authorization required for public registration route
|
||||
|
||||
def new
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
class StoriesController < ApplicationController
|
||||
before_action :authenticate_user!, except: [:index,:search,:show, :feed, :new]
|
||||
before_action :set_cache_control_headers, only: [:index, :search, :show]
|
||||
before_action :authenticate_user!, except: %i[index search show feed new]
|
||||
before_action :set_cache_control_headers, only: %i[index search show]
|
||||
|
||||
def index
|
||||
return handle_user_or_organization_or_podcast_index if params[:username]
|
||||
|
|
@ -81,11 +81,11 @@ class StoriesController < ApplicationController
|
|||
|
||||
@stories = article_finder(8)
|
||||
|
||||
if @tag_model && @tag_model.requires_approval
|
||||
if @tag_model&.requires_approval
|
||||
@stories = @stories.where(approved: true)
|
||||
end
|
||||
|
||||
@stories = stories_by_timeframe
|
||||
@stories = stories_by_timeframe
|
||||
@stories = @stories.decorate
|
||||
|
||||
@featured_story = Article.new
|
||||
|
|
@ -147,7 +147,7 @@ class StoriesController < ApplicationController
|
|||
end
|
||||
|
||||
def handle_user_index
|
||||
@user = User.find_by_username(params[:username].tr("@","").downcase)
|
||||
@user = User.find_by_username(params[:username].tr("@", "").downcase)
|
||||
unless @user
|
||||
redirect_to_changed_username_profile
|
||||
return
|
||||
|
|
@ -173,7 +173,7 @@ class StoriesController < ApplicationController
|
|||
@comments_to_show_count = 25
|
||||
@comment = Comment.new
|
||||
render template: "podcast_episodes/show"
|
||||
return
|
||||
nil
|
||||
end
|
||||
|
||||
def redirect_if_view_param
|
||||
|
|
@ -239,7 +239,7 @@ class StoriesController < ApplicationController
|
|||
|
||||
def assign_organization_article
|
||||
@article = @organization.articles.find_by_slug(params[:slug])&.decorate
|
||||
@user = @article&.user || not_found #The org may have changed back to user and this does not handle that properly
|
||||
@user = @article&.user || not_found # The org may have changed back to user and this does not handle that properly
|
||||
end
|
||||
|
||||
def assign_user_article
|
||||
|
|
@ -273,12 +273,12 @@ class StoriesController < ApplicationController
|
|||
|
||||
def article_finder(num_articles)
|
||||
Article.where(published: true).
|
||||
includes(:user).
|
||||
limited_column_select.
|
||||
page(@page).
|
||||
per(num_articles).
|
||||
filter_excluded_tags(params[:tag])
|
||||
end
|
||||
includes(:user).
|
||||
limited_column_select.
|
||||
page(@page).
|
||||
per(num_articles).
|
||||
filter_excluded_tags(params[:tag])
|
||||
end
|
||||
|
||||
def assign_sticky_nav
|
||||
return unless @article
|
||||
|
|
@ -298,7 +298,7 @@ class StoriesController < ApplicationController
|
|||
order("RANDOM()").
|
||||
limit(8)
|
||||
if tag_articles.size < 6
|
||||
more_articles = Article.tagged_with((["career","productivity","discuss","explainlikeimfive"]), any: true).
|
||||
more_articles = Article.tagged_with(["career", "productivity", "discuss", "explainlikeimfive"], any: true).
|
||||
includes(:user).
|
||||
where("comments_count > ?", comment_count_num).
|
||||
limited_column_select.
|
||||
|
|
@ -310,12 +310,11 @@ class StoriesController < ApplicationController
|
|||
end
|
||||
|
||||
@user_stickies = (@organization || @user).articles.
|
||||
where(published: true).
|
||||
limited_column_select.
|
||||
tagged_with(article_tags, any: true).
|
||||
where.not(id: @article.id).order("published_at DESC").
|
||||
limit(2)
|
||||
where(published: true).
|
||||
limited_column_select.
|
||||
tagged_with(article_tags, any: true).
|
||||
where.not(id: @article.id).order("published_at DESC").
|
||||
limit(2)
|
||||
@sticky_articles = (tag_articles + more_articles).sample(8)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class TwilioTokensController < ApplicationController
|
|||
return
|
||||
end
|
||||
@chat_channel = ChatChannel.find(video_channel.to_i)
|
||||
authorize @chat_channel #show pundit method for chat_channel_policy works here, should always check though
|
||||
authorize @chat_channel # show pundit method for chat_channel_policy works here, should always check though
|
||||
@twilio_token = TwilioToken.new(current_user, params[:id]).get
|
||||
render json: { status: "success", token: @twilio_token }, status: 200
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class VideosController < ApplicationController
|
|||
|
||||
def create
|
||||
authorize :video
|
||||
@article = Article.new(body_markdown:"---\ntitle: Unpublished Video ~ #{rand(100000).to_s(26)}\npublished: false\ndescription: \ntags: \n---\n\n",processed_html:"")
|
||||
@article = Article.new(body_markdown: "---\ntitle: Unpublished Video ~ #{rand(100000).to_s(26)}\npublished: false\ndescription: \ntags: \n---\n\n", processed_html: "")
|
||||
@article.user_id = current_user.id
|
||||
@article.show_comments = true
|
||||
assign_video_attributes
|
||||
|
|
|
|||
|
|
@ -45,20 +45,20 @@ class ArticleDashboard < Administrate::BaseDashboard
|
|||
video_thumbnail_url: Field::String,
|
||||
video_closed_caption_track_url: Field::String,
|
||||
main_tag_name_for_social: Field::String,
|
||||
}
|
||||
}.freeze
|
||||
|
||||
# COLLECTION_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's index page.
|
||||
#
|
||||
# By default, it's limited to four items to reduce clutter on index pages.
|
||||
# Feel free to add, remove, or rearrange items.
|
||||
COLLECTION_ATTRIBUTES = [
|
||||
:user,
|
||||
:title,
|
||||
:published,
|
||||
:featured,
|
||||
:comments
|
||||
]
|
||||
COLLECTION_ATTRIBUTES = %i[
|
||||
user
|
||||
title
|
||||
published
|
||||
featured
|
||||
comments
|
||||
].freeze
|
||||
|
||||
# SHOW_PAGE_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's show page.
|
||||
|
|
@ -67,35 +67,34 @@ class ArticleDashboard < Administrate::BaseDashboard
|
|||
# FORM_ATTRIBUTES
|
||||
# an array of attributes that will be displayed
|
||||
# on the model's form (`new` and `edit`) pages.
|
||||
FORM_ATTRIBUTES = [
|
||||
:user_id,
|
||||
:second_user_id,
|
||||
:third_user_id,
|
||||
:organization,
|
||||
:title,
|
||||
:body_markdown,
|
||||
:slug,
|
||||
:social_image,
|
||||
:featured,
|
||||
:approved,
|
||||
:featured_number,
|
||||
:canonical_url,
|
||||
:password,
|
||||
:published_at,
|
||||
:collection,
|
||||
:collection_position,
|
||||
:name_within_collection,
|
||||
:show_comments,
|
||||
:main_image_background_hex_color,
|
||||
:ids_for_suggested_articles,
|
||||
:video,
|
||||
:video_code,
|
||||
:video_source_url,
|
||||
:video_thumbnail_url,
|
||||
:video_closed_caption_track_url,
|
||||
:main_tag_name_for_social
|
||||
|
||||
]
|
||||
FORM_ATTRIBUTES = %i[
|
||||
user_id
|
||||
second_user_id
|
||||
third_user_id
|
||||
organization
|
||||
title
|
||||
body_markdown
|
||||
slug
|
||||
social_image
|
||||
featured
|
||||
approved
|
||||
featured_number
|
||||
canonical_url
|
||||
password
|
||||
published_at
|
||||
collection
|
||||
collection_position
|
||||
name_within_collection
|
||||
show_comments
|
||||
main_image_background_hex_color
|
||||
ids_for_suggested_articles
|
||||
video
|
||||
video_code
|
||||
video_source_url
|
||||
video_thumbnail_url
|
||||
video_closed_caption_track_url
|
||||
main_tag_name_for_social
|
||||
].freeze
|
||||
|
||||
# Overwrite this method to customize how articles are displayed
|
||||
# across all pages of the admin dashboard.
|
||||
|
|
|
|||
|
|
@ -26,34 +26,34 @@ class BadgeAchievementDashboard < Administrate::BaseDashboard
|
|||
#
|
||||
# By default, it's limited to four items to reduce clutter on index pages.
|
||||
# Feel free to add, remove, or rearrange items.
|
||||
COLLECTION_ATTRIBUTES = [
|
||||
:user,
|
||||
:badge,
|
||||
:rewarder,
|
||||
:id,
|
||||
COLLECTION_ATTRIBUTES = %i[
|
||||
user
|
||||
badge
|
||||
rewarder
|
||||
id
|
||||
].freeze
|
||||
|
||||
# SHOW_PAGE_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's show page.
|
||||
SHOW_PAGE_ATTRIBUTES = [
|
||||
:id,
|
||||
:user,
|
||||
:name_of_user,
|
||||
:badge,
|
||||
:rewarding_context_message,
|
||||
:rewarder,
|
||||
:created_at,
|
||||
:updated_at,
|
||||
SHOW_PAGE_ATTRIBUTES = %i[
|
||||
id
|
||||
user
|
||||
name_of_user
|
||||
badge
|
||||
rewarding_context_message
|
||||
rewarder
|
||||
created_at
|
||||
updated_at
|
||||
].freeze
|
||||
|
||||
# FORM_ATTRIBUTES
|
||||
# an array of attributes that will be displayed
|
||||
# on the model's form (`new` and `edit`) pages.
|
||||
FORM_ATTRIBUTES = [
|
||||
:user_id,
|
||||
:rewarding_context_message_markdown,
|
||||
:badge,
|
||||
:rewarder_id,
|
||||
FORM_ATTRIBUTES = %i[
|
||||
user_id
|
||||
rewarding_context_message_markdown
|
||||
badge
|
||||
rewarder_id
|
||||
].freeze
|
||||
|
||||
# Overwrite this method to customize how badge achievements are displayed
|
||||
|
|
|
|||
|
|
@ -23,35 +23,35 @@ class BadgeDashboard < Administrate::BaseDashboard
|
|||
#
|
||||
# By default, it's limited to four items to reduce clutter on index pages.
|
||||
# Feel free to add, remove, or rearrange items.
|
||||
COLLECTION_ATTRIBUTES = [
|
||||
:badge_image,
|
||||
:id,
|
||||
:title,
|
||||
:slug,
|
||||
:description,
|
||||
COLLECTION_ATTRIBUTES = %i[
|
||||
badge_image
|
||||
id
|
||||
title
|
||||
slug
|
||||
description
|
||||
].freeze
|
||||
|
||||
# SHOW_PAGE_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's show page.
|
||||
SHOW_PAGE_ATTRIBUTES = [
|
||||
:users,
|
||||
:id,
|
||||
:title,
|
||||
:slug,
|
||||
:description,
|
||||
:badge_image,
|
||||
:created_at,
|
||||
:updated_at,
|
||||
SHOW_PAGE_ATTRIBUTES = %i[
|
||||
users
|
||||
id
|
||||
title
|
||||
slug
|
||||
description
|
||||
badge_image
|
||||
created_at
|
||||
updated_at
|
||||
].freeze
|
||||
|
||||
# FORM_ATTRIBUTES
|
||||
# an array of attributes that will be displayed
|
||||
# on the model's form (`new` and `edit`) pages.
|
||||
FORM_ATTRIBUTES = [
|
||||
:title,
|
||||
:slug,
|
||||
:description,
|
||||
:badge_image,
|
||||
FORM_ATTRIBUTES = %i[
|
||||
title
|
||||
slug
|
||||
description
|
||||
badge_image
|
||||
].freeze
|
||||
|
||||
# Overwrite this method to customize how badges are displayed
|
||||
|
|
|
|||
|
|
@ -20,51 +20,51 @@ class CollectionDashboard < Administrate::BaseDashboard
|
|||
published: Field::Boolean,
|
||||
created_at: Field::DateTime,
|
||||
updated_at: Field::DateTime,
|
||||
}
|
||||
}.freeze
|
||||
|
||||
# COLLECTION_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's index page.
|
||||
#
|
||||
# By default, it's limited to four items to reduce clutter on index pages.
|
||||
# Feel free to add, remove, or rearrange items.
|
||||
COLLECTION_ATTRIBUTES = [
|
||||
:articles,
|
||||
:user,
|
||||
:organization,
|
||||
:id,
|
||||
]
|
||||
COLLECTION_ATTRIBUTES = %i[
|
||||
articles
|
||||
user
|
||||
organization
|
||||
id
|
||||
].freeze
|
||||
|
||||
# SHOW_PAGE_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's show page.
|
||||
SHOW_PAGE_ATTRIBUTES = [
|
||||
:articles,
|
||||
:user,
|
||||
:organization,
|
||||
:id,
|
||||
:title,
|
||||
:slug,
|
||||
:description,
|
||||
:main_image,
|
||||
:social_image,
|
||||
:published,
|
||||
:created_at,
|
||||
:updated_at,
|
||||
]
|
||||
SHOW_PAGE_ATTRIBUTES = %i[
|
||||
articles
|
||||
user
|
||||
organization
|
||||
id
|
||||
title
|
||||
slug
|
||||
description
|
||||
main_image
|
||||
social_image
|
||||
published
|
||||
created_at
|
||||
updated_at
|
||||
].freeze
|
||||
|
||||
# FORM_ATTRIBUTES
|
||||
# an array of attributes that will be displayed
|
||||
# on the model's form (`new` and `edit`) pages.
|
||||
FORM_ATTRIBUTES = [
|
||||
:articles,
|
||||
:user,
|
||||
:organization,
|
||||
:title,
|
||||
:slug,
|
||||
:description,
|
||||
:main_image,
|
||||
:social_image,
|
||||
:published,
|
||||
]
|
||||
FORM_ATTRIBUTES = %i[
|
||||
articles
|
||||
user
|
||||
organization
|
||||
title
|
||||
slug
|
||||
description
|
||||
main_image
|
||||
social_image
|
||||
published
|
||||
].freeze
|
||||
|
||||
# Overwrite this method to customize how collections are displayed
|
||||
# across all pages of the admin dashboard.
|
||||
|
|
|
|||
|
|
@ -23,46 +23,46 @@ class CommentDashboard < Administrate::BaseDashboard
|
|||
id_code: Field::String,
|
||||
score: Field::Number,
|
||||
deleted: Field::Boolean,
|
||||
}
|
||||
}.freeze
|
||||
|
||||
# COLLECTION_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's index page.
|
||||
#
|
||||
# By default, it's limited to four items to reduce clutter on index pages.
|
||||
# Feel free to add, remove, or rearrange items.
|
||||
COLLECTION_ATTRIBUTES = [
|
||||
:id,
|
||||
:name_of_user,
|
||||
:body_markdown,
|
||||
:reactions,
|
||||
]
|
||||
COLLECTION_ATTRIBUTES = %i[
|
||||
id
|
||||
name_of_user
|
||||
body_markdown
|
||||
reactions
|
||||
].freeze
|
||||
|
||||
# SHOW_PAGE_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's show page.
|
||||
SHOW_PAGE_ATTRIBUTES = [
|
||||
:commentable,
|
||||
:user,
|
||||
:name_of_user,
|
||||
:reactions,
|
||||
:id,
|
||||
:body_markdown,
|
||||
:edited,
|
||||
:created_at,
|
||||
:updated_at,
|
||||
:ancestry,
|
||||
:id_code,
|
||||
:score,
|
||||
:deleted,
|
||||
]
|
||||
SHOW_PAGE_ATTRIBUTES = %i[
|
||||
commentable
|
||||
user
|
||||
name_of_user
|
||||
reactions
|
||||
id
|
||||
body_markdown
|
||||
edited
|
||||
created_at
|
||||
updated_at
|
||||
ancestry
|
||||
id_code
|
||||
score
|
||||
deleted
|
||||
].freeze
|
||||
|
||||
# FORM_ATTRIBUTES
|
||||
# an array of attributes that will be displayed
|
||||
# on the model's form (`new` and `edit`) pages.
|
||||
FORM_ATTRIBUTES = [
|
||||
:user_id,
|
||||
:body_markdown,
|
||||
:deleted,
|
||||
]
|
||||
FORM_ATTRIBUTES = %i[
|
||||
user_id
|
||||
body_markdown
|
||||
deleted
|
||||
].freeze
|
||||
|
||||
# Overwrite this method to customize how comments are displayed
|
||||
# across all pages of the admin dashboard.
|
||||
|
|
|
|||
|
|
@ -9,23 +9,23 @@ class DashboardManifest
|
|||
# To show or hide dashboards, add or remove the model name from this list.
|
||||
# Dashboards returned from this method must be Rails models for Administrate
|
||||
# to work correctly.
|
||||
DASHBOARDS = [
|
||||
:articles,
|
||||
:users,
|
||||
:organizations,
|
||||
:comments,
|
||||
:follows,
|
||||
:reactions,
|
||||
:podcasts,
|
||||
:podcast_episodes,
|
||||
:collections,
|
||||
:tags,
|
||||
:email_messages,
|
||||
:feedback_messages,
|
||||
:display_ads,
|
||||
:badges,
|
||||
:badge_achievements,
|
||||
]
|
||||
DASHBOARDS = %i[
|
||||
articles
|
||||
users
|
||||
organizations
|
||||
comments
|
||||
follows
|
||||
reactions
|
||||
podcasts
|
||||
podcast_episodes
|
||||
collections
|
||||
tags
|
||||
email_messages
|
||||
feedback_messages
|
||||
display_ads
|
||||
badges
|
||||
badge_achievements
|
||||
].freeze
|
||||
# DASHBOARDS = [
|
||||
# :users,
|
||||
# :articles,
|
||||
|
|
|
|||
|
|
@ -28,42 +28,42 @@ class DisplayAdDashboard < Administrate::BaseDashboard
|
|||
#
|
||||
# By default, it's limited to four items to reduce clutter on index pages.
|
||||
# Feel free to add, remove, or rearrange items.
|
||||
COLLECTION_ATTRIBUTES = [
|
||||
:organization,
|
||||
:id,
|
||||
:placement_area,
|
||||
:body_markdown,
|
||||
COLLECTION_ATTRIBUTES = %i[
|
||||
organization
|
||||
id
|
||||
placement_area
|
||||
body_markdown
|
||||
].freeze
|
||||
|
||||
# SHOW_PAGE_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's show page.
|
||||
SHOW_PAGE_ATTRIBUTES = [
|
||||
:organization,
|
||||
:id,
|
||||
:placement_area,
|
||||
:body_markdown,
|
||||
:processed_html,
|
||||
:cost_per_impression,
|
||||
:cost_per_click,
|
||||
:impressions_count,
|
||||
:clicks_count,
|
||||
:published,
|
||||
:approved,
|
||||
:created_at,
|
||||
:updated_at,
|
||||
SHOW_PAGE_ATTRIBUTES = %i[
|
||||
organization
|
||||
id
|
||||
placement_area
|
||||
body_markdown
|
||||
processed_html
|
||||
cost_per_impression
|
||||
cost_per_click
|
||||
impressions_count
|
||||
clicks_count
|
||||
published
|
||||
approved
|
||||
created_at
|
||||
updated_at
|
||||
].freeze
|
||||
|
||||
# FORM_ATTRIBUTES
|
||||
# an array of attributes that will be displayed
|
||||
# on the model's form (`new` and `edit`) pages.
|
||||
FORM_ATTRIBUTES = [
|
||||
:organization,
|
||||
:placement_area,
|
||||
:body_markdown,
|
||||
:cost_per_impression,
|
||||
:cost_per_click,
|
||||
:published,
|
||||
:approved,
|
||||
FORM_ATTRIBUTES = %i[
|
||||
organization
|
||||
placement_area
|
||||
body_markdown
|
||||
cost_per_impression
|
||||
cost_per_click
|
||||
published
|
||||
approved
|
||||
].freeze
|
||||
|
||||
# Overwrite this method to customize how display ads are displayed
|
||||
|
|
|
|||
|
|
@ -30,32 +30,32 @@ class EmailMessageDashboard < Administrate::BaseDashboard
|
|||
#
|
||||
# By default, it's limited to four items to reduce clutter on index pages.
|
||||
# Feel free to add, remove, or rearrange items.
|
||||
COLLECTION_ATTRIBUTES = [
|
||||
:user,
|
||||
:id,
|
||||
:subject,
|
||||
:opened_at,
|
||||
:clicked_at,
|
||||
COLLECTION_ATTRIBUTES = %i[
|
||||
user
|
||||
id
|
||||
subject
|
||||
opened_at
|
||||
clicked_at
|
||||
].freeze
|
||||
|
||||
# SHOW_PAGE_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's show page.
|
||||
SHOW_PAGE_ATTRIBUTES = [
|
||||
:user,
|
||||
:id,
|
||||
:token,
|
||||
:to,
|
||||
:mailer,
|
||||
:subject,
|
||||
:content,
|
||||
:utm_source,
|
||||
:utm_medium,
|
||||
:utm_term,
|
||||
:utm_content,
|
||||
:utm_campaign,
|
||||
:sent_at,
|
||||
:opened_at,
|
||||
:clicked_at,
|
||||
SHOW_PAGE_ATTRIBUTES = %i[
|
||||
user
|
||||
id
|
||||
token
|
||||
to
|
||||
mailer
|
||||
subject
|
||||
content
|
||||
utm_source
|
||||
utm_medium
|
||||
utm_term
|
||||
utm_content
|
||||
utm_campaign
|
||||
sent_at
|
||||
opened_at
|
||||
clicked_at
|
||||
].freeze
|
||||
|
||||
# FORM_ATTRIBUTES
|
||||
|
|
|
|||
|
|
@ -20,31 +20,31 @@ class FeedbackMessageDashboard < Administrate::BaseDashboard
|
|||
#
|
||||
# By default, it's limited to four items to reduce clutter on index pages.
|
||||
# Feel free to add, remove, or rearrange items.
|
||||
COLLECTION_ATTRIBUTES = [
|
||||
:user,
|
||||
:id,
|
||||
:message,
|
||||
:feedback_type,
|
||||
COLLECTION_ATTRIBUTES = %i[
|
||||
user
|
||||
id
|
||||
message
|
||||
feedback_type
|
||||
].freeze
|
||||
|
||||
# SHOW_PAGE_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's show page.
|
||||
SHOW_PAGE_ATTRIBUTES = [
|
||||
:user,
|
||||
:id,
|
||||
:message,
|
||||
:feedback_type,
|
||||
:category,
|
||||
SHOW_PAGE_ATTRIBUTES = %i[
|
||||
user
|
||||
id
|
||||
message
|
||||
feedback_type
|
||||
category
|
||||
].freeze
|
||||
|
||||
# FORM_ATTRIBUTES
|
||||
# an array of attributes that will be displayed
|
||||
# on the model's form (`new` and `edit`) pages.
|
||||
FORM_ATTRIBUTES = [
|
||||
:user,
|
||||
:message,
|
||||
:feedback_type,
|
||||
:category,
|
||||
FORM_ATTRIBUTES = %i[
|
||||
user
|
||||
message
|
||||
feedback_type
|
||||
category
|
||||
].freeze
|
||||
|
||||
# Overwrite this method to customize how feedback messages are displayed
|
||||
|
|
|
|||
|
|
@ -23,32 +23,32 @@ class FollowDashboard < Administrate::BaseDashboard
|
|||
#
|
||||
# By default, it's limited to four items to reduce clutter on index pages.
|
||||
# Feel free to add, remove, or rearrange items.
|
||||
COLLECTION_ATTRIBUTES = [
|
||||
:created_at,
|
||||
:followable_type,
|
||||
:follower,
|
||||
:blocked,
|
||||
COLLECTION_ATTRIBUTES = %i[
|
||||
created_at
|
||||
followable_type
|
||||
follower
|
||||
blocked
|
||||
].freeze
|
||||
|
||||
# SHOW_PAGE_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's show page.
|
||||
SHOW_PAGE_ATTRIBUTES = [
|
||||
:followable_type,
|
||||
:followable_id,
|
||||
:follower,
|
||||
:id,
|
||||
:blocked,
|
||||
:created_at,
|
||||
:updated_at,
|
||||
SHOW_PAGE_ATTRIBUTES = %i[
|
||||
followable_type
|
||||
followable_id
|
||||
follower
|
||||
id
|
||||
blocked
|
||||
created_at
|
||||
updated_at
|
||||
].freeze
|
||||
|
||||
# FORM_ATTRIBUTES
|
||||
# an array of attributes that will be displayed
|
||||
# on the model's form (`new` and `edit`) pages.
|
||||
FORM_ATTRIBUTES = [
|
||||
:followable_id,
|
||||
:follower,
|
||||
:blocked,
|
||||
FORM_ATTRIBUTES = %i[
|
||||
followable_id
|
||||
follower
|
||||
blocked
|
||||
].freeze
|
||||
|
||||
# Overwrite this method to customize how follows are displayed
|
||||
|
|
|
|||
|
|
@ -34,20 +34,20 @@ class OrganizationDashboard < Administrate::BaseDashboard
|
|||
cta_button_text: Field::String,
|
||||
cta_button_url: Field::String,
|
||||
cta_body_markdown: Field::Text,
|
||||
}
|
||||
}.freeze
|
||||
|
||||
# COLLECTION_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's index page.
|
||||
#
|
||||
# By default, it's limited to four items to reduce clutter on index pages.
|
||||
# Feel free to add, remove, or rearrange items.
|
||||
COLLECTION_ATTRIBUTES = [
|
||||
:profile_image,
|
||||
:name,
|
||||
:url,
|
||||
:twitter_username,
|
||||
:approved,
|
||||
]
|
||||
COLLECTION_ATTRIBUTES = %i[
|
||||
profile_image
|
||||
name
|
||||
url
|
||||
twitter_username
|
||||
approved
|
||||
].freeze
|
||||
|
||||
# SHOW_PAGE_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's show page.
|
||||
|
|
@ -56,30 +56,30 @@ class OrganizationDashboard < Administrate::BaseDashboard
|
|||
# FORM_ATTRIBUTES
|
||||
# an array of attributes that will be displayed
|
||||
# on the model's form (`new` and `edit`) pages.
|
||||
FORM_ATTRIBUTES = [
|
||||
:name,
|
||||
:slug,
|
||||
:summary,
|
||||
:tag_line,
|
||||
:profile_image,
|
||||
:nav_image,
|
||||
:url,
|
||||
:bg_color_hex,
|
||||
:text_color_hex,
|
||||
:twitter_username,
|
||||
:github_username,
|
||||
:jobs_url,
|
||||
:jobs_email,
|
||||
:address,
|
||||
:city,
|
||||
:state,
|
||||
:zip_code,
|
||||
:country,
|
||||
:approved,
|
||||
:cta_button_text,
|
||||
:cta_button_url,
|
||||
:cta_body_markdown,
|
||||
]
|
||||
FORM_ATTRIBUTES = %i[
|
||||
name
|
||||
slug
|
||||
summary
|
||||
tag_line
|
||||
profile_image
|
||||
nav_image
|
||||
url
|
||||
bg_color_hex
|
||||
text_color_hex
|
||||
twitter_username
|
||||
github_username
|
||||
jobs_url
|
||||
jobs_email
|
||||
address
|
||||
city
|
||||
state
|
||||
zip_code
|
||||
country
|
||||
approved
|
||||
cta_button_text
|
||||
cta_button_url
|
||||
cta_body_markdown
|
||||
].freeze
|
||||
|
||||
def display_resource(organization)
|
||||
organization.name
|
||||
|
|
|
|||
|
|
@ -26,63 +26,63 @@ class PodcastDashboard < Administrate::BaseDashboard
|
|||
status_notice: Field::Text,
|
||||
created_at: Field::DateTime,
|
||||
updated_at: Field::DateTime,
|
||||
}
|
||||
}.freeze
|
||||
|
||||
# COLLECTION_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's index page.
|
||||
#
|
||||
# By default, it's limited to four items to reduce clutter on index pages.
|
||||
# Feel free to add, remove, or rearrange items.
|
||||
COLLECTION_ATTRIBUTES = [
|
||||
:podcast_episodes,
|
||||
:id,
|
||||
:title,
|
||||
:description,
|
||||
]
|
||||
COLLECTION_ATTRIBUTES = %i[
|
||||
podcast_episodes
|
||||
id
|
||||
title
|
||||
description
|
||||
].freeze
|
||||
|
||||
# SHOW_PAGE_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's show page.
|
||||
SHOW_PAGE_ATTRIBUTES = [
|
||||
:podcast_episodes,
|
||||
:id,
|
||||
:title,
|
||||
:description,
|
||||
:feed_url,
|
||||
:itunes_url,
|
||||
:overcast_url,
|
||||
:android_url,
|
||||
:soundcloud_url,
|
||||
:website_url,
|
||||
:status_notice,
|
||||
:twitter_username,
|
||||
:main_color_hex,
|
||||
:image,
|
||||
:pattern_image,
|
||||
:slug,
|
||||
:created_at,
|
||||
:updated_at,
|
||||
]
|
||||
SHOW_PAGE_ATTRIBUTES = %i[
|
||||
podcast_episodes
|
||||
id
|
||||
title
|
||||
description
|
||||
feed_url
|
||||
itunes_url
|
||||
overcast_url
|
||||
android_url
|
||||
soundcloud_url
|
||||
website_url
|
||||
status_notice
|
||||
twitter_username
|
||||
main_color_hex
|
||||
image
|
||||
pattern_image
|
||||
slug
|
||||
created_at
|
||||
updated_at
|
||||
].freeze
|
||||
|
||||
# FORM_ATTRIBUTES
|
||||
# an array of attributes that will be displayed
|
||||
# on the model's form (`new` and `edit`) pages.
|
||||
FORM_ATTRIBUTES = [
|
||||
:podcast_episodes,
|
||||
:title,
|
||||
:description,
|
||||
:status_notice,
|
||||
:feed_url,
|
||||
:itunes_url,
|
||||
:overcast_url,
|
||||
:android_url,
|
||||
:soundcloud_url,
|
||||
:website_url,
|
||||
:twitter_username,
|
||||
:pattern_image,
|
||||
:main_color_hex,
|
||||
:image,
|
||||
:slug,
|
||||
]
|
||||
FORM_ATTRIBUTES = %i[
|
||||
podcast_episodes
|
||||
title
|
||||
description
|
||||
status_notice
|
||||
feed_url
|
||||
itunes_url
|
||||
overcast_url
|
||||
android_url
|
||||
soundcloud_url
|
||||
website_url
|
||||
twitter_username
|
||||
pattern_image
|
||||
main_color_hex
|
||||
image
|
||||
slug
|
||||
].freeze
|
||||
|
||||
# Overwrite this method to customize how podcasts are displayed
|
||||
# across all pages of the admin dashboard.
|
||||
|
|
|
|||
|
|
@ -32,52 +32,52 @@ class PodcastEpisodeDashboard < Administrate::BaseDashboard
|
|||
created_at: Field::DateTime,
|
||||
updated_at: Field::DateTime,
|
||||
social_image: CarrierwaveField,
|
||||
}
|
||||
}.freeze
|
||||
|
||||
# COLLECTION_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's index page.
|
||||
#
|
||||
# By default, it's limited to four items to reduce clutter on index pages.
|
||||
# Feel free to add, remove, or rearrange items.
|
||||
COLLECTION_ATTRIBUTES = [
|
||||
:id,
|
||||
:title,
|
||||
]
|
||||
COLLECTION_ATTRIBUTES = %i[
|
||||
id
|
||||
title
|
||||
].freeze
|
||||
|
||||
# SHOW_PAGE_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's show page.
|
||||
SHOW_PAGE_ATTRIBUTES = [
|
||||
:id,
|
||||
:podcast,
|
||||
:title,
|
||||
:image,
|
||||
:social_image,
|
||||
:body,
|
||||
:featured,
|
||||
:featured_number,
|
||||
:media_url,
|
||||
:website_url,
|
||||
:itunes_url,
|
||||
:duration_in_seconds,
|
||||
:published_at,
|
||||
:slug,
|
||||
:created_at,
|
||||
:updated_at,
|
||||
]
|
||||
SHOW_PAGE_ATTRIBUTES = %i[
|
||||
id
|
||||
podcast
|
||||
title
|
||||
image
|
||||
social_image
|
||||
body
|
||||
featured
|
||||
featured_number
|
||||
media_url
|
||||
website_url
|
||||
itunes_url
|
||||
duration_in_seconds
|
||||
published_at
|
||||
slug
|
||||
created_at
|
||||
updated_at
|
||||
].freeze
|
||||
|
||||
# FORM_ATTRIBUTES
|
||||
# an array of attributes that will be displayed
|
||||
# on the model's form (`new` and `edit`) pages.
|
||||
FORM_ATTRIBUTES = [
|
||||
:title,
|
||||
:body,
|
||||
:website_url,
|
||||
:media_url,
|
||||
:itunes_url,
|
||||
:social_image,
|
||||
:duration_in_seconds,
|
||||
:published_at,
|
||||
]
|
||||
FORM_ATTRIBUTES = %i[
|
||||
title
|
||||
body
|
||||
website_url
|
||||
media_url
|
||||
itunes_url
|
||||
social_image
|
||||
duration_in_seconds
|
||||
published_at
|
||||
].freeze
|
||||
|
||||
# Overwrite this method to customize how podcast episodes are displayed
|
||||
# across all pages of the admin dashboard.
|
||||
|
|
|
|||
|
|
@ -23,34 +23,34 @@ class ReactionDashboard < Administrate::BaseDashboard
|
|||
#
|
||||
# By default, it's limited to four items to reduce clutter on index pages.
|
||||
# Feel free to add, remove, or rearrange items.
|
||||
COLLECTION_ATTRIBUTES = [
|
||||
:reactable,
|
||||
:user,
|
||||
:id,
|
||||
:category,
|
||||
COLLECTION_ATTRIBUTES = %i[
|
||||
reactable
|
||||
user
|
||||
id
|
||||
category
|
||||
].freeze
|
||||
|
||||
# SHOW_PAGE_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's show page.
|
||||
SHOW_PAGE_ATTRIBUTES = [
|
||||
:reactable,
|
||||
:user,
|
||||
:user_id,
|
||||
:id,
|
||||
:category,
|
||||
:points,
|
||||
:created_at,
|
||||
:updated_at,
|
||||
SHOW_PAGE_ATTRIBUTES = %i[
|
||||
reactable
|
||||
user
|
||||
user_id
|
||||
id
|
||||
category
|
||||
points
|
||||
created_at
|
||||
updated_at
|
||||
].freeze
|
||||
|
||||
# FORM_ATTRIBUTES
|
||||
# an array of attributes that will be displayed
|
||||
# on the model's form (`new` and `edit`) pages.
|
||||
FORM_ATTRIBUTES = [
|
||||
:reactable,
|
||||
:user_id,
|
||||
:category,
|
||||
:points,
|
||||
FORM_ATTRIBUTES = %i[
|
||||
reactable
|
||||
user_id
|
||||
category
|
||||
points
|
||||
].freeze
|
||||
|
||||
# Overwrite this method to customize how reactions are displayed
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class TagDashboard < Administrate::BaseDashboard
|
|||
text_color_hex: Field::String,
|
||||
alias_for: Field::String,
|
||||
keywords_for_search: Field::String,
|
||||
taggings_count: Field::Number
|
||||
taggings_count: Field::Number,
|
||||
}.freeze
|
||||
|
||||
# COLLECTION_ATTRIBUTES
|
||||
|
|
@ -35,58 +35,58 @@ class TagDashboard < Administrate::BaseDashboard
|
|||
#
|
||||
# By default, it's limited to five items to reduce clutter on index pages.
|
||||
# Feel free to add, remove, or rearrange items.
|
||||
COLLECTION_ATTRIBUTES = [
|
||||
:id,
|
||||
:name,
|
||||
:supported,
|
||||
:alias_for,
|
||||
:taggings_count
|
||||
COLLECTION_ATTRIBUTES = %i[
|
||||
id
|
||||
name
|
||||
supported
|
||||
alias_for
|
||||
taggings_count
|
||||
].freeze
|
||||
|
||||
# SHOW_PAGE_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's show page.
|
||||
SHOW_PAGE_ATTRIBUTES = [
|
||||
:id,
|
||||
:name,
|
||||
:supported,
|
||||
:tag_moderator_ids,
|
||||
:alias_for,
|
||||
:wiki_body_markdown,
|
||||
:wiki_body_html,
|
||||
:rules_markdown,
|
||||
:rules_html,
|
||||
:short_summary,
|
||||
:requires_approval,
|
||||
:submission_template,
|
||||
:submission_rules_headsup,
|
||||
:pretty_name,
|
||||
:profile_image,
|
||||
:social_image,
|
||||
:bg_color_hex,
|
||||
:text_color_hex,
|
||||
:keywords_for_search
|
||||
SHOW_PAGE_ATTRIBUTES = %i[
|
||||
id
|
||||
name
|
||||
supported
|
||||
tag_moderator_ids
|
||||
alias_for
|
||||
wiki_body_markdown
|
||||
wiki_body_html
|
||||
rules_markdown
|
||||
rules_html
|
||||
short_summary
|
||||
requires_approval
|
||||
submission_template
|
||||
submission_rules_headsup
|
||||
pretty_name
|
||||
profile_image
|
||||
social_image
|
||||
bg_color_hex
|
||||
text_color_hex
|
||||
keywords_for_search
|
||||
].freeze
|
||||
|
||||
# FORM_ATTRIBUTES
|
||||
# an array of attributes that will be displayed
|
||||
# on the model's form (`new` and `edit`) pages.
|
||||
FORM_ATTRIBUTES = [
|
||||
:name,
|
||||
:supported,
|
||||
:tag_moderator_ids,
|
||||
:alias_for,
|
||||
:wiki_body_markdown,
|
||||
:rules_markdown,
|
||||
:short_summary,
|
||||
:requires_approval,
|
||||
:submission_template,
|
||||
:submission_rules_headsup,
|
||||
:pretty_name,
|
||||
:profile_image,
|
||||
:social_image,
|
||||
:bg_color_hex,
|
||||
:text_color_hex,
|
||||
:keywords_for_search
|
||||
FORM_ATTRIBUTES = %i[
|
||||
name
|
||||
supported
|
||||
tag_moderator_ids
|
||||
alias_for
|
||||
wiki_body_markdown
|
||||
rules_markdown
|
||||
short_summary
|
||||
requires_approval
|
||||
submission_template
|
||||
submission_rules_headsup
|
||||
pretty_name
|
||||
profile_image
|
||||
social_image
|
||||
bg_color_hex
|
||||
text_color_hex
|
||||
keywords_for_search
|
||||
].freeze
|
||||
|
||||
# Overwrite this method to customize how tags are displayed
|
||||
|
|
|
|||
|
|
@ -53,17 +53,17 @@ class UserDashboard < Administrate::BaseDashboard
|
|||
#
|
||||
# By default, it's limited to four items to reduce clutter on index pages.
|
||||
# Feel free to add, remove, or rearrange items.
|
||||
COLLECTION_ATTRIBUTES = [
|
||||
:profile_image,
|
||||
:id,
|
||||
:created_at,
|
||||
:username,
|
||||
:name,
|
||||
:twitter_username,
|
||||
:github_username,
|
||||
:following_tags_count,
|
||||
:saw_onboarding,
|
||||
:monthly_dues,
|
||||
COLLECTION_ATTRIBUTES = %i[
|
||||
profile_image
|
||||
id
|
||||
created_at
|
||||
username
|
||||
name
|
||||
twitter_username
|
||||
github_username
|
||||
following_tags_count
|
||||
saw_onboarding
|
||||
monthly_dues
|
||||
].freeze
|
||||
|
||||
# SHOW_PAGE_ATTRIBUTES
|
||||
|
|
@ -73,28 +73,28 @@ class UserDashboard < Administrate::BaseDashboard
|
|||
# FORM_ATTRIBUTES
|
||||
# an array of attributes that will be displayed
|
||||
# on the model's form (`new` and `edit`) pages.
|
||||
FORM_ATTRIBUTES = [
|
||||
:organization,
|
||||
:name,
|
||||
:username,
|
||||
:twitter_username,
|
||||
:github_username,
|
||||
:profile_image,
|
||||
:org_admin,
|
||||
:banned,
|
||||
:reason_for_ban,
|
||||
:warned,
|
||||
:reason_for_warning,
|
||||
:trusted,
|
||||
:scholar,
|
||||
:analytics,
|
||||
:summary,
|
||||
:website_url,
|
||||
:bg_color_hex,
|
||||
:text_color_hex,
|
||||
:reputation_modifier,
|
||||
:feed_url,
|
||||
:saw_onboarding,
|
||||
FORM_ATTRIBUTES = %i[
|
||||
organization
|
||||
name
|
||||
username
|
||||
twitter_username
|
||||
github_username
|
||||
profile_image
|
||||
org_admin
|
||||
banned
|
||||
reason_for_ban
|
||||
warned
|
||||
reason_for_warning
|
||||
trusted
|
||||
scholar
|
||||
analytics
|
||||
summary
|
||||
website_url
|
||||
bg_color_hex
|
||||
text_color_hex
|
||||
reputation_modifier
|
||||
feed_url
|
||||
saw_onboarding
|
||||
].freeze
|
||||
|
||||
# Overwrite this method to customize how users are displayed
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class ArticleDecorator < ApplicationDecorator
|
|||
end
|
||||
end
|
||||
|
||||
def internal_utm_params(place="additional_box")
|
||||
def internal_utm_params(place = "additional_box")
|
||||
campaign = if boosted_additional_articles
|
||||
"#{organization&.slug}_boosted"
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
class OrganizationDecorator < ApplicationDecorator
|
||||
delegate_all
|
||||
|
||||
|
||||
def darker_color(adjustment = 0.88)
|
||||
HexComparer.new([enriched_colors[:bg], enriched_colors[:text]]).brightness(adjustment)
|
||||
end
|
||||
|
|
@ -9,12 +9,12 @@ class OrganizationDecorator < ApplicationDecorator
|
|||
if bg_color_hex.blank?
|
||||
{
|
||||
bg: assigned_color[:bg],
|
||||
text: assigned_color[:text]
|
||||
text: assigned_color[:text],
|
||||
}
|
||||
else
|
||||
{
|
||||
bg: bg_color_hex || assigned_color[:bg],
|
||||
text: text_color_hex || assigned_color[:text]
|
||||
text: text_color_hex || assigned_color[:text],
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
@ -22,7 +22,7 @@ class OrganizationDecorator < ApplicationDecorator
|
|||
def assigned_color
|
||||
{
|
||||
bg: "#0a0a0a",
|
||||
text: "#ffffff"
|
||||
text: "#ffffff",
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,59 +15,59 @@ class UserDecorator < ApplicationDecorator
|
|||
if bg_color_hex.blank?
|
||||
{
|
||||
bg: assigned_color[:bg],
|
||||
text: assigned_color[:text]
|
||||
text: assigned_color[:text],
|
||||
}
|
||||
else
|
||||
{
|
||||
bg: bg_color_hex || assigned_color[:bg],
|
||||
text: text_color_hex || assigned_color[:text]
|
||||
text: text_color_hex || assigned_color[:text],
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def assigned_color
|
||||
colors = [
|
||||
{
|
||||
bg: "#093656",
|
||||
text: "#ffffff"
|
||||
},
|
||||
{
|
||||
bg: "#19063A",
|
||||
text: "#dce9f3"
|
||||
},
|
||||
{
|
||||
bg: "#0D4D4B",
|
||||
text: "#fdf9f3"
|
||||
},
|
||||
{
|
||||
bg: "#61122f",
|
||||
text: "#ffffff"
|
||||
},
|
||||
{
|
||||
bg: "#edebf6",
|
||||
text:" #070126"
|
||||
},
|
||||
{
|
||||
bg: "#080E3B",
|
||||
text: "#ffffff"
|
||||
},
|
||||
{
|
||||
bg: "#010C1F",
|
||||
text: "#aebcd5"
|
||||
},
|
||||
{
|
||||
bg: "#d7dee2",
|
||||
text: "#022235"
|
||||
},
|
||||
{
|
||||
bg: "#161616",
|
||||
text: "#66e2d5"
|
||||
},
|
||||
{
|
||||
bg: "#1c0bba",
|
||||
text: "#c9d2dd"
|
||||
},
|
||||
]
|
||||
{
|
||||
bg: "#093656",
|
||||
text: "#ffffff",
|
||||
},
|
||||
{
|
||||
bg: "#19063A",
|
||||
text: "#dce9f3",
|
||||
},
|
||||
{
|
||||
bg: "#0D4D4B",
|
||||
text: "#fdf9f3",
|
||||
},
|
||||
{
|
||||
bg: "#61122f",
|
||||
text: "#ffffff",
|
||||
},
|
||||
{
|
||||
bg: "#edebf6",
|
||||
text: " #070126",
|
||||
},
|
||||
{
|
||||
bg: "#080E3B",
|
||||
text: "#ffffff",
|
||||
},
|
||||
{
|
||||
bg: "#010C1F",
|
||||
text: "#aebcd5",
|
||||
},
|
||||
{
|
||||
bg: "#d7dee2",
|
||||
text: "#022235",
|
||||
},
|
||||
{
|
||||
bg: "#161616",
|
||||
text: "#66e2d5",
|
||||
},
|
||||
{
|
||||
bg: "#1c0bba",
|
||||
text: "#c9d2dd",
|
||||
},
|
||||
]
|
||||
colors[id % 10]
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ module ApplicationHelper
|
|||
controller_name == "users" ||
|
||||
controller_name == "pages" ||
|
||||
controller_name == "chat_channels" ||
|
||||
controller_name == "dashboards"||
|
||||
controller_name == "moderations"||
|
||||
controller_name == "videos"||
|
||||
controller_name == "badges"||
|
||||
controller_name == "dashboards" ||
|
||||
controller_name == "moderations" ||
|
||||
controller_name == "videos" ||
|
||||
controller_name == "badges" ||
|
||||
controller_name == "stories" ||
|
||||
controller_name == "comments" ||
|
||||
controller_name == "notifications" ||
|
||||
|
|
@ -36,16 +36,16 @@ module ApplicationHelper
|
|||
|
||||
def title(page_title)
|
||||
derived_title = if page_title.include?("DEV")
|
||||
page_title
|
||||
else
|
||||
page_title + " - DEV Community 👩💻👨💻"
|
||||
page_title
|
||||
else
|
||||
page_title + " - DEV Community 👩💻👨💻"
|
||||
end
|
||||
content_for(:title){ derived_title }
|
||||
content_for(:title) { derived_title }
|
||||
derived_title
|
||||
end
|
||||
|
||||
def icon(name, pixels = "20")
|
||||
image_tag icon_url(name), alt: name, class:"icon-img", height: pixels, width: pixels
|
||||
image_tag icon_url(name), alt: name, class: "icon-img", height: pixels, width: pixels
|
||||
end
|
||||
|
||||
def icon_url(name)
|
||||
|
|
@ -66,11 +66,11 @@ module ApplicationHelper
|
|||
end
|
||||
end
|
||||
|
||||
def cloudinary(url, width = nil, quality = 80, format = "jpg")
|
||||
def cloudinary(url, width = nil, _quality = 80, _format = "jpg")
|
||||
if Rails.env.development? && (url.blank? || !url.include?("http"))
|
||||
return url
|
||||
end
|
||||
if url && url.size.positive?
|
||||
if url&.size&.positive?
|
||||
if width
|
||||
"https://res.cloudinary.com/practicaldev/image/fetch/c_scale,fl_progressive,q_auto,w_#{width}/f_auto/#{url}"
|
||||
else
|
||||
|
|
@ -121,7 +121,7 @@ module ApplicationHelper
|
|||
def tag_colors(tag)
|
||||
Rails.cache.fetch("view-helper-#{tag}/tag_colors", expires_in: 5.hours) do
|
||||
if found_tag = Tag.find_by_name(tag)
|
||||
{ background: found_tag.bg_color_hex,color: found_tag.text_color_hex }
|
||||
{ background: found_tag.bg_color_hex, color: found_tag.text_color_hex }
|
||||
else
|
||||
{ background: "#d6d9e0", color: "#606570" }
|
||||
end
|
||||
|
|
@ -130,7 +130,7 @@ module ApplicationHelper
|
|||
|
||||
def beautified_url(url)
|
||||
url.sub(/^((http[s]?|ftp):\/)?\//, "").sub(/\?.*/, "").chomp("/")
|
||||
rescue
|
||||
rescue StandardError
|
||||
url
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
module ArticlesHelper
|
||||
|
||||
def hasVid(article)
|
||||
article.processed_html.include?("youtube.com/embed/") || article.processed_html.include?("player.vimeo.com") || article.comments_blob.include?("youtube")
|
||||
end
|
||||
|
||||
def collection_link_class(current_article,linked_article)
|
||||
if (current_article.id == linked_article.id)
|
||||
def collection_link_class(current_article, linked_article)
|
||||
if current_article.id == linked_article.id
|
||||
"current-article"
|
||||
elsif !linked_article.published
|
||||
"coming-soon"
|
||||
|
|
@ -14,15 +13,15 @@ module ArticlesHelper
|
|||
|
||||
def image_tag_or_inline_svg(service_name)
|
||||
if is_internal_navigation?
|
||||
image_tag("#{service_name}-logo.svg", class:"icon-img")
|
||||
image_tag("#{service_name}-logo.svg", class: "icon-img")
|
||||
else
|
||||
inline_svg("#{service_name}-logo.svg", class:"icon-img")
|
||||
inline_svg("#{service_name}-logo.svg", class: "icon-img")
|
||||
end
|
||||
end
|
||||
|
||||
def should_show_updated_on?(article)
|
||||
article.edited_at &&
|
||||
article.published &&
|
||||
article.published &&
|
||||
!article.published_from_feed &&
|
||||
article.published_at.next_day < article.edited_at
|
||||
end
|
||||
|
|
@ -42,7 +41,7 @@ module ArticlesHelper
|
|||
host.start_with?("www.") ? host[4..-1] : host
|
||||
end
|
||||
|
||||
def is_hiring_form?(tag,article)
|
||||
def is_hiring_form?(tag, article)
|
||||
tag.to_s == "hiring" || article.tag_list.include?("hiring")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ module BadgeRewarder
|
|||
achievement = BadgeAchievement.create(
|
||||
user_id: user.id,
|
||||
badge_id: 2,
|
||||
rewarding_context_message_markdown: message)
|
||||
rewarding_context_message_markdown: message,
|
||||
)
|
||||
user.save if achievement.valid?
|
||||
# ID 2 is the proper ID in prod. We should change in future to ENV var.
|
||||
end
|
||||
|
|
@ -17,7 +18,8 @@ module BadgeRewarder
|
|||
achievement = BadgeAchievement.create(
|
||||
user_id: comment.user_id,
|
||||
badge_id: 3,
|
||||
rewarding_context_message_markdown: message)
|
||||
rewarding_context_message_markdown: message,
|
||||
)
|
||||
comment.user.save if achievement.valid?
|
||||
# ID 3 is the proper ID in prod. We should change in future to ENV var.
|
||||
end
|
||||
|
|
@ -28,7 +30,8 @@ module BadgeRewarder
|
|||
BadgeAchievement.create(
|
||||
user_id: user.id,
|
||||
badge_id: Badge.find_by_slug("top-7").id,
|
||||
rewarding_context_message_markdown: "Congrats!!!")
|
||||
rewarding_context_message_markdown: "Congrats!!!",
|
||||
)
|
||||
user.save
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
class CacheBuster
|
||||
|
||||
def bust(path)
|
||||
return unless Rails.env.production?
|
||||
request = HTTParty.post("https://api.fastly.com/purge/https://dev.to#{path}",
|
||||
:headers => { 'Fastly-Key' => 'f15066a3abedf47238b08e437684c84f' } )
|
||||
headers: { "Fastly-Key" => "f15066a3abedf47238b08e437684c84f" })
|
||||
request = HTTParty.post("https://api.fastly.com/purge/https://dev.to#{path}?i=i",
|
||||
:headers => { 'Fastly-Key' => 'f15066a3abedf47238b08e437684c84f' } )
|
||||
return request
|
||||
headers: { "Fastly-Key" => "f15066a3abedf47238b08e437684c84f" })
|
||||
request
|
||||
end
|
||||
|
||||
def bust_comment(comment)
|
||||
|
|
@ -22,10 +21,10 @@ class CacheBuster
|
|||
bust("?i=i")
|
||||
end
|
||||
bust("#{comment.commentable.path}/comments/")
|
||||
bust("#{comment.commentable.path}")
|
||||
bust(comment.commentable.path.to_s)
|
||||
comment.commentable.comments.each do |c|
|
||||
bust(c.path)
|
||||
bust(c.path+"?i=i")
|
||||
bust(c.path + "?i=i")
|
||||
end
|
||||
bust("#{comment.commentable.path}/comments/*")
|
||||
bust("/#{comment.user.username}")
|
||||
|
|
@ -50,10 +49,8 @@ class CacheBuster
|
|||
bust("/api/articles/#{article.id}")
|
||||
bust("/api/articles/by_path?url=#{article.path}")
|
||||
|
||||
if article.collection
|
||||
article.collection.articles.each do |a|
|
||||
bust(a.path)
|
||||
end
|
||||
article.collection&.articles&.each do |a|
|
||||
bust(a.path)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -62,7 +59,7 @@ class CacheBuster
|
|||
bust("/")
|
||||
bust("?i=i")
|
||||
end
|
||||
[[1.week.ago, "week"],[1.month.ago, "month"],[1.year.ago, "year"],[5.years.ago, "infinity"]].each do |timeframe|
|
||||
[[1.week.ago, "week"], [1.month.ago, "month"], [1.year.ago, "year"], [5.years.ago, "infinity"]].each do |timeframe|
|
||||
if Article.where(published: true).where("published_at > ?", timeframe[0]).
|
||||
order("positive_reactions_count DESC").limit(4).pluck(:id).include?(article.id)
|
||||
bust("/top/#{timeframe[1]}")
|
||||
|
|
@ -88,7 +85,7 @@ class CacheBuster
|
|||
bust("/t/#{tag}/latest")
|
||||
bust("/t/#{tag}/latest?i=i")
|
||||
end
|
||||
[[1.week.ago, "week"],[1.month.ago, "month"],[1.year.ago, "year"],[5.years.ago, "infinity"]].
|
||||
[[1.week.ago, "week"], [1.month.ago, "month"], [1.year.ago, "year"], [5.years.ago, "infinity"]].
|
||||
each do |timeframe|
|
||||
if Article.where(published: true).where("published_at > ?", timeframe[0]).tagged_with(tag).
|
||||
order("positive_reactions_count DESC").limit(3).pluck(:id).include?(article.id)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class ColorFromImage
|
||||
|
||||
def initialize(url)
|
||||
@url = url
|
||||
end
|
||||
|
|
@ -8,19 +7,17 @@ class ColorFromImage
|
|||
return "#000000" unless Rails.env.production?
|
||||
begin
|
||||
get_palette["colors"][0]["hex"]
|
||||
rescue
|
||||
rescue StandardError
|
||||
"#dddddd"
|
||||
end
|
||||
end
|
||||
|
||||
def get_palette
|
||||
input = {
|
||||
url: @url
|
||||
url: @url,
|
||||
}
|
||||
client = Algorithmia.client(ApplicationConfig["ALGORITHMIA_KEY"])
|
||||
algo = client.algo('vagrant/ColorSchemeExtraction/0.2.0')
|
||||
algo = client.algo("vagrant/ColorSchemeExtraction/0.2.0")
|
||||
algo.pipe(input).result
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class ErrorMessageCleaner
|
||||
|
||||
attr_accessor :error_message
|
||||
|
||||
def initialize(error_message)
|
||||
|
|
@ -13,5 +12,4 @@ class ErrorMessageCleaner
|
|||
error_message
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class FollowChecker
|
||||
|
||||
attr_accessor :follower, :followable_type, :followable_id
|
||||
|
||||
def initialize(follower, followable_type, followable_id)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class HexComparer
|
||||
|
||||
attr_accessor :hexes, :amount
|
||||
def initialize(hexes, amount = 1)
|
||||
@hexes = hexes
|
||||
|
|
@ -19,32 +18,29 @@ class HexComparer
|
|||
end
|
||||
|
||||
def brightness(amount = 1)
|
||||
begin
|
||||
rgb = smallest.gsub("#","").scan(/../).map(&:hex).map{ |color| color * amount }.map(&:round)
|
||||
"#%02x%02x%02x" % rgb
|
||||
rescue
|
||||
smallest
|
||||
end
|
||||
rgb = smallest.gsub("#", "").scan(/../).map(&:hex).map { |color| color * amount }.map(&:round)
|
||||
"#%02x%02x%02x" % rgb
|
||||
rescue StandardError
|
||||
smallest
|
||||
end
|
||||
|
||||
def accent()
|
||||
if brightness(1.14 ** amount).size == 7
|
||||
brightness(1.14 ** amount)
|
||||
elsif brightness(1.08 ** amount).size == 7
|
||||
brightness(1.08 ** amount)
|
||||
elsif brightness(1.06 ** amount).size == 7
|
||||
brightness(1.06 ** amount)
|
||||
elsif brightness(0.96 ** amount).size == 7
|
||||
brightness(0.96 ** amount)
|
||||
elsif brightness(0.9 ** amount).size == 7
|
||||
brightness(0.9 ** amount)
|
||||
elsif brightness(0.8 ** amount).size == 7
|
||||
brightness(0.8 ** amount)
|
||||
elsif brightness(0.7 ** amount).size == 7
|
||||
brightness(0.7 ** amount)
|
||||
elsif brightness(0.6 ** amount).size == 7
|
||||
brightness(0.6 ** amount)
|
||||
def accent
|
||||
if brightness(1.14**amount).size == 7
|
||||
brightness(1.14**amount)
|
||||
elsif brightness(1.08**amount).size == 7
|
||||
brightness(1.08**amount)
|
||||
elsif brightness(1.06**amount).size == 7
|
||||
brightness(1.06**amount)
|
||||
elsif brightness(0.96**amount).size == 7
|
||||
brightness(0.96**amount)
|
||||
elsif brightness(0.9**amount).size == 7
|
||||
brightness(0.9**amount)
|
||||
elsif brightness(0.8**amount).size == 7
|
||||
brightness(0.8**amount)
|
||||
elsif brightness(0.7**amount).size == 7
|
||||
brightness(0.7**amount)
|
||||
elsif brightness(0.6**amount).size == 7
|
||||
brightness(0.6**amount)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
class HtmlCleaner
|
||||
|
||||
def clean_html(html)
|
||||
doc = Nokogiri::HTML(html)
|
||||
# Remove Medium tracking pixel
|
||||
doc.css("img").each do |img|
|
||||
if img.attr('src') && (img.attr('src').include? "medium.com/_/stat")
|
||||
if img.attr("src") && (img.attr("src").include? "medium.com/_/stat")
|
||||
img.remove
|
||||
end
|
||||
end
|
||||
|
|
@ -15,13 +14,11 @@ class HtmlCleaner
|
|||
end
|
||||
end
|
||||
|
||||
doc.css('figure').each do |el|
|
||||
el.name = 'p'
|
||||
doc.css("figure").each do |el|
|
||||
el.name = "p"
|
||||
end
|
||||
|
||||
doc.xpath('//@class').remove
|
||||
doc.xpath("//@class").remove
|
||||
doc.to_html
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,22 +1,19 @@
|
|||
class LanguageDetector
|
||||
|
||||
def initialize(article)
|
||||
@article = article
|
||||
end
|
||||
|
||||
def detect
|
||||
begin
|
||||
response = get_language
|
||||
response["result"] if response["confidence"] > 0.8
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
response = get_language
|
||||
response["result"] if response["confidence"] > 0.8
|
||||
rescue StandardError
|
||||
nil
|
||||
end
|
||||
|
||||
def get_language
|
||||
return { "result" => "en", "confidence" => 0.9 } unless Rails.env.production?
|
||||
client = Algorithmia.client(ApplicationConfig["ALGORITHMIA_KEY"])
|
||||
algo = client.algo('miguelher/LanguageDetector/0.1.0')
|
||||
algo = client.algo("miguelher/LanguageDetector/0.1.0")
|
||||
algo.pipe(text).result
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class MarkdownParser
|
|||
renderer = Redcarpet::Render::HTMLRouge.new(hard_wrap: true, filter_html: false)
|
||||
markdown = Redcarpet::Markdown.new(renderer, REDCARPET_CONFIG)
|
||||
tag_whitelist = %w(strong em p h1 h2 h3 h4 h5 h6 i u b code pre
|
||||
br ul ol li small sup sub img a span hr blockquote)
|
||||
br ul ol li small sup sub img a span hr blockquote)
|
||||
attribute_whitelist = %w(href strong em ref rel src title alt class)
|
||||
ActionController::Base.helpers.sanitize markdown.render(@content).html_safe,
|
||||
tags: tag_whitelist,
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
class NotificationCounter
|
||||
|
||||
def initialize(user)
|
||||
@user = user
|
||||
end
|
||||
|
||||
def unread_notification_count
|
||||
return 0 if Rails.env.test?
|
||||
StreamRails.feed_manager.get_notification_feed(@user.id).get['unseen']
|
||||
StreamRails.feed_manager.get_notification_feed(@user.id).get["unseen"]
|
||||
end
|
||||
|
||||
def set_to_zero
|
||||
StreamRails.feed_manager.get_notification_feed(@user.id).get(mark_seen:true)
|
||||
StreamRails.feed_manager.get_notification_feed(@user.id).get(mark_seen: true)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ class PodcastFeed
|
|||
update_existing_episode(ep, item, podcast)
|
||||
end
|
||||
end
|
||||
return feed.items.size
|
||||
rescue => e
|
||||
feed.items.size
|
||||
rescue StandardError => e
|
||||
puts e.message
|
||||
end
|
||||
|
||||
|
|
@ -36,19 +36,19 @@ class PodcastFeed
|
|||
get_media_url(ep, item, podcast)
|
||||
begin
|
||||
ep.published_at = item.pubDate.to_date
|
||||
rescue
|
||||
rescue StandardError
|
||||
puts "not valid date"
|
||||
end
|
||||
ep.body = item.content_encoded || item.itunes_summary || item.description
|
||||
ep.save!
|
||||
end
|
||||
|
||||
def update_existing_episode(ep, item, podcast)
|
||||
def update_existing_episode(ep, item, _podcast)
|
||||
if ep.published_at == nil
|
||||
begin
|
||||
ep.published_at = item.pubDate.to_date
|
||||
ep.save
|
||||
rescue
|
||||
rescue StandardError
|
||||
puts "not valid date"
|
||||
end
|
||||
end
|
||||
|
|
@ -65,12 +65,12 @@ class PodcastFeed
|
|||
|
||||
def get_media_url(ep, item, podcast)
|
||||
ep.media_url = if Rails.env.test? ||
|
||||
open(item.enclosure.url.gsub(/http:/, "https:")).status[0] == "200"
|
||||
open(item.enclosure.url.gsub(/http:/, "https:")).status[0] == "200"
|
||||
item.enclosure.url.gsub(/http:/, "https:")
|
||||
else
|
||||
item.enclosure.url
|
||||
end
|
||||
rescue
|
||||
rescue StandardError
|
||||
# podcast episode must have a media_url
|
||||
ep.media_url = item.enclosure.url
|
||||
if podcast.status_notice.empty?
|
||||
|
|
@ -80,12 +80,12 @@ class PodcastFeed
|
|||
|
||||
def update_media_url(ep, item)
|
||||
if ep.media_url.include?("https")
|
||||
return
|
||||
nil
|
||||
elsif !ep.media_url.include?("https") &&
|
||||
item.enclosure.url.include?("https")
|
||||
ep.update!(media_url: item.enclosure.url)
|
||||
end
|
||||
rescue
|
||||
rescue StandardError
|
||||
logger.info "something went wrong with #{podcast.title}, #{ep.title} -- #{ep.media_url}"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,16 +6,16 @@ class RateLimitChecker
|
|||
|
||||
def limit_by_situation(situation)
|
||||
result = false
|
||||
case situation
|
||||
when "comment_creation"
|
||||
result = user.comments.where("created_at > ?", 30.seconds.ago).size > 9
|
||||
when "published_article_creation"
|
||||
result = user.articles.
|
||||
where(published: true).
|
||||
where("created_at > ?", 30.seconds.ago).size > 9
|
||||
else
|
||||
result = false
|
||||
end
|
||||
result = case situation
|
||||
when "comment_creation"
|
||||
user.comments.where("created_at > ?", 30.seconds.ago).size > 9
|
||||
when "published_article_creation"
|
||||
user.articles.
|
||||
where(published: true).
|
||||
where("created_at > ?", 30.seconds.ago).size > 9
|
||||
else
|
||||
false
|
||||
end
|
||||
ping_admins if result == true
|
||||
result
|
||||
end
|
||||
|
|
@ -29,7 +29,7 @@ class RateLimitChecker
|
|||
def ping_admins
|
||||
return unless user
|
||||
SlackBot.ping(
|
||||
"Rate limit exceeded. https://dev.to#{user.path}",
|
||||
"Rate limit exceeded. https://dev.to#{user.path}",
|
||||
channel: "abuse-reports",
|
||||
username: "rate_limit",
|
||||
icon_emoji: ":hand:",
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ class ReactionImage
|
|||
|
||||
def path
|
||||
images = {
|
||||
'like' => 'emoji/emoji-one-heart.png',
|
||||
'unicorn' => 'emoji/emoji-one-unicorn.png',
|
||||
'hands' => 'emoji/emoji-one-hands.png',
|
||||
'thinking' => 'emoji/emoji-one-thinking.png',
|
||||
'readinglist' => 'emoji/emoji-one-bookmark.png'
|
||||
"like" => "emoji/emoji-one-heart.png",
|
||||
"unicorn" => "emoji/emoji-one-unicorn.png",
|
||||
"hands" => "emoji/emoji-one-hands.png",
|
||||
"thinking" => "emoji/emoji-one-thinking.png",
|
||||
"readinglist" => "emoji/emoji-one-bookmark.png",
|
||||
}.freeze
|
||||
images[category]
|
||||
end
|
||||
|
|
|
|||
|
|
@ -29,4 +29,4 @@ class ReadingList
|
|||
def reaction_criteria
|
||||
{ user_id: user.id, reactable_type: "Article", category: "readinglist" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class Timeframer
|
||||
|
||||
attr_accessor :timeframe
|
||||
def initialize(timeframe)
|
||||
@timeframe = timeframe
|
||||
|
|
@ -18,5 +17,4 @@ class Timeframer
|
|||
"latest"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class TwilioToken
|
|||
api_key,
|
||||
api_secret,
|
||||
[],
|
||||
identity: user.id
|
||||
identity: user.id,
|
||||
)
|
||||
|
||||
grant = Twilio::JWT::AccessToken::VideoGrant.new
|
||||
|
|
@ -25,5 +25,4 @@ class TwilioToken
|
|||
|
||||
token.to_jwt
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,13 +7,11 @@ class UnreadNotificationsEmailer
|
|||
# We can change this up later.
|
||||
users = User.where("comments_count > ? OR reactions_count > ?", 0, 0).order("RANDOM()").limit(num)
|
||||
users.find_each do |user|
|
||||
begin
|
||||
UnreadNotificationsEmailer.new(user).send_email_if_appropriate
|
||||
rescue => e
|
||||
logger = Logger.new(STDOUT)
|
||||
logger = Airbrake::AirbrakeLogger.new(logger)
|
||||
logger.error(e)
|
||||
end
|
||||
UnreadNotificationsEmailer.new(user).send_email_if_appropriate
|
||||
rescue StandardError => e
|
||||
logger = Logger.new(STDOUT)
|
||||
logger = Airbrake::AirbrakeLogger.new(logger)
|
||||
logger.error(e)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -56,7 +54,7 @@ class UnreadNotificationsEmailer
|
|||
|
||||
def last_email_sent_after(time)
|
||||
last_email = user.email_messages.last
|
||||
time_check = last_email && last_email.sent_at && (last_email.sent_at > time)
|
||||
time_check = last_email&.sent_at && (last_email.sent_at > time)
|
||||
time_check.present?
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -19,26 +19,26 @@ class UserStates
|
|||
end
|
||||
|
||||
def made_first_article
|
||||
user.articles.where(published:true).size > 0
|
||||
!user.articles.where(published: true).empty?
|
||||
end
|
||||
|
||||
def follows_a_tag
|
||||
user.follows.where(followable_type:"ActsAsTaggableOn::Tag").size > 0
|
||||
!user.follows.where(followable_type: "ActsAsTaggableOn::Tag").empty?
|
||||
end
|
||||
|
||||
def fill_out_your_profile
|
||||
user.summary.present? && user.summary.size > 0
|
||||
user.summary.present? && !user.summary.empty?
|
||||
end
|
||||
|
||||
def leave_reactions
|
||||
user.reactions.size > 0
|
||||
!user.reactions.empty?
|
||||
end
|
||||
|
||||
def follow_people
|
||||
user.follows.where(followable_type:"User").size > 0
|
||||
!user.follows.where(followable_type: "User").empty?
|
||||
end
|
||||
|
||||
def leave_comments
|
||||
user.comments.size > 0
|
||||
!user.comments.empty?
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ class CodepenTag < LiquidTagBase
|
|||
@height = 600
|
||||
end
|
||||
|
||||
def render(context)
|
||||
def render(_context)
|
||||
html = <<-HTML
|
||||
<iframe height="#{@height}"
|
||||
src="#{@link}?height=500&default-tab=result&embed-version=2"
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
class CommentTag < LiquidTagBase
|
||||
attr_reader :id_code, :comment
|
||||
|
||||
def initialize(tag_name, id_code, tokens)
|
||||
def initialize(_tag_name, id_code, _tokens)
|
||||
@id_code = parse_id(id_code)
|
||||
@comment = find_comment
|
||||
end
|
||||
|
||||
def render(context)
|
||||
def render(_context)
|
||||
raise_error unless @comment
|
||||
commentable = if @comment.commentable_type == "Article"
|
||||
Article.find_by_id(@comment.commentable_id)
|
||||
|
|
@ -14,7 +14,7 @@ class CommentTag < LiquidTagBase
|
|||
PodcastEpisode.find_by_id(@comment.commentable_id)
|
||||
end
|
||||
|
||||
html = '' \
|
||||
html = "" \
|
||||
"<div class=\"liquid-comment\">" \
|
||||
"<div class=\"details\">" \
|
||||
"<a href=\"/#{@comment.user.username}\">" \
|
||||
|
|
@ -29,29 +29,29 @@ class CommentTag < LiquidTagBase
|
|||
"</div>" \
|
||||
"</div>" \
|
||||
"<div class=\"body\">" \
|
||||
+ @comment.processed_html.html_safe+ \
|
||||
+ @comment.processed_html.html_safe + \
|
||||
"</div>" \
|
||||
"</div>"
|
||||
end
|
||||
|
||||
def render_twitter_and_github
|
||||
result = ''
|
||||
result = ""
|
||||
if @comment.user.twitter_username.present?
|
||||
result += "<a href=\"http://twitter.com/#{@comment.user.twitter_username}\">" \
|
||||
+image_tag('/assets/twitter-logo.svg', class:'icon-img', alt: 'twitter')+ \
|
||||
"</a>"
|
||||
+image_tag("/assets/twitter-logo.svg", class: "icon-img", alt: "twitter") + \
|
||||
"</a>"
|
||||
end
|
||||
if @comment.user.github_username.present?
|
||||
result += "<a href=\"http://github.com/#{@comment.user.github_username}\">" \
|
||||
+image_tag('/assets/github-logo.svg', class:'icon-img', alt: 'github')+ \
|
||||
"</a>"
|
||||
+image_tag("/assets/github-logo.svg", class: "icon-img", alt: "github") + \
|
||||
"</a>"
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def parse_id(id)
|
||||
id_no_space = id.delete(' ')
|
||||
id_no_space = id.delete(" ")
|
||||
raise_error unless valid_id?(id_no_space)
|
||||
id_no_space
|
||||
end
|
||||
|
|
@ -63,11 +63,11 @@ class CommentTag < LiquidTagBase
|
|||
end
|
||||
|
||||
def valid_id?(id)
|
||||
id.length < 10 && !(id !~ /^[a-zA-Z0-9]*$/)
|
||||
id.length < 10 && id =~ /^[a-zA-Z0-9]*$/
|
||||
end
|
||||
|
||||
def raise_error
|
||||
raise StandardError, 'Invalid comment ID or comment does not exist'
|
||||
raise StandardError, "Invalid comment ID or comment does not exist"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class GistTag < LiquidTagBase
|
|||
@link = parse_link(link)
|
||||
end
|
||||
|
||||
def render(context)
|
||||
def render(_context)
|
||||
html = <<~HTML
|
||||
<div class="ltag_gist-liquid-tag">
|
||||
<script id="gist-ltag" src="#{@link}.js"></script>
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ class GithubTag < LiquidTagBase
|
|||
end
|
||||
|
||||
def issue_or_readme
|
||||
if @link.include?('issues')
|
||||
if @link.include?("issues")
|
||||
"issue"
|
||||
else
|
||||
"readme"
|
||||
|
|
@ -16,16 +16,14 @@ class GithubTag < LiquidTagBase
|
|||
end
|
||||
|
||||
def pre_render
|
||||
begin
|
||||
if issue_or_readme == "issue"
|
||||
GithubTag::GithubIssueTag.new(@link).render
|
||||
elsif issue_or_readme == "readme"
|
||||
gt = GithubTag::GithubReadmeTag.new(@link)
|
||||
gt.render
|
||||
end
|
||||
rescue StandardError => e
|
||||
raise StandardError, e.message
|
||||
if issue_or_readme == "issue"
|
||||
GithubTag::GithubIssueTag.new(@link).render
|
||||
elsif issue_or_readme == "readme"
|
||||
gt = GithubTag::GithubReadmeTag.new(@link)
|
||||
gt.render
|
||||
end
|
||||
rescue StandardError => e
|
||||
raise StandardError, e.message
|
||||
end
|
||||
|
||||
def render(*)
|
||||
|
|
|
|||
|
|
@ -19,10 +19,10 @@ class GithubTag
|
|||
username = contentJSON[:user][:login]
|
||||
user_html_url = contentJSON[:user][:html_url]
|
||||
user_avatar_url = contentJSON[:user][:avatar_url]
|
||||
date = Date.parse(contentJSON[:created_at].to_s).strftime('%b %d, %Y')
|
||||
date = Date.parse(contentJSON[:created_at].to_s).strftime("%b %d, %Y")
|
||||
date_link = contentJSON[:html_url]
|
||||
title = generate_title
|
||||
html = '' \
|
||||
html = "" \
|
||||
"<div class=\"ltag_github-liquid-tag\"> "\
|
||||
"#{title}" \
|
||||
"<div class=\"github-thread\"> " \
|
||||
|
|
@ -52,7 +52,7 @@ class GithubTag
|
|||
|
||||
def parse_link(link)
|
||||
link = ActionController::Base.helpers.strip_tags(link)
|
||||
link_no_space = link.delete(' ')
|
||||
link_no_space = link.delete(" ")
|
||||
if valid_link?(link_no_space)
|
||||
generate_api_link(link_no_space)
|
||||
else
|
||||
|
|
@ -61,9 +61,9 @@ class GithubTag
|
|||
end
|
||||
|
||||
def generate_api_link(input)
|
||||
input = input.gsub(/\?.*/, '')
|
||||
if input.include?('#issuecomment-')
|
||||
input = input.gsub(/\d{1,}#issuecomment-/, 'comments/')
|
||||
input = input.gsub(/\?.*/, "")
|
||||
if input.include?("#issuecomment-")
|
||||
input = input.gsub(/\d{1,}#issuecomment-/, "comments/")
|
||||
end
|
||||
"https://api.github.com/repos/#{input.gsub(/.*github\.com\//, '')}"
|
||||
end
|
||||
|
|
@ -76,7 +76,7 @@ class GithubTag
|
|||
return unless title
|
||||
"<h1> " \
|
||||
"<a href=\"#{link}\">" \
|
||||
"<img class=\"github-logo\" src=\"#{ActionController::Base.helpers.asset_path("github-logo.svg")}\" /><span class=\"issue-title\">#{title}</span> <span class=\"issue-number\">##{number}</span> " \
|
||||
"<img class=\"github-logo\" src=\"#{ActionController::Base.helpers.asset_path('github-logo.svg')}\" /><span class=\"issue-title\">#{title}</span> <span class=\"issue-number\">##{number}</span> " \
|
||||
"</a>" \
|
||||
"</h1> "
|
||||
end
|
||||
|
|
@ -88,17 +88,17 @@ class GithubTag
|
|||
end
|
||||
|
||||
def valid_link?(link)
|
||||
link_without_domain = link.gsub(/.*github\.com\//, '').split('/')
|
||||
link_without_domain = link.gsub(/.*github\.com\//, "").split("/")
|
||||
raise_error unless [
|
||||
!(link !~ /.*github\.com\//),
|
||||
!!(link =~ /.*github\.com\//),
|
||||
link_without_domain.length == 4,
|
||||
link_without_domain[3].to_i > 0
|
||||
link_without_domain[3].to_i > 0,
|
||||
].all? { |bool| bool == true }
|
||||
true
|
||||
end
|
||||
|
||||
def raise_error
|
||||
raise StandardError, 'Invalid Github issue link'
|
||||
raise StandardError, "Invalid Github issue link"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class GithubTag
|
|||
<div class="ltag-github-readme-tag">
|
||||
<div class="readme-overview">
|
||||
<h2>
|
||||
<img src="#{ActionController::Base.helpers.asset_path("github-logo.svg")}" /><a href="https://github.com/#{@content.owner.login}">#{@content.owner.login}</a> / <a style="font-weight: 600;" href="#{@content.html_url}">#{@content.name}</a>
|
||||
<img src="#{ActionController::Base.helpers.asset_path('github-logo.svg')}" /><a href="https://github.com/#{@content.owner.login}">#{@content.owner.login}</a> / <a style="font-weight: 600;" href="#{@content.html_url}">#{@content.name}</a>
|
||||
</h2>
|
||||
<h3>#{@content.description}</h3>
|
||||
</div><div class="ltag-github-body">
|
||||
|
|
@ -23,17 +23,16 @@ class GithubTag
|
|||
|
||||
def parse_link(link)
|
||||
link = ActionController::Base.helpers.strip_tags(link)
|
||||
link.gsub(/.*github\.com\//, '').delete(' ')
|
||||
link.gsub(/.*github\.com\//, "").delete(" ")
|
||||
end
|
||||
|
||||
def get_content(link)
|
||||
repo_details = link.split('/')
|
||||
repo_details = link.split("/")
|
||||
raise_error if repo_details.length > 2
|
||||
user_name = repo_details[0]
|
||||
repo_name = repo_details[1]
|
||||
client = Octokit::Client.new(access_token: token)
|
||||
@readme_html = client.readme user_name + "/" + repo_name, :accept =>
|
||||
"application/vnd.github.html"
|
||||
@readme_html = client.readme user_name + "/" + repo_name, accept: "application/vnd.github.html"
|
||||
@readme = client.readme user_name + "/" + repo_name
|
||||
@updated_html = clean_relative_path!(@readme_html, @readme.download_url)
|
||||
client.repository(user_name + "/" + repo_name)
|
||||
|
|
@ -42,7 +41,7 @@ class GithubTag
|
|||
private
|
||||
|
||||
def raise_error
|
||||
raise StandardError, 'Invalid Github Repo link'
|
||||
raise StandardError, "Invalid Github Repo link"
|
||||
end
|
||||
|
||||
def clean_relative_path!(readme_html, url)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class GlitchTag < LiquidTagBase
|
|||
@id = parse_id(id)
|
||||
end
|
||||
|
||||
def render(context)
|
||||
def render(_context)
|
||||
html = <<-HTML
|
||||
<div class="glitch-embed-wrap" style="height: 450px; width: 100%;margin: 1em auto 1.3em">
|
||||
<iframe
|
||||
|
|
|
|||
|
|
@ -4,19 +4,19 @@ class InstagramTag < LiquidTagBase
|
|||
@id = parse_id(id)
|
||||
end
|
||||
|
||||
def render(context)
|
||||
def render(_context)
|
||||
html = <<-HTML
|
||||
<div class="instagram-position">
|
||||
<iframe
|
||||
id="instagram-liquid-tag"
|
||||
src="https://www.instagram.com/p/#{@id}/embed/captioned"
|
||||
allowtransparency="true"
|
||||
frameborder="0"
|
||||
data-instgrm-payload-id="instagram-media-payload-0"
|
||||
scrolling="no">
|
||||
</iframe>
|
||||
<script async defer src="https://platform.instagram.com/en_US/embeds.js"></script>
|
||||
</div>
|
||||
<iframe
|
||||
id="instagram-liquid-tag"
|
||||
src="https://www.instagram.com/p/#{@id}/embed/captioned"
|
||||
allowtransparency="true"
|
||||
frameborder="0"
|
||||
data-instgrm-payload-id="instagram-media-payload-0"
|
||||
scrolling="no">
|
||||
</iframe>
|
||||
<script async defer src="https://platform.instagram.com/en_US/embeds.js"></script>
|
||||
</div>
|
||||
HTML
|
||||
finalize_html(html)
|
||||
end
|
||||
|
|
@ -33,7 +33,7 @@ class InstagramTag < LiquidTagBase
|
|||
end
|
||||
|
||||
def valid_id?(id)
|
||||
id.length == 11 && !(id !~ /[a-zA-Z0-9_-]{11}/)
|
||||
id.length == 11 && id =~ /[a-zA-Z0-9_-]{11}/
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ class LinkTag < LiquidTagBase
|
|||
include ActionView::Helpers
|
||||
attr_reader :article
|
||||
|
||||
def initialize(tag_name, url, tokens)
|
||||
def initialize(_tag_name, url, _tokens)
|
||||
@article = parse_url_for_article(url)
|
||||
end
|
||||
|
||||
def render(context)
|
||||
def render(_context)
|
||||
tags = article.tag_list.map { |t| "<span class='ltag__link__tag'>##{t}</span>" }.join
|
||||
<<-HTML
|
||||
<div class='ltag__link'>
|
||||
|
|
@ -33,7 +33,7 @@ class LinkTag < LiquidTagBase
|
|||
article = find_article_by_user(hash) || find_article_by_org(hash)
|
||||
raise_error unless article
|
||||
article
|
||||
rescue
|
||||
rescue StandardError
|
||||
raise_error
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
class LiquidTagBase < Liquid::Tag
|
||||
def self.script
|
||||
''
|
||||
""
|
||||
end
|
||||
|
||||
def finalize_html(input)
|
||||
input.gsub(/ {2,}/, '')
|
||||
.gsub(/\n/m, ' ')
|
||||
.gsub(/>\n{1,}</m, '><')
|
||||
.strip
|
||||
.html_safe
|
||||
input.gsub(/ {2,}/, "").
|
||||
gsub(/\n/m, " ").
|
||||
gsub(/>\n{1,}</m, "><").
|
||||
strip.
|
||||
html_safe
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,18 +4,18 @@ class PodcastTag < LiquidTagBase
|
|||
attr_reader :episode, :podcast
|
||||
|
||||
IMAGE_LINK = {
|
||||
itunes: 'https://d.ibtimes.co.uk/en/full/1423047/itunes-12.png',
|
||||
overcast: 'https://d2uzvmey2c90kn.cloudfront.net/img/logo.svg',
|
||||
android: 'http://storage.googleapis.com/ix_choosemuse/uploads/2016/02/android-logo.png',
|
||||
rss: 'https://temenos.com/globalassets/img/marketplace/temenos/rss/rss.png',
|
||||
itunes: "https://d.ibtimes.co.uk/en/full/1423047/itunes-12.png",
|
||||
overcast: "https://d2uzvmey2c90kn.cloudfront.net/img/logo.svg",
|
||||
android: "http://storage.googleapis.com/ix_choosemuse/uploads/2016/02/android-logo.png",
|
||||
rss: "https://temenos.com/globalassets/img/marketplace/temenos/rss/rss.png",
|
||||
}.freeze
|
||||
|
||||
def initialize(tag_name, link, tokens)
|
||||
def initialize(_tag_name, link, _tokens)
|
||||
@episode = fetch_podcast(link)
|
||||
@podcast
|
||||
end
|
||||
|
||||
def render(context)
|
||||
def render(_context)
|
||||
html = <<-HTML
|
||||
<div class="podcastliquidtag" style="#{renderStyle}">
|
||||
<div class="podcastliquidtag__info">
|
||||
|
|
@ -24,13 +24,13 @@ class PodcastTag < LiquidTagBase
|
|||
</a>
|
||||
<a href="/#{@podcast.slug}">
|
||||
#{cl_image_tag(@podcast.image_url,
|
||||
:type=>"fetch",
|
||||
:crop => "fill",
|
||||
:quality => "auto",
|
||||
:sign_url => true,
|
||||
:flags => "progressive",
|
||||
:fetch_format => "auto",
|
||||
:class => "tinyimage")}
|
||||
type: 'fetch',
|
||||
crop: 'fill',
|
||||
quality: 'auto',
|
||||
sign_url: true,
|
||||
flags: 'progressive',
|
||||
fetch_format: 'auto',
|
||||
class: 'tinyimage')}
|
||||
<h1 class="podcastliquidtag__info__podcasttitle">#{@podcast.title}</h1>
|
||||
</a>
|
||||
|
||||
|
|
@ -41,14 +41,14 @@ class PodcastTag < LiquidTagBase
|
|||
<img class="button play-butt" id="play-butt-#{episode.slug}" src="/assets/playbutt.png"/>
|
||||
<img class="button pause-butt" id="pause-butt-#{episode.slug}" src="/assets/pausebutt.png"/>
|
||||
#{cl_image_tag(@podcast.image_url,
|
||||
:type=>"fetch",
|
||||
:crop => "fill",
|
||||
:quality => "auto",
|
||||
:sign_url => true,
|
||||
:flags => "progressive",
|
||||
:fetch_format => "auto",
|
||||
:class => "podcastliquidtag__podcastimage",
|
||||
:id => "podcastimage-#{episode.slug}")}
|
||||
type: 'fetch',
|
||||
crop: 'fill',
|
||||
quality: 'auto',
|
||||
sign_url: true,
|
||||
flags: 'progressive',
|
||||
fetch_format: 'auto',
|
||||
class: 'podcastliquidtag__podcastimage',
|
||||
id: "podcastimage-#{episode.slug}")}
|
||||
</div>
|
||||
#{render_hidden_audio}
|
||||
</div>
|
||||
|
|
@ -58,7 +58,7 @@ class PodcastTag < LiquidTagBase
|
|||
|
||||
def renderStyle
|
||||
"background:##{@podcast.main_color_hex} " \
|
||||
"url(#{cl_image_path(@podcast.pattern_image_url || 'https://i.imgur.com/fKYKgo4.png', :type=>'fetch', :quality => 'auto', :sign_url => true, :flags => 'progressive', :fetch_format => 'jpg')})"
|
||||
"url(#{cl_image_path(@podcast.pattern_image_url || 'https://i.imgur.com/fKYKgo4.png', type: 'fetch', quality: 'auto', sign_url: true, flags: 'progressive', fetch_format: 'jpg')})"
|
||||
end
|
||||
|
||||
def render_hidden_audio
|
||||
|
|
@ -71,16 +71,15 @@ class PodcastTag < LiquidTagBase
|
|||
<div id="progressBar" class="audio-player-display">
|
||||
<a href="/#{@podcast.slug}/#{@episode.slug}">
|
||||
#{cl_image_tag(@episode.image_url || @podcast.image_url,
|
||||
:type=>"fetch",
|
||||
:crop => "fill",
|
||||
:width => 420,
|
||||
:height => 420,
|
||||
:quality => "auto",
|
||||
:sign_url => true,
|
||||
:flags => "progressive",
|
||||
:fetch_format => "auto",
|
||||
:id => "episode-profile-image")
|
||||
}
|
||||
type: 'fetch',
|
||||
crop: 'fill',
|
||||
width: 420,
|
||||
height: 420,
|
||||
quality: 'auto',
|
||||
sign_url: true,
|
||||
flags: 'progressive',
|
||||
fetch_format: 'auto',
|
||||
id: 'episode-profile-image')}
|
||||
<img id="animated-bars" src="/assets/animated-bars.gif" />
|
||||
</a>
|
||||
<span id="barPlayPause">
|
||||
|
|
@ -90,14 +89,14 @@ class PodcastTag < LiquidTagBase
|
|||
<span id="volume">
|
||||
<span id="volumeindicator" class="volume-icon-wrapper showing">
|
||||
<span id="volbutt">
|
||||
#{image_tag("/assets/volume.png", alt: name, class:"icon-img", height: 16, width: 16)}
|
||||
#{image_tag('/assets/volume.png', alt: name, class: 'icon-img', height: 16, width: 16)}
|
||||
</span>
|
||||
<span class="range-wrapper">
|
||||
<input type="range" name="points" id="volumeslider" value="50" min="0" max="100" data-show-value="true">
|
||||
</span>
|
||||
</span>
|
||||
<span id="mutebutt" class="volume-icon-wrapper hidden">
|
||||
#{image_tag("/assets/volume-mute.png", alt: name, class:"icon-img", height: 16, width: 16)}
|
||||
#{image_tag('/assets/volume-mute.png', alt: name, class: 'icon-img', height: 16, width: 16)}
|
||||
</span>
|
||||
<span class="speed" id="speed" data-speed=1 >1x</span>
|
||||
</span>
|
||||
|
|
@ -149,7 +148,7 @@ class PodcastTag < LiquidTagBase
|
|||
|
||||
def fetch_podcast(link)
|
||||
cleaned_link = parse_link(link)
|
||||
podcast_slug, episode_slug = cleaned_link.split('/').last(2)
|
||||
podcast_slug, episode_slug = cleaned_link.split("/").last(2)
|
||||
target_podcast = Podcast.find_by_slug(podcast_slug)
|
||||
target_episode = PodcastEpisode.find_by_slug(episode_slug)
|
||||
raise_error unless target_podcast && target_episode
|
||||
|
|
@ -159,14 +158,14 @@ class PodcastTag < LiquidTagBase
|
|||
end
|
||||
|
||||
def parse_link(link)
|
||||
new_link = ActionController::Base.helpers.strip_tags(link).delete(' ').gsub(/\?.*/, '')
|
||||
component_count = new_link.split('/').count
|
||||
new_link = ActionController::Base.helpers.strip_tags(link).delete(" ").gsub(/\?.*/, "")
|
||||
component_count = new_link.split("/").count
|
||||
raise_error if component_count < 2 || component_count > 5
|
||||
new_link
|
||||
end
|
||||
|
||||
def raise_error
|
||||
raise StandardError, 'Invalid podcast link'
|
||||
raise StandardError, "Invalid podcast link"
|
||||
end
|
||||
end
|
||||
Liquid::Template.register_tag("podcast", PodcastTag)
|
||||
|
|
|
|||
|
|
@ -4,25 +4,25 @@ class ReplitTag < LiquidTagBase
|
|||
@id = parse_id(id)
|
||||
end
|
||||
|
||||
def render(context)
|
||||
def render(_context)
|
||||
'<div class="ltag__replit">
|
||||
<iframe frameborder="0" height="550px" src="https://repl.it/'+@id+'?lite=true"></iframe>
|
||||
<iframe frameborder="0" height="550px" src="https://repl.it/' + @id + '?lite=true"></iframe>
|
||||
</div>'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def parse_id(input)
|
||||
input_no_space = input.delete(' ')
|
||||
input_no_space = input.delete(" ")
|
||||
if valid_id?(input_no_space)
|
||||
input_no_space
|
||||
else
|
||||
raise StandardError, 'Invalid repl.it Id'
|
||||
raise StandardError, "Invalid repl.it Id"
|
||||
end
|
||||
end
|
||||
|
||||
def valid_id?(id)
|
||||
id.length > 1 && !(id !~ /[a-zA-Z0-9\/]/)
|
||||
id.length > 1 && id =~ /[a-zA-Z0-9\/]/
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class SpeakerdeckTag < LiquidTagBase
|
|||
@id = parse_id(id)
|
||||
end
|
||||
|
||||
def render(context)
|
||||
def render(_context)
|
||||
html = <<-HTML
|
||||
<div class="ltag_speakerdeck"
|
||||
style="position: relative;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class TweetTag < LiquidTagBase
|
|||
@tweet = Tweet.find_or_fetch(@id)
|
||||
end
|
||||
|
||||
def render(context)
|
||||
def render(_context)
|
||||
media_div = ""
|
||||
video_div = ""
|
||||
play_butt = ""
|
||||
|
|
@ -15,7 +15,7 @@ class TweetTag < LiquidTagBase
|
|||
if @tweet.extended_entities_serialized.present? && @tweet.extended_entities_serialized[:media] && @tweet.extended_entities_serialized[:media].size == 1
|
||||
media_item = @tweet.extended_entities_serialized[:media].first
|
||||
if media_item[:type] == "animated_gif" || media_item[:type] == "video"
|
||||
play_butt = image_tag("/assets/play-butt.svg", class:"ltag__twitter-tweet__play-butt")
|
||||
play_butt = image_tag("/assets/play-butt.svg", class: "ltag__twitter-tweet__play-butt")
|
||||
preview_div = "<div class='ltag__twitter-tweet__media--video-preview'><img src='#{media_item[:media_url_https]}'/>#{play_butt}</div>"
|
||||
video_div = "<div class='ltag__twitter-tweet__video'><video loop><source src='#{media_item[:video_info][:variants].last[:url]}' type='#{media_item[:video_info][:variants].last[:content_type]}' /></video></div>"
|
||||
media_div = "<div class='ltag__twitter-tweet__media ltag__twitter-tweet__media__video-wrapper'>#{preview_div}#{video_div}</div>"
|
||||
|
|
@ -32,28 +32,28 @@ class TweetTag < LiquidTagBase
|
|||
quoted_status = @tweet.full_fetched_object_serialized[:quoted_status]
|
||||
quote_div = "<div class='ltag__twitter-tweet__quote'><div class='ltag__twitter-tweet__quote__header'><span class='ltag__twitter-tweet__quote__header__name'>#{quoted_status[:user][:name]}</span> @#{quoted_status[:user][:screen_name]}</div>#{quoted_status[:text]}</div>"
|
||||
end
|
||||
'<blockquote '\
|
||||
'class="ltag__twitter-tweet" data-url="https://twitter.com/'+@tweet.twitter_username+'/status/'+@id+'">'\
|
||||
+media_div+\
|
||||
'<div class="ltag__twitter-tweet__main" data-url="https://twitter.com/'+@tweet.twitter_username+'/status/'+@id+'">'\
|
||||
"<blockquote "\
|
||||
'class="ltag__twitter-tweet" data-url="https://twitter.com/' + @tweet.twitter_username + "/status/" + @id + '">'\
|
||||
+media_div + \
|
||||
'<div class="ltag__twitter-tweet__main" data-url="https://twitter.com/' + @tweet.twitter_username + "/status/" + @id + '">'\
|
||||
'<div class="ltag__twitter-tweet__header">'\
|
||||
'<img class="ltag__twitter-tweet__profile-image" src="'+@tweet.full_fetched_object_serialized[:user][:profile_image_url_https]+'"/>'\
|
||||
'<div class="ltag__twitter-tweet__full-name">'+@tweet.twitter_name+'</div>'\
|
||||
'<div class="ltag__twitter-tweet__username">@'+@tweet.twitter_username+'</div>'\
|
||||
'<img class="ltag__twitter-tweet__profile-image" src="' + @tweet.full_fetched_object_serialized[:user][:profile_image_url_https] + '"/>'\
|
||||
'<div class="ltag__twitter-tweet__full-name">' + @tweet.twitter_name + "</div>"\
|
||||
'<div class="ltag__twitter-tweet__username">@' + @tweet.twitter_username + "</div>"\
|
||||
'<div class="ltag__twitter-tweet__twitter-logo">'\
|
||||
'<img src="'+ActionController::Base.helpers.asset_path("twitter.svg")+'" />'\
|
||||
'</div>'\
|
||||
'</div>'\
|
||||
'<div class="ltag__twitter-tweet__body">'+@tweet.processed_text.html_safe+'</div>'\
|
||||
'<div class="ltag__twitter-tweet__date">'+@tweet.tweeted_at.strftime("%H:%M %p - %d %b %Y")+'</div>'\
|
||||
+quote_div+\
|
||||
'<img src="' + ActionController::Base.helpers.asset_path("twitter.svg") + '" />'\
|
||||
"</div>"\
|
||||
"</div>"\
|
||||
'<div class="ltag__twitter-tweet__body">' + @tweet.processed_text.html_safe + "</div>"\
|
||||
'<div class="ltag__twitter-tweet__date">' + @tweet.tweeted_at.strftime("%H:%M %p - %d %b %Y") + "</div>"\
|
||||
+quote_div + \
|
||||
'<div class="ltag__twitter-tweet__actions">'\
|
||||
'<a href= "https://twitter.com/intent/tweet?in_reply_to='+@id+'" class="ltag__twitter-tweet__actions__button">'+image_tag("/assets/twitter-reply-action.svg")+'</a>'\
|
||||
'<a href= "https://twitter.com/intent/retweet?tweet_id='+@id+'" class="ltag__twitter-tweet__actions__button">'+image_tag("/assets/twitter-retweet-action.svg")+'</a>'+@tweet.retweet_count.to_s+\
|
||||
'<a href= "https://twitter.com/intent/like?tweet_id='+@id+'" class="ltag__twitter-tweet__actions__button">'+image_tag("/assets/twitter-like-action.svg")+'</a>'+@tweet.favorite_count.to_s+\
|
||||
'</div>'\
|
||||
'</div>'\
|
||||
'</blockquote>'
|
||||
'<a href= "https://twitter.com/intent/tweet?in_reply_to=' + @id + '" class="ltag__twitter-tweet__actions__button">' + image_tag("/assets/twitter-reply-action.svg") + "</a>"\
|
||||
'<a href= "https://twitter.com/intent/retweet?tweet_id=' + @id + '" class="ltag__twitter-tweet__actions__button">' + image_tag("/assets/twitter-retweet-action.svg") + "</a>" + @tweet.retweet_count.to_s + \
|
||||
'<a href= "https://twitter.com/intent/like?tweet_id=' + @id + '" class="ltag__twitter-tweet__actions__button">' + image_tag("/assets/twitter-like-action.svg") + "</a>" + @tweet.favorite_count.to_s + \
|
||||
"</div>"\
|
||||
"</div>"\
|
||||
"</blockquote>"
|
||||
end
|
||||
|
||||
def self.script
|
||||
|
|
@ -82,11 +82,11 @@ class TweetTag < LiquidTagBase
|
|||
private
|
||||
|
||||
def parse_id(input)
|
||||
input_no_space = input.delete(' ')
|
||||
input_no_space = input.delete(" ")
|
||||
if valid_id?(input_no_space)
|
||||
input_no_space
|
||||
else
|
||||
raise StandardError, 'Invalid Twitter Id'
|
||||
raise StandardError, "Invalid Twitter Id"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ class UserTag < LiquidTagBase
|
|||
include ApplicationHelper
|
||||
attr_reader :user
|
||||
|
||||
def initialize(tag_name, user, tokens)
|
||||
def initialize(_tag_name, user, _tokens)
|
||||
@user = parse_username_to_user(user)
|
||||
end
|
||||
|
||||
def render(context)
|
||||
def render(_context)
|
||||
# looks like link liquid tag
|
||||
<<-HTML
|
||||
<div class="ltag__user ltag__user__id__#{@user.id}" style="border-color:#{@user.decorate.darker_color};box-shadow: 3px 3px 0px #{@user.decorate.darker_color}">
|
||||
|
|
@ -14,7 +14,7 @@ class UserTag < LiquidTagBase
|
|||
.ltag__user__id__#{@user.id} .follow-action-button{
|
||||
background-color: #{user_colors(@user)[:bg]} !important;
|
||||
color: #{user_colors(@user)[:text]} !important;
|
||||
border-color: #{ user_colors(@user)[:bg].downcase == '#ffffff' ? user_colors(@user)[:text] : user_colors(@user)[:bg] } !important;
|
||||
border-color: #{user_colors(@user)[:bg].casecmp('#ffffff').zero? ? user_colors(@user)[:text] : user_colors(@user)[:bg]} !important;
|
||||
}
|
||||
</style>
|
||||
<a href="/#{@user.username}" class="ltag__user__link profile-image-link">
|
||||
|
|
@ -54,7 +54,7 @@ class UserTag < LiquidTagBase
|
|||
if @user.twitter_username.present?
|
||||
<<-HTML
|
||||
<a href="http://twitter.com/#{@user.twitter_username}" target="_blank" rel="noopener">
|
||||
#{image_tag('/assets/twitter-logo.svg', class:'icon-img', alt: 'twitter')} #{@user.twitter_username}
|
||||
#{image_tag('/assets/twitter-logo.svg', class: 'icon-img', alt: 'twitter')} #{@user.twitter_username}
|
||||
</a>
|
||||
HTML
|
||||
end
|
||||
|
|
@ -64,7 +64,7 @@ class UserTag < LiquidTagBase
|
|||
if @user.github_username.present?
|
||||
<<-HTML
|
||||
<a href="http://github.com/#{@user.github_username}" target="_blank" rel="noopener">
|
||||
#{image_tag('/assets/github-logo.svg', class:'icon-img', alt: 'github')} #{@user.github_username}
|
||||
#{image_tag('/assets/github-logo.svg', class: 'icon-img', alt: 'github')} #{@user.github_username}
|
||||
</a>
|
||||
HTML
|
||||
end
|
||||
|
|
@ -74,7 +74,7 @@ class UserTag < LiquidTagBase
|
|||
if @user.website_url.present?
|
||||
<<-HTML
|
||||
<a href="#{@user.website_url}" target="_blank" rel="noopener">
|
||||
#{image_tag('/assets/link.svg', class:'icon-img', alt: 'website link')} #{beautified_url(@user.website_url)}
|
||||
#{image_tag('/assets/link.svg', class: 'icon-img', alt: 'website link')} #{beautified_url(@user.website_url)}
|
||||
</a>
|
||||
HTML
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ class YoutubeTag < LiquidTagBase
|
|||
@height = 399
|
||||
end
|
||||
|
||||
def render(context)
|
||||
def render(_context)
|
||||
html = <<-HTML
|
||||
<iframe
|
||||
width="#{@width}"
|
||||
|
|
@ -22,11 +22,11 @@ class YoutubeTag < LiquidTagBase
|
|||
|
||||
def parse_id(input)
|
||||
input = translate_url(input) if input.include?("watch?v=")
|
||||
input_no_space = input.delete(' ')
|
||||
input_no_space = input.delete(" ")
|
||||
if valid_id?(input_no_space)
|
||||
input_no_space
|
||||
else
|
||||
raise StandardError, 'Invalid Youtube Id'
|
||||
raise StandardError, "Invalid Youtube Id"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ class YoutubeTag < LiquidTagBase
|
|||
end
|
||||
|
||||
def valid_id?(id)
|
||||
id.length == 11 && !(id !~ /[a-zA-Z0-9_-]{11}/)
|
||||
id.length == 11 && id =~ /[a-zA-Z0-9_-]{11}/
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue