source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/mutations/profile/update.rb | Ruby | apache-2.0 | 187 | the-future | 1,596 | # frozen_string_literal: true
class Mutations::Profile::Update < Mutations::Base
include FancyMutation
description 'Update profile'
input do
argument :id, ID,
required: false,
description: 'Your ID or the one of another user.'
argument :name,
String,
required: false,
descr... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/mutations/profile_link/delete.rb | Ruby | apache-2.0 | 187 | the-future | 802 | # frozen_string_literal: true
class Mutations::ProfileLink::Delete < Mutations::Base
include FancyMutation
description 'Delete a profile link'
input do
argument :profile_link,
Types::Enum::ProfileLinksSites,
required: true,
description: 'The profile link to delete'
end
result Types::S... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/mutations/profile_link/create.rb | Ruby | apache-2.0 | 187 | the-future | 1,125 | # frozen_string_literal: true
class Mutations::ProfileLink::Create < Mutations::Base
include FancyMutation
description 'Create a profile link'
input do
argument :url, String,
required: true,
description: 'The url of the profile link',
as: :profile_link_url
argument :profile_link_site,... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/mutations/profile_link/update.rb | Ruby | apache-2.0 | 187 | the-future | 1,208 | # frozen_string_literal: true
class Mutations::ProfileLink::Update < Mutations::Base
include FancyMutation
description 'Update profile links'
input do
argument :url, String,
required: true,
description: 'The url of the profile link',
as: :profile_link_url
argument :profile_link_site,
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/mutations/comment/unhold.rb | Ruby | apache-2.0 | 187 | the-future | 715 | # frozen_string_literal: true
class Mutations::Comment::Unhold < Mutations::Base
include FancyMutation
directive Directives::SitePermission, required: 'community_mod'
description 'Mark a held Comment as fine, unholding it.'
input do
argument :comment_id, ID, required: true
end
result Types::Comment
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/mutations/comment/create.rb | Ruby | apache-2.0 | 187 | the-future | 1,244 | # frozen_string_literal: true
class Mutations::Comment::Create < Mutations::Base
include FancyMutation
description 'Create a Comment'
input do
argument :content, String, required: true,
description: 'The (markdown-formatted) content of the comment'
argument :post_id, ID, required: true,
des... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/mutations/comment/delete.rb | Ruby | apache-2.0 | 187 | the-future | 655 | # frozen_string_literal: true
class Mutations::Comment::Delete < Mutations::Base
include FancyMutation
description 'Delete a comment'
input do
argument :comment_id, ID,
required: true,
description: 'The id of the comment.'
end
result Types::Comment
errors Types::Errors::NotAuthenticated,
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/mutations/wiki_submission/update_draft.rb | Ruby | apache-2.0 | 187 | the-future | 913 | class Mutations::WikiSubmission::UpdateDraft < Mutations::Base
prepend RescueValidationErrors
argument :input,
Types::Input::WikiSubmission::UpdateDraft,
required: true,
description: 'Update a wiki submission draft.',
as: :wiki_submission
field :wiki_submission, Types::WikiSubmission, null: true... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/mutations/wiki_submission/submit_draft.rb | Ruby | apache-2.0 | 187 | the-future | 782 | class Mutations::WikiSubmission::SubmitDraft < Mutations::Base
prepend RescueValidationErrors
argument :input,
Types::Input::WikiSubmission::SubmitDraft,
required: true,
description: 'Submit a wiki submission draft. This will change the status to pending.',
as: :wiki_submission
field :wiki_submi... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/mutations/wiki_submission/create_draft.rb | Ruby | apache-2.0 | 187 | the-future | 655 | class Mutations::WikiSubmission::CreateDraft < Mutations::Base
prepend RescueValidationErrors
argument :input,
Types::Input::WikiSubmission::CreateDraft,
required: true,
description: 'Create a wiki submission draft.',
as: :wiki_submission
field :wiki_submission, Types::WikiSubmission, null: true... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/connections/holdable_connection.rb | Ruby | apache-2.0 | 187 | the-future | 467 | # frozen_string_literal: true
class Connections::HoldableConnection < GraphQL::Pagination::ActiveRecordRelationConnection
def initialize
super(HeldItem.order(created_at: :desc))
end
def limited_nodes
held_items = super
loaded_items = held_items.group_by(&:type).to_h do |key, items|
[key, key.c... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/resolvers/localized_field.rb | Ruby | apache-2.0 | 187 | the-future | 1,753 | # frozen_string_literal: true
class Resolvers::LocalizedField < Resolvers::Base
type Types::Map, null: false
argument :locales, [String], required: false
class << self
attr_accessor :field_method
end
def self.from(field_method)
Class.new(self) do
self.field_method = field_method
end
en... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/concerns/rescue_validation_errors.rb | Ruby | apache-2.0 | 187 | the-future | 423 | module RescueValidationErrors
extend ActiveSupport::Concern
def resolve(*args, **kwargs)
super
rescue ActiveRecord::RecordInvalid => e
errors = e.record.errors.map do |attribute, message|
{
code: 'ValidationError',
message: e.record.errors.full_message(attribute, message),
p... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/concerns/fancy_mutation.rb | Ruby | apache-2.0 | 187 | the-future | 7,388 | # frozen_string_literal: true
# Provides a bunch of helpers for our standard mutation structure, making consistency easy!
#
# @example
# class Mutations::Post::Like < Mutations::Base
# # Pass a description here to be used in the GraphQL schema
# description 'Like a post'
# # Build your input type here (s... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/concerns/behind_feature_flag.rb | Ruby | apache-2.0 | 187 | the-future | 597 | module BehindFeatureFlag
extend ActiveSupport::Concern
class_methods do
def behind_feature_flag(flag)
if method_defined?(:visible?)
define_method(:visible?) do |context|
super(context) && Flipper[flag].enabled?(context[:user])
end
elsif respond_to?(:visible?)
defin... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/concerns/has_image_field.rb | Ruby | apache-2.0 | 187 | the-future | 694 | module HasImageField
extend ActiveSupport::Concern
class_methods do
def image_field(key, **options)
options = {
type: Types::Image,
null: true
}.merge(options)
field(key, **options.except(:method)) do
yield if block_given?
end
define_method(key) do
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/concerns/rate_limited_mutation.rb | Ruby | apache-2.0 | 187 | the-future | 412 | module RateLimitedMutation
extend ActiveSupport::Concern
class_methods do
attr_reader :rate_limiter
def rate_limit(&block)
@rate_limiter = Strait.new("mutation-#{graphql_name}", &block)
end
end
def ready?(*_args, **_kwargs)
self.class.rate_limiter.limit!(current_user)
super
rescue... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/loaders/library_entries_loader.rb | Ruby | apache-2.0 | 187 | the-future | 1,905 | # frozen_string_literal: true
class Loaders::LibraryEntriesLoader < GraphQL::FancyLoader
from LibraryEntry
sort :media_type
sort :status
sort :created_at
sort :updated_at
sort :progress
sort :rating
sort :started_at
sort :finished_at
sort :title,
transform: ->(ast, _context) {
ast.join(An... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/loaders/media_characters_loader.rb | Ruby | apache-2.0 | 187 | the-future | 216 | class Loaders::MediaCharactersLoader < GraphQL::FancyLoader
from MediaCharacter
sort :created_at
sort :updated_at
sort :role, on: -> { Arel::Nodes::Subtraction.new(0, MediaCharacter.arel_table[:role]) }
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/loaders/follows_loader.rb | Ruby | apache-2.0 | 187 | the-future | 1,049 | class Loaders::FollowsLoader < GraphQL::FancyLoader
from Follow
# Sort by whether you follow the followed person
sort :following_followed,
transform: ->(ast, context) {
their_follows = Follow.arel_table
your_follows = Follow.arel_table.alias('yours')
condition = your_follows[:followed_id].e... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/loaders/record_loader.rb | Ruby | apache-2.0 | 187 | the-future | 851 | class Loaders::RecordLoader < GraphQL::Batch::Loader
def initialize(model, column: model.primary_key, where: nil, policy: nil, token: nil)
@model = model
@column = column.to_s
@column_type = model.type_for_attribute(@column)
@where = where
@policy = (policy.presence || model).to_s
@token = tok... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/loaders/unscoped_record_loader.rb | Ruby | apache-2.0 | 187 | the-future | 611 | class Loaders::UnscopedRecordLoader < GraphQL::Batch::Loader
def initialize(model, column: model.primary_key, where: nil)
@model = model
@column = column.to_s
@column_type = model.type_for_attribute(@column)
@where = where
super()
end
def load(key)
super(@column_type.cast(key))
end
d... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/loaders/slug_loader.rb | Ruby | apache-2.0 | 187 | the-future | 235 | # frozen_string_literal: true
class Loaders::SlugLoader < Loaders::UnscopedRecordLoader
def initialize(model, column: :slug, **args)
super(model, column:, **args)
end
def cache_key(load_key)
load_key.downcase
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/loaders/comments_loader.rb | Ruby | apache-2.0 | 187 | the-future | 470 | class Loaders::CommentsLoader < GraphQL::FancyLoader
from Comment
sort :following,
transform: ->(ast, context) {
follows = Follow.arel_table
comment = Comment.arel_table
condition = follows[:followed_id].eq(comment[:user_id]).and(
follows[:follower_id].eq(context[:user]&.id)
)
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/loaders/association_loader.rb | Ruby | apache-2.0 | 187 | the-future | 1,763 | class Loaders::AssociationLoader < GraphQL::Batch::Loader
def self.validate(model, association_name)
new(model, association_name)
nil
end
def initialize(model, association_name, token: nil, policy: nil)
@model = model
@association_name = association_name
@token = token
@policy = (policy.p... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/loaders/post_likes_loader.rb | Ruby | apache-2.0 | 187 | the-future | 449 | class Loaders::PostLikesLoader < GraphQL::FancyLoader
from PostLike
sort :following,
transform: ->(ast, context) {
follows = Follow.arel_table
likes = PostLike.arel_table
condition = follows[:followed_id].eq(likes[:user_id]).and(
follows[:follower_id].eq(context[:user]&.id)
)
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/loaders/installments_loader.rb | Ruby | apache-2.0 | 187 | the-future | 537 | class Loaders::InstallmentsLoader < GraphQL::FancyLoader
from Installment
modify_query ->(query) {
release_rank = GraphQL::FancyLoader::RankQueryGenerator.new(
column: :release_order,
partition_by: @find_by,
table: table
).arel
alternative_rank = GraphQL::FancyLoader::RankQueryGenerato... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/loaders/media_reaction_votes_loader.rb | Ruby | apache-2.0 | 187 | the-future | 477 | class Loaders::MediaReactionVotesLoader < GraphQL::FancyLoader
from MediaReactionVote
sort :created_at
sort :following,
transform: ->(ast, context) {
follows = Follow.arel_table
votes = MediaReactionVote.arel_table
condition = follows[:followed_id].eq(votes[:user_id]).and(
follows[... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/loaders/media_categories_loader.rb | Ruby | apache-2.0 | 187 | the-future | 510 | class Loaders::MediaCategoriesLoader < GraphQL::FancyLoader
from MediaCategory
sort :ancestry,
transform: ->(ast, _context) {
ac = MediaCategory.arel_table
c = Category.arel_table
condition = ac[:category_id].eq(c[:id])
ast.join(c, Arel::Nodes::OuterJoin).on(condition)
},
on: ... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/loaders/comment_likes_loader.rb | Ruby | apache-2.0 | 187 | the-future | 458 | class Loaders::CommentLikesLoader < GraphQL::FancyLoader
from CommentLike
sort :following,
transform: ->(ast, context) {
follows = Follow.arel_table
likes = CommentLike.arel_table
condition = follows[:followed_id].eq(likes[:user_id]).and(
follows[:follower_id].eq(context[:user]&.id)
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/analysis/prometheus_metrics.rb | Ruby | apache-2.0 | 187 | the-future | 2,175 | # frozen_string_literal: true
require 'graphql/metrics'
module Analysis
class PrometheusMetrics < GraphQL::Metrics::Analyzer
# graphql_query_duration_seconds{operation_type,operation_name}
GRAPHQL_QUERY_DURATION_SECONDS = $prometheus.register(
:summary,
'graphql_query_duration_seconds',
'T... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/analysis/max_node_limit.rb | Ruby | apache-2.0 | 187 | the-future | 5,010 | # frozen_string_literal: true
module Analysis
# Unlike Graphql-ruby's default complexity analysis, this only counts objects, not individual
# fields.
class MaxNodeLimit < GraphQL::Analysis::AST::Analyzer
GRAPHQL_QUERY_NODE_AMOUNT = $prometheus.register(
:summary,
'graphql_query_node_amount',
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/analysis/max_node_limit/base_scope_type.rb | Ruby | apache-2.0 | 187 | the-future | 1,500 | # frozen_string_literal: true
module Analysis
class MaxNodeLimit
class BaseScopeType
attr_reader :field_definition, :query
delegate :complexity, to: :field_definition
# A single proc for {#scoped_children} hashes. Use this to avoid repeated allocations,
# since the lexical binding isn't... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/analysis/max_node_limit/custom_scope_type.rb | Ruby | apache-2.0 | 187 | the-future | 211 | # frozen_string_literal: true
module Analysis
class MaxNodeLimit
class CustomScopeType < BaseScopeType
def total_nodes(child_nodes_amount)
child_nodes_amount + 1
end
end
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/analysis/max_node_limit/connection_scope_type.rb | Ruby | apache-2.0 | 187 | the-future | 1,132 | # frozen_string_literal: true
module Analysis
class MaxNodeLimit
class ConnectionScopeType < BaseScopeType
def valid?
if node_argument.nil?
message = "Connection '#{field_definition.name}' requires" \
" the argument 'first' or 'last' to be supplied."
raise GraphQL::A... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/graphql/directives/site_permission.rb | Ruby | apache-2.0 | 187 | the-future | 1,546 | # frozen_string_literal: true
class Directives::SitePermission < GraphQL::Schema::Directive
description 'Ensure the current user has the necessary site permission to access a resource'
locations FIELD_DEFINITION, OBJECT, SCALAR, ENUM, UNION, INTERFACE, INPUT_OBJECT, ENUM_VALUE,
ARGUMENT_DEFINITION, INPUT_FIEL... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/chewy/media_index.rb | Ruby | apache-2.0 | 187 | the-future | 5,260 | class MediaIndex < Chewy::Index
class << self
def sfw
safe_ratings = AgeRatings::SAFE_AGE_RATINGS.map(&:downcase)
age_ratings = AgeRatings::AGE_RATINGS.map(&:to_s).map(&:downcase)
unsafe_ratings = age_ratings - safe_ratings
filter do
age_rating(:or) != unsafe_ratings
end
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/chewy/characters_index.rb | Ruby | apache-2.0 | 187 | the-future | 1,289 | class CharactersIndex < Chewy::Index
define_type Character.includes(castings: %i[media person]) do
def self.query_for(query)
fields = %w[name^2 people media]
{
bool: {
must: {
multi_match: {
query: query,
fields: fields,
fuzziness... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/chewy/groups_index.rb | Ruby | apache-2.0 | 187 | the-future | 578 | class GroupsIndex < Chewy::Index
define_type Group do
def self.visible_for(user)
return filter { privacy(:or) == %w[open restricted] } unless user
members = user.group_members.pluck(:group_id)
filter { (_id(:or) == members) | (privacy(:or) == %w[open restricted]) }
end
def self.sfw
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/chewy/group_tickets_index.rb | Ruby | apache-2.0 | 187 | the-future | 616 | class GroupTicketsIndex < Chewy::Index
define_type GroupTicket do
def self.visible_for(user)
return filter { _id == false } unless user
members = GroupMember.with_permission(:tickets).for_user(user)
groups = members.pluck(:group_id)
filter { (group_id(:or) == groups) | (user_id == user.id)... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/chewy/users_index.rb | Ruby | apache-2.0 | 187 | the-future | 1,173 | class UsersIndex < Chewy::Index
define_type User do
def self.blocking(*user_ids)
filter { _id(:or) != user_ids.flatten }
end
def self.active
filter { deleted_at.nil? }
end
field :name
field :past_names
field :updated_at
field :deleted_at
end
define_type GroupMember.i... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/chewy/concerns/index_translatable.rb | Ruby | apache-2.0 | 187 | the-future | 447 | module IndexTranslatable
extend ActiveSupport::Concern
TRANSLATION_MAPPINGS = {
'ja_*' => 'cjk',
'zh_*' => 'cjk',
'ko_*' => 'cjk',
'en_*' => 'english'
}.freeze
class_methods do
def translatable_field(name, opts = {})
field name, { type: 'object' }.merge(opts)
TRANSLATION_MAPPIN... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/pipelines/long_pipeline.rb | Ruby | apache-2.0 | 187 | the-future | 296 | LongPipeline = HTML::Pipeline.new [
HTMLFilters::InlineMarkdownFilter,
HTML::Pipeline::SanitizationFilter,
HTMLFilters::KitsuMentionFilter,
HTML::Pipeline::AutolinkFilter,
HTMLFilters::UnembedFilter
], base_url: '/user/',
link_attr: 'target="_blank" rel="nofollow" class="autolink"' |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/pipelines/inline_pipeline.rb | Ruby | apache-2.0 | 187 | the-future | 278 | InlinePipeline = HTML::Pipeline.new [
HTMLFilters::InlineMarkdownFilter,
HTML::Pipeline::SanitizationFilter,
HTMLFilters::KitsuMentionFilter,
HTML::Pipeline::AutolinkFilter,
HTMLFilters::UnembedFilter
], base_url: '/user/', link_attr: 'target="_blank" rel="nofollow"' |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/pipelines/rules_pipeline.rb | Ruby | apache-2.0 | 187 | the-future | 261 | RulesPipeline = HTML::Pipeline.new [
HTMLFilters::KramdownFilter,
HTML::Pipeline::SanitizationFilter,
HTMLFilters::KitsuMentionFilter,
HTML::Pipeline::AutolinkFilter
], base_url: '/user/',
link_attr: 'target="_blank" rel="nofollow" class="autolink"' |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/pipelines/html_filters/kitsu_mention_filter.rb | Ruby | apache-2.0 | 187 | the-future | 626 | class HTMLFilters::KitsuMentionFilter < HTML::Pipeline::MentionFilter
# Disable "@mention" mentions
MentionLogins = [].freeze
def call
result[:mentioned_users] = []
super
end
# Check if user exists before we linkify it
def link_to_mentioned_user(mention)
user = User.by_slug(mention).first || U... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/pipelines/html_filters/unembed_filter.rb | Ruby | apache-2.0 | 187 | the-future | 427 | class HTMLFilters::UnembedFilter < HTML::Pipeline::Filter
def call
doc.search('iframe, img').each do |embed|
href = to_href(embed['src'])
embed.swap <<-EOF.squish
<a href="#{href}" rel="nofollow">#{href}</a>
EOF
end
doc
end
private
def to_href(url)
case url
when %... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/pipelines/html_filters/hashtags_filter.rb | Ruby | apache-2.0 | 187 | the-future | 2,888 | # frozen_string_literal: true
class HTMLFilters::HashtagsFilter < HTML::Pipeline::Filter
# These regexex are reproduced from the twitter/tweet-text library, which is licensed under
# the Apache 2.0 license. The originals can be found at the following URL:
#
# https://github.com/twitter/twitter-text/blob/maste... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/pipelines/html_filters/inline_markdown_filter.rb | Ruby | apache-2.0 | 187 | the-future | 279 | class HTMLFilters::InlineMarkdownFilter < HTML::Pipeline::TextFilter
def initialize(text, context = nil, result = nil)
super text, context, result
@text = @text.delete("\r")
end
def call
Kramdown::Document.new(@text, input: 'InlineMarkdown').to_html
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/pipelines/html_filters/kramdown_filter.rb | Ruby | apache-2.0 | 187 | the-future | 267 | class HTMLFilters::KramdownFilter < HTML::Pipeline::TextFilter
def initialize(text, context = nil, result = nil)
super text, context, result
@text = @text.delete("\r")
end
def call
Kramdown::Document.new(@text, input: 'Markdown').to_html
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/library_entry_log_resource.rb | Ruby | apache-2.0 | 187 | the-future | 333 | class LibraryEntryLogResource < BaseResource
immutable
paginator :unlimited
attributes :progress, :rating, :reconsume_count, :reconsuming,
:status, :volumes_owned, :action_performed, :sync_status, :error_message
has_one :linked_account
has_one :media, polymorphic: true
filters :linked_account_id, :syn... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/report_resource.rb | Ruby | apache-2.0 | 187 | the-future | 254 | class ReportResource < BaseResource
attributes :reason, :status, :explanation, :naughty_type, :naughty_id
has_one :naughty, polymorphic: true
has_one :user
has_one :moderator
filters :user_id, :naughty_id, :naughty_type, :status, :reason
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/media_attribute_resource.rb | Ruby | apache-2.0 | 187 | the-future | 204 | class MediaAttributeResource < BaseResource
attributes :title, :high_title, :neutral_title, :low_title
has_many :anime
has_many :drama
has_many :manga
paginator :unlimited
filter :slug
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/favorite_resource.rb | Ruby | apache-2.0 | 187 | the-future | 203 | class FavoriteResource < BaseResource
include RankedResource
attributes :fav_rank
ranks :fav_rank
has_one :user
has_one :item, polymorphic: true
filters :user_id, :item_type, :item_id
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/base_resource.rb | Ruby | apache-2.0 | 187 | the-future | 1,364 | class BaseResource < JSONAPI::Resource
abstract
include BackportFindRecords
include IgnorePreloadingNils
include AuthenticatedResource
include Pundit::Resource
include SearchableResource
attributes :created_at, :updated_at
def respond_to?(method_name, include_private = false)
if method_name.to_s.e... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/category_resource.rb | Ruby | apache-2.0 | 187 | the-future | 497 | class CategoryResource < BaseResource
attributes :title, :description, :total_media_count,
:slug, :nsfw, :child_count
has_one :parent, eager_load_on_include: false
has_many :anime
has_many :drama
has_many :manga
paginator :unlimited
filters :slug, :nsfw
filter :parent_id, apply: ->(records, value... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/group_resource.rb | Ruby | apache-2.0 | 187 | the-future | 2,833 | class GroupResource < BaseResource
include SluggableResource
include GroupActionLogger
caching
attributes :about, :locale, :members_count, :name, :nsfw, :privacy, :rules,
:rules_formatted, :leaders_count, :neighbors_count, :featured, :tagline,
:last_activity_at
attributes :avatar, format: :shrine_at... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/manga_resource.rb | Ruby | apache-2.0 | 187 | the-future | 463 | # frozen_string_literal: true
class MangaResource < MediaResource
attributes :chapter_count, :volume_count, :serialization
attribute :manga_type # DEPRECATED
# ElasticSearch hookup
index MediaIndex::Manga
query :chapter_count, MediaResource::NUMERIC_QUERY
has_many :chapters
has_many :manga_characters
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/drama_resource.rb | Ruby | apache-2.0 | 187 | the-future | 204 | class DramaResource < MediaResource
include EpisodicResource
attributes :youtube_video_id
has_many :drama_characters
has_many :drama_staff
# ElasticSearch hookup
index MediaIndex::Drama
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/media_relationship_resource.rb | Ruby | apache-2.0 | 187 | the-future | 473 | class MediaRelationshipResource < BaseResource
attribute :role
filter :role, apply: ->(records, values, _options) {
roles = MediaRelationship.roles.values_at(*values).compact
roles = values if roles.empty?
records.where(role: roles)
}
has_one :source, polymorphic: true
has_one :destination, poly... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/library_event_resource.rb | Ruby | apache-2.0 | 187 | the-future | 348 | class LibraryEventResource < BaseResource
immutable
attributes :changed_data, :kind
has_one :library_entry
has_one :user
has_one :anime
has_one :manga
has_one :drama
filter :user_id
filter :kind, apply: ->(records, values, _opts) {
values = values.map { |v| records.kinds[v] || v }
records.... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/group_ticket_resource.rb | Ruby | apache-2.0 | 187 | the-future | 892 | class GroupTicketResource < BaseResource
include GroupActionLogger
attribute :status
has_one :user
has_one :group
has_one :assignee
has_many :messages
has_one :first_message
filters :group, :user, :assignee
filter :status, apply: ->(records, values, _options) {
statuses = GroupTicket.statuses.v... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/library_entry_resource.rb | Ruby | apache-2.0 | 187 | the-future | 4,501 | # frozen_string_literal: true
class LibraryEntryResource < BaseResource
TITLE_SORT = /\A([^\.]+)\.titles\.([^\.]+)\z/
class TitleSortableFields
def initialize(whitelist)
@whitelist = whitelist
end
def include?(key)
return true if @whitelist.include?(key)
# Magic match-handling code
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/chapter_resource.rb | Ruby | apache-2.0 | 187 | the-future | 484 | class ChapterResource < BaseResource
caching
attribute :synopsis # DEPRECATED
def synopsis
description
end
attribute :description
def description
_model.description['en']
end
attributes :titles, :canonical_title, :volume_number, :number,
:published, :length
attribute :thumbnail, format:... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/episode_resource.rb | Ruby | apache-2.0 | 187 | the-future | 611 | class EpisodeResource < BaseResource
caching
attribute :synopsis # DEPRECATED
def synopsis
description
end
attribute :description
def description
_model.description['en']
end
attributes :titles, :canonical_title, :season_number, :number, :relative_number,
:airdate, :length
attribute :th... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/group_invite_resource.rb | Ruby | apache-2.0 | 187 | the-future | 475 | class GroupInviteResource < BaseResource
include GroupActionLogger
attributes :accepted_at, :declined_at, :revoked_at
has_one :user
has_one :group
has_one :sender
filters :group, :sender, :user
filter :status, apply: ->(records, values, _o) {
records.by_status(values.first)
}
log_verb do |acti... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/review_resource.rb | Ruby | apache-2.0 | 187 | the-future | 272 | class ReviewResource < BaseResource
attributes :content, :content_formatted, :likes_count, :progress, :rating,
:source, :spoiler
caching
has_one :library_entry
has_one :media, polymorphic: true
has_one :user
filters :media_id, :media_type, :user_id
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/user_resource.rb | Ruby | apache-2.0 | 187 | the-future | 3,798 | # frozen_string_literal: true
class UserResource < BaseResource
PRIVATE_FIELDS = %i[email password confirmed previous_email language time_zone country
share_to_global title_language_preference sfw_filter rating_system
theme facebook_id has_password status subscribed_to_new... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/media_reaction_resource.rb | Ruby | apache-2.0 | 187 | the-future | 343 | # frozen_string_literal: true
class MediaReactionResource < BaseResource
attributes :reaction, :up_votes_count, :held_reason
has_one :anime
has_one :drama
has_one :manga
has_one :user
has_one :library_entry
has_many :votes
filters :created_at, :up_votes_count,
:user_id, :anime_id, :drama_id, :man... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/character_resource.rb | Ruby | apache-2.0 | 187 | the-future | 741 | class CharacterResource < BaseResource
attributes :slug, :names, :canonical_name, :other_names, :name, :mal_id, :description
attribute :image, format: :shrine_attachment, delegate: :image_attacher
has_one :primary_media, polymorphic: true
has_many :castings
has_many :media_characters
has_many :quotes
fi... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/manga_media_attribute_resource.rb | Ruby | apache-2.0 | 187 | the-future | 220 | class MangaMediaAttributeResource < BaseResource
attributes :high_vote_count, :low_vote_count, :neutral_vote_count
has_one :anime
has_one :media_attribute
has_many :media_attribute_votes
filter :anime_id
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/group_member_resource.rb | Ruby | apache-2.0 | 187 | the-future | 1,977 | class GroupMemberResource < BaseResource
include SortableByFollowing
include GroupActionLogger
attributes :rank, :unread_count, :hidden
filter :rank, apply: ->(records, values, _options) {
ranks = GroupMember.ranks.values_at(*values).compact
ranks = values if ranks.empty?
records.where(rank: ranks... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/activity_group_resource.rb | Ruby | apache-2.0 | 187 | the-future | 224 | class ActivityGroupResource < BaseResource
include ScopelessResource
model_name 'Feed::ActivityGroup'
# notifications
attributes :group, :is_seen, :is_read
has_many :activities, eager_load_on_include: false
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/community_recommendation_resource.rb | Ruby | apache-2.0 | 187 | the-future | 229 | class CommunityRecommendationResource < BaseResource
has_one :community_recommendation_request
has_one :media, polymorphic: true
has_many :reasons
filters :media_id, :media_type, :community_recommendation_request_id
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/comment_resource.rb | Ruby | apache-2.0 | 187 | the-future | 369 | # frozen_string_literal: true
class CommentResource < BaseResource
caching
attributes :content, :content_formatted, :blocked, :deleted_at, :likes_count,
:replies_count, :edited_at, :embed, :embed_url, :held_reason
has_one :user
has_one :post
has_one :parent
has_many :likes
has_many :replies
has_m... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/ama_resource.rb | Ruby | apache-2.0 | 187 | the-future | 536 | class AMAResource < BaseResource
attributes :description, :start_date, :end_date,
:ama_subscribers_count
has_one :author
has_one :original_post
has_many :ama_subscribers
filters :end_date, :start_date, :ama_subscribers_count
filter :status, apply: ->(records, values, _opts) {
values.inject(records... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/group_permission_resource.rb | Ruby | apache-2.0 | 187 | the-future | 313 | class GroupPermissionResource < BaseResource
include GroupActionLogger
attribute :permission
has_one :group_member
log_verb do |action|
case action
when :create then 'granted'
when :remove then 'revoked'
end
end
log_target :group_member, :user
log_group :group_member, :group
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/post_resource.rb | Ruby | apache-2.0 | 187 | the-future | 1,097 | # frozen_string_literal: true
class PostResource < BaseResource
caching
IMMUTABLE_ATTRIBUTES = %i[locked_at locked_reason].freeze
IMMUTABLE_FIELDS = (IMMUTABLE_ATTRIBUTES + %i[locked_by]).freeze
attributes :content, :content_formatted, :comments_count, :post_likes_count,
:spoiler, :nsfw, :blocked, :delete... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/casting_resource.rb | Ruby | apache-2.0 | 187 | the-future | 952 | class CastingResource < BaseResource
attributes :role, :voice_actor, :featured, :language
key_type :string
model_hint model: MediaCasting, resource: :casting
exclude_links :default
has_one :media, polymorphic: true, exclude_links: :default
has_one :character, exclude_links: :default
has_one :person, excl... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/person_resource.rb | Ruby | apache-2.0 | 187 | the-future | 327 | class PersonResource < BaseResource
attributes :name, :mal_id, :description
attribute :image, format: :shrine_attachment, delegate: :image_attacher
has_many :castings
has_many :staff
has_many :voices
def mal_id
'Moved to mappings relationship.'
end
def description
_model.description['en']
e... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/stat_resource.rb | Ruby | apache-2.0 | 187 | the-future | 632 | class StatResource < BaseResource
immutable
caching
include STIResource
# STI, put all inheritance here
model_hint model: Stat::AnimeCategoryBreakdown
model_hint model: Stat::MangaCategoryBreakdown
model_hint model: Stat::AnimeAmountConsumed
model_hint model: Stat::MangaAmountConsumed
model_hint mode... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/group_ban_resource.rb | Ruby | apache-2.0 | 187 | the-future | 387 | class GroupBanResource < BaseResource
include GroupActionLogger
attributes :notes, :notes_formatted
has_one :group
has_one :user
has_one :moderator
filter :group
log_verb do |action|
case action
when :create then 'banned'
when :remove then 'unbanned'
end
end
log_target :user
bef... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/list_import_resource.rb | Ruby | apache-2.0 | 187 | the-future | 658 | # frozen_string_literal: true
class ListImportResource < BaseResource
include STIResource
model_hint model: ListImport::MyAnimeListXML
model_hint model: ListImport::MyAnimeList
model_hint model: ListImport::AnimePlanet
model_hint model: ListImport::Anilist
model_hint model: ListImport::Aozora
# Paramet... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/block_resource.rb | Ruby | apache-2.0 | 187 | the-future | 958 | class BlockResource < BaseResource
has_one :user
has_one :blocked
filter :user
def records_for(relation_name)
return super unless relation_name == :user
_model.public_send relation_name
end
def self.preload_included_fragments(resources, records, serializer, options)
super
includes = opti... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/media_production_resource.rb | Ruby | apache-2.0 | 187 | the-future | 279 | class MediaProductionResource < BaseResource
immutable
attribute :role
has_one :media, polymorphic: true
has_one :company
filter :role, apply: ->(records, values, _opts) {
values = values.map { |v| records.roles[v] || v }
records.where(roles: values)
}
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/upload_resource.rb | Ruby | apache-2.0 | 187 | the-future | 406 | class UploadResource < BaseResource
include ScopelessResource
include RankedResource
attribute :content, format: :shrine_attachment
attribute :upload_order
ranks :upload_order
def content
_model.content_attacher
end
def content=(value)
_model.content_data_uri = value
end
has_one :user
... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/media_character_resource.rb | Ruby | apache-2.0 | 187 | the-future | 299 | class MediaCharacterResource < BaseResource
immutable
attribute :role
has_one :media, polymorphic: true
has_one :character
has_many :voices
filter :role, apply: ->(records, values, _opts) {
values = values.map { |v| records.roles[v] || v }
records.where(roles: values)
}
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/group_neighbor_resource.rb | Ruby | apache-2.0 | 187 | the-future | 330 | class GroupNeighborResource < BaseResource
include GroupActionLogger
has_one :source
has_one :destination
filters :source, :destination
log_verb do |action|
case action
when :create then 'added_neighbor'
when :remove then 'removed_neighbor'
end
end
log_target :destination
log_group :s... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/anime_resource.rb | Ruby | apache-2.0 | 187 | the-future | 1,034 | # frozen_string_literal: true
class AnimeResource < MediaResource
include EpisodicResource
attributes :youtube_video_id
attribute :show_type # DEPRECATED
attribute :nsfw, delegate: :nsfw?
has_many :streaming_links
has_many :anime_productions
has_many :anime_characters
has_many :anime_staff
# Elasti... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/linked_account_resource.rb | Ruby | apache-2.0 | 187 | the-future | 331 | class LinkedAccountResource < BaseResource
include STIResource
model_hint model: LinkedAccount::MyAnimeList
model_hint model: LinkedAccount::YoutubeChannel
attributes :external_user_id, :token, :share_to, :share_from, :sync_to,
:disabled_reason
has_one :user
has_many :library_entry_logs
filters :u... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/comment_like_resource.rb | Ruby | apache-2.0 | 187 | the-future | 210 | class CommentLikeResource < BaseResource
caching
has_one :comment
has_one :user
filter :comment_id
filter :user_id
def self.default_sort
[{ field: 'created_at', direction: :desc }]
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/media_resource.rb | Ruby | apache-2.0 | 187 | the-future | 4,231 | class MediaResource < BaseResource
include SluggableResource
abstract
# This regex accepts a numerical range or single number
# $1 = start, $2 = dot representing closed/open, $3 = end
NUMBER = /(\d+(?:\.\d+)?)/
NUMERIC_RANGE = /\A#{NUMBER}?(\.{2,3})?#{NUMBER}?\z/
NUMERIC_QUERY = {
valid: ->(value, _... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/media_attribute_vote_resource.rb | Ruby | apache-2.0 | 187 | the-future | 234 | class MediaAttributeVoteResource < BaseResource
attribute :vote
has_one :anime_media_attributes
has_one :manga_media_attributes
has_one :dramas_media_attributes
has_one :user
filters :created_at, :user_id, :media_id
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/activity_resource.rb | Ruby | apache-2.0 | 187 | the-future | 595 | class ActivityResource < BaseResource
include ScopelessResource
model_name 'Feed::Activity'
attributes :status, :verb, :time, :stream_id, :foreign_id, :rating,
:progress, :reply_to_type, :reply_to_user, :nineteen_scale, :mentioned_users, :reason
has_one :actor, polymorphic: true, eager_load_on_include: f... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/video_resource.rb | Ruby | apache-2.0 | 187 | the-future | 288 | class VideoResource < BaseResource
caching
attributes :url, :sub_lang, :dub_lang, :embed_data
attributes :subs, :dubs, :regions
attribute :available_regions, delegate: :regions # DEPRECATED
has_one :episode
has_one :streamer
filters :sub_lang, :dub_lang, :episode_id
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/community_recommendation_request_resource.rb | Ruby | apache-2.0 | 187 | the-future | 225 | class CommunityRecommendationRequestResource < BaseResource
attributes :title, :description
has_one :user
has_many :community_recommendations
filter :user_id
def description
_model.description['en']
end
end |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/group_report_resource.rb | Ruby | apache-2.0 | 187 | the-future | 474 | class GroupReportResource < BaseResource
include GroupActionLogger
attributes :reason, :status, :explanation, :naughty_type, :naughty_id
has_one :group
has_one :naughty, polymorphic: true
has_one :user
has_one :moderator
filters :group, :user, :naughty, :naughty_type, :reason
filter :status, verify: ... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/concerns/sortable_by_following.rb | Ruby | apache-2.0 | 187 | the-future | 544 | module SortableByFollowing
extend ActiveSupport::Concern
class_methods do
def sortable_fields(context)
if context[:current_user]
super(context) + %i[following]
else
super(context)
end
end
def sort_records(records, order_options, options = {})
if order_options.de... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/concerns/algolia_searchable_resource.rb | Ruby | apache-2.0 | 187 | the-future | 6,610 | module AlgoliaSearchableResource
extend ActiveSupport::Concern
class_methods do
attr_reader :_algolia_index, :_query_fields
# Declare the Algolia index to use when searching this resource
def algolia_index(index)
@_algolia_index = index
end
def inherited(subclass)
subclass.instanc... |
github | hummingbird-me/kitsu-server | https://github.com/hummingbird-me/kitsu-server | app/resources/concerns/group_action_logger.rb | Ruby | apache-2.0 | 187 | the-future | 1,104 | module GroupActionLogger
extend ActiveSupport::Concern
def handle_log_action(action)
# Get log target, group
target = action_log_target.inject(_model, :public_send)
group = (action_log_group || %i[group]).inject(_model, :public_send)
# Execute to generate verb
verbs = [_model.instance_exec(acti... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.