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 | osunyorg/admin | https://github.com/osunyorg/admin | app/controllers/api/osuny/communication/medias_controller.rb | Ruby | mit | 48 | main | 1,390 | class Api::Osuny::Communication::MediasController < Api::Osuny::ApplicationController
before_action :create_blob, only: :create
def show
@media = current_university.communication_medias.find(params[:id])
end
def create
@media = Communication::Media.create_from_blob(@blob)
if @media.persisted?
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/controllers/api/osuny/communication/websites/application_controller.rb | Ruby | mit | 48 | main | 277 | class Api::Osuny::Communication::Websites::ApplicationController < Api::Osuny::ApplicationController
before_action :load_website
protected
def load_website
@website = current_university.websites.find params[:website_id]
end
def website
@website
end
end |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/controllers/api/osuny/communication/websites/posts_controller.rb | Ruby | mit | 48 | main | 3,851 | class Api::Osuny::Communication::Websites::PostsController < Api::Osuny::Communication::Websites::ApplicationController
include Api::Osuny::HasResource
include Api::Osuny::HasMigrationIdentifier
def index
@posts = paginate(website.posts.includes(:localizations))
end
def show
end
def create
@pos... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/controllers/api/osuny/communication/websites/pages_controller.rb | Ruby | mit | 48 | main | 4,052 | class Api::Osuny::Communication::Websites::PagesController < Api::Osuny::Communication::Websites::ApplicationController
include Api::Osuny::HasResource
include Api::Osuny::HasMigrationIdentifier
def index
@pages = paginate(website.pages.includes(:localizations))
end
def show
end
def create
@pag... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/controllers/api/osuny/communication/websites/portfolio/projects_controller.rb | Ruby | mit | 48 | main | 4,159 | class Api::Osuny::Communication::Websites::Portfolio::ProjectsController < Api::Osuny::Communication::Websites::ApplicationController
include Api::Osuny::HasResource
include Api::Osuny::HasMigrationIdentifier
def index
@projects = paginate(website.portfolio_projects.includes(:localizations))
end
def sho... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/controllers/api/osuny/communication/websites/portfolio/categories_controller.rb | Ruby | mit | 48 | main | 4,162 | class Api::Osuny::Communication::Websites::Portfolio::CategoriesController < Api::Osuny::Communication::Websites::ApplicationController
include Api::Osuny::HasResource
include Api::Osuny::HasMigrationIdentifier
def index
@categories = paginate(website.portfolio_categories.includes(:localizations))
end
d... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/controllers/api/osuny/communication/websites/pages/categories_controller.rb | Ruby | mit | 48 | main | 4,099 | class Api::Osuny::Communication::Websites::Pages::CategoriesController < Api::Osuny::Communication::Websites::ApplicationController
include Api::Osuny::HasResource
include Api::Osuny::HasMigrationIdentifier
def index
@categories = paginate(website.page_categories.includes(:localizations))
end
def show
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/controllers/api/osuny/communication/websites/posts/categories_controller.rb | Ruby | mit | 48 | main | 4,099 | class Api::Osuny::Communication::Websites::Posts::CategoriesController < Api::Osuny::Communication::Websites::ApplicationController
include Api::Osuny::HasResource
include Api::Osuny::HasMigrationIdentifier
def index
@categories = paginate(website.post_categories.includes(:localizations))
end
def show
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/controllers/api/osuny/communication/websites/agenda/events_controller.rb | Ruby | mit | 48 | main | 6,031 | class Api::Osuny::Communication::Websites::Agenda::EventsController < Api::Osuny::Communication::Websites::ApplicationController
include Api::Osuny::HasResource
include Api::Osuny::HasMigrationIdentifier
def index
@events = paginate(website.events.includes(:localizations))
end
def show
end
def crea... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/controllers/api/osuny/communication/websites/agenda/categories_controller.rb | Ruby | mit | 48 | main | 4,114 | class Api::Osuny::Communication::Websites::Agenda::CategoriesController < Api::Osuny::Communication::Websites::ApplicationController
include Api::Osuny::HasResource
include Api::Osuny::HasMigrationIdentifier
def index
@categories = paginate(website.agenda_categories.includes(:localizations))
end
def sho... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/controllers/api/osuny/university/organizations_controller.rb | Ruby | mit | 48 | main | 4,442 | class Api::Osuny::University::OrganizationsController < Api::Osuny::ApplicationController
include Api::Osuny::HasResource
include Api::Osuny::HasMigrationIdentifier
def index
@organizations = paginate(current_university.organizations.includes(:localizations))
end
def show
end
def create
@organi... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/controllers/api/osuny/university/organizations/categories_controller.rb | Ruby | mit | 48 | main | 4,070 | class Api::Osuny::University::Organizations::CategoriesController < Api::Osuny::ApplicationController
include Api::Osuny::HasResource
include Api::Osuny::HasMigrationIdentifier
def index
@categories = paginate(current_university.organization_categories.includes(:localizations))
end
def show
end
def... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/controllers/api/osuny/server/websites_controller.rb | Ruby | mit | 48 | main | 400 | class Api::Osuny::Server::WebsitesController < Api::Osuny::ApplicationController
skip_before_action :verify_app_token
before_action :verify_autoupdate_theme_key
def theme_released
Communication::Website.autoupdate_websites
end
def verify_autoupdate_theme_key
render_forbidden if params[:secret_key].b... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/static.rb | Ruby | mit | 48 | main | 1,986 | class Static
DOOMED_CHARACTERS = [
"\u2028", # https://github.com/noesya/pixelis-rapportglobal2023/issues/1
"\u0094",
"\u008d", # https://github.com/osunyorg/lacriee-site/actions/runs/9242403369
"\u009D",
"\u0090", # https://github.com/osunyorg/marionrebier-beelearning/actions/runs/11340775264
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/deuxfleurs.rb | Ruby | mit | 48 | main | 1,434 | class Deuxfleurs
def create_bucket(host)
response = client.post("website/#{host}")
data = JSON.parse response.body
{
identifier: data.dig('vhost', 'name'),
access_key_id: data.dig('access_key_id'),
secret_access_key: data.dig('secret_access_key')
}
end
def rename_bucket(host, n... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/dependencies_filter.rb | Ruby | mit | 48 | main | 406 | class DependenciesFilter
# [
# "gid://osuny/Communication::Block/4ac9f6fe-80cd-46f6-becc-fc14b3fecea0",
# "gid://osuny/University::Person/36501bf0-99b9-58f9-b269-bf161b451c43"
# ]
def self.filtered(dependencies)
dependencies.select { |dependency| dependency.is_a?(ActiveRecord::Base) }
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/icon.rb | Ruby | mit | 48 | main | 3,604 | # used in menu items and in admin navigation
class Icon
DASHBOARD = 'fas fa-chart-line'
COMMUNICATION_AUTHOR = 'fas fa-users'
COMMUNICATION_EXTRANET = 'fas fa-project-diagram'
COMMUNICATION_WEBSITE = 'fas fa-sitemap'
COMMUNICATION_WEBSITE_HOME = 'fas fa-home'
COMMUNICATION_WEBSITE_LOCALIZATIONS = 'fas fa-g... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/locale_service.rb | Ruby | mit | 48 | main | 967 | class LocaleService
## Get best locale for a user
def self.locale(user, accept_language_header)
user&.language.nil? ? self.preferred_language(accept_language_header) : user.language.iso_code.to_sym
end
protected
def self.preferred_language(accept_language_header)
# browser_language > french
bro... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/screenshot.rb | Ruby | mit | 48 | main | 1,290 | class Screenshot
PUBLIC_API = 'https://api.microlink.io'.freeze
PRO_API = 'https://pro.microlink.io'.freeze
# https://microlink.io/docs/api/getting-started/overview
# https://api.microlink.io/?url=https://www.noesya.coop&screenshot=true&meta=false&device=Macbook%20Pro%2015
# {
# "status": "success",
# ... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/contact_details.rb | Ruby | mit | 48 | main | 1,202 | class ContactDetails
PARTS = [
:postal_address,
:phone_numbers,
:emails,
:websites,
:social_networks
]
SOCIAL_NETWORKS = [
:facebook,
:github,
:instagram,
:linkedin,
:mastodon,
:peertube,
:tiktok,
:twitter,
:vimeo,
:x,
:youtube
]
PHONES = [
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/polymorphic_object_finder.rb | Ruby | mit | 48 | main | 1,831 | class PolymorphicObjectFinder
# PolymorphicObjectFinder.find(
# params,
# key: :about,
# university: current_university,
# mandatory_module: Contentful
# )
# Rails uses ActiveRecord::Inheritance#polymorphic_name to hydrate the about_type.
# Example: A Block for a Communication::Website::Page::Ho... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/variant_service.rb | Ruby | mit | 48 | main | 3,764 | class VariantService
GRAVITIES = [
'top',
'right',
'bottom',
'left',
'center'
]
def self.manage(blob, params)
use_keycdn = params.dig(:keycdn) == 'true'
use_keycdn ? VariantService::KeyCdn.new(blob, params)
: VariantService::ActiveStorage.new(blob, params)
end
at... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/osuny/theme_info.rb | Ruby | mit | 48 | main | 397 | class Osuny::ThemeInfo
def self.get_current_version
URI("https://example.osuny.org/osuny-theme-version.txt").read
rescue
end
def self.get_current_sha
client.branch(ENV["GITHUB_WEBSITE_THEME_REPOSITORY"], ENV["GITHUB_WEBSITE_THEME_BRANCH"])[:commit][:sha]
end
private
def self.client
@client... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/osuny/breadcrumbs_on_rails_builder.rb | Ruby | mit | 48 | main | 792 | class Osuny::BreadcrumbsOnRailsBuilder < BreadcrumbsOnRails::Breadcrumbs::Builder
def render
return '' unless @elements.many?
html = '<nav aria-label="breadcrumb"><ol class="breadcrumb m-0">'
html += @elements.collect do |element|
render_element(element)
end.join('')
html += '</ol></nav>'
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/osuny/simple_navigation_renderer.rb | Ruby | mit | 48 | main | 2,227 | class Osuny::SimpleNavigationRenderer < SimpleNavigation::Renderer::Base
def render(item_container)
content = '<ul class="navbar-nav">'
item_container.items.each do |item|
content << make(item)
end
content << '</ul>'
content.html_safe
end
protected
def make(item)
has_sub_navigati... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/osuny/notes.rb | Ruby | mit | 48 | main | 1,837 | module Osuny
class Notes
attr_reader :index
def initialize
@index = 1
end
def prepare(text)
@text = text
@parts = @text.split('<note>')
@text_with_notes = ''
replace_notes! if @parts.any?
@text_with_notes.html_safe
end
protected
def replace_notes!
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/osuny/address_formatter.rb | Ruby | mit | 48 | main | 2,387 | class Osuny::AddressFormatter
attr_reader :about, :l10n, :language
def initialize(about:, l10n: nil, language:)
@about = about
@l10n = l10n
@language = language
end
def present?
to_s.present?
end
def address
about.try(:address)
end
def address_name
l10n.try(:address_name)
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/osuny/search.rb | Ruby | mit | 48 | main | 763 | class Osuny::Search
attr_reader :term, :university, :language, :website, :extranet
def initialize(term, university, language, website: nil, extranet: nil)
@term = term
@university = university
@language = language
@website = website
@extranet = extranet
end
def results
term.present? ?... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/osuny/sanitizer.rb | Ruby | mit | 48 | main | 833 | class Osuny::Sanitizer
include ActionView::Helpers::SanitizeHelper
self.sanitized_allowed_tags = Rails.application.config.action_view.sanitized_allowed_tags
self.sanitized_allowed_attributes = Rails.application.config.action_view.sanitized_allowed_attributes
# type(ActiveRecord) = ['text', 'string']
def sel... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/osuny/api/migration_identifier_integrity_checker.rb | Ruby | mit | 48 | main | 598 | module Osuny::Api
class MigrationIdentifierIntegrityChecker
attr_reader :resource, :params, :list
def initialize(resource, params, list)
@resource = resource
@params = params
@list = list
end
def migration_identifier
@migration_identifier ||= params.dig(:migration_identi... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/osuny/media/resizer.rb | Ruby | mit | 48 | main | 1,530 | # Resize a blob, coming from Vue advanced cropper
# answers with another blob (or the same if untouched)
class Osuny::Media::Resizer
attr_reader :blob, :params
def initialize(blob, params)
@blob = blob
@params = params
end
def to_json
{
id: resized_blob.id,
signed_id: resized_blob.sign... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/osuny/media/picker.rb | Ruby | mit | 48 | main | 2,008 | class Osuny::Media::Picker
attr_accessor :university, :language, :params, :about, :key
def initialize(about: nil)
@about = about unless about.nil?
end
def params=(value)
@params = value
import_from_params
end
def to_hash
{
about: {
type: about.class.polymorphic_name,
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/osuny/media/picker/origins.rb | Ruby | mit | 48 | main | 3,522 | class Osuny::Media::Picker::Origins
attr_reader :picker
delegate :params, :university, :about, :image, :image_property, :alt, :credit,
to: :picker
def initialize(picker)
@picker = picker
end
# Empty origins, for initialization purpose
def to_hash
{
blob: {
id: '',
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/git/orphan_and_layout_analyzer.rb | Ruby | mit | 48 | main | 1,828 | # Orphans
# Les orphelins sont les fichiers du référentiel Git, dans content,
# qui ne proviennent pas d'un git_file d'Osuny.
# Cela peut être normal, mais cela peut être aussi des fichiers mal supprimés.
#
# Layouts
# Les fichiers de layouts sont les surcharges (override) du thème.
class Git::OrphanAndLayoutAnalyzer
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/git/repository.rb | Ruby | mit | 48 | main | 2,532 | class Git::Repository
attr_accessor :git_files
attr_reader :website
def initialize(website)
@website = website
@git_files = []
end
def url
provider.url
end
def batch_size
provider.class::COMMIT_BATCH_SIZE
end
def sync!
return if git_files.empty?
puts "Start sync"
synchr... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/git/analyzer.rb | Ruby | mit | 48 | main | 709 | # Analyzer est utilisé pour envoyer les fichiers vers les référentiels Git
class Git::Analyzer
attr_accessor :git_file
attr_reader :repository
def initialize(repository)
@repository = repository
end
def should_create?
!should_destroy? && !exists?(git_file.current_path) && !moved?
end
def should... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/git/providers/github.rb | Ruby | mit | 48 | main | 4,207 | class Git::Providers::Github < Git::Providers::Abstract
BASE_URL = "https://github.com".freeze
COMMIT_BATCH_SIZE = 30
include WithSecrets
include WithTheme
def url
"#{BASE_URL}/#{repository}"
end
def create_file(path, content)
batch << {
path: path,
mode: '100644', # https://docs.gi... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/git/providers/abstract.rb | Ruby | mit | 48 | main | 1,626 | class Git::Providers::Abstract
attr_reader :git_repository, :endpoint, :branch, :access_token, :repository
def initialize(git_repository)
@git_repository = git_repository
@endpoint = git_repository.website.git_endpoint
@branch = git_repository.website.git_branch
@access_token = git_repository.websi... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/git/providers/gitlab.rb | Ruby | mit | 48 | main | 2,544 | class Git::Providers::Gitlab < Git::Providers::Abstract
DEFAULT_ENDPOINT = 'https://gitlab.com/api/v4'.freeze
COMMIT_BATCH_SIZE = 75
def url
base_url = endpoint.gsub("/api/v4", "")
"#{base_url}/#{repository}"
end
def create_file(path, content)
batch << {
action: 'create',
file_path: ... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/git/providers/github/with_theme.rb | Ruby | mit | 48 | main | 491 | module Git::Providers::Github::WithTheme
extend ActiveSupport::Concern
def update_theme
batch << {
path: ENV["GITHUB_WEBSITE_THEME_PATH"],
mode: '160000',
type: 'commit',
sha: current_theme_sha
} if previous_theme_sha != current_theme_sha
end
protected
def current_theme_sha
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/git/providers/github/with_secrets.rb | Ruby | mit | 48 | main | 1,027 | module Git::Providers::Github::WithSecrets
extend ActiveSupport::Concern
def update_secrets(secrets)
secrets.each do |secret_key, secret_value|
encrypted_secret_options = encrypt_secret_value(secret_value)
client.create_or_update_actions_secret(repository, secret_key, encrypted_secret_options)
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/variant_service/active_storage.rb | Ruby | mit | 48 | main | 1,681 | class VariantService::ActiveStorage < VariantService
GRAVITY_PER_CROP = {
'top' => 'North',
'right' => 'East',
'bottom' => 'South',
'left' => 'West',
'center' => 'Center'
}
# FIXME Problem with host missing when called outside controller
def url
Rails.application.routes.url_helpers.url_... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/variant_service/key_cdn.rb | Ruby | mit | 48 | main | 1,442 | class VariantService::KeyCdn < VariantService
def url
"https://#{keycdn_host}/#{blob.key}?#{query_string}"
end
def params
@params ||= begin
params = {}
if should_resize?
if should_crop?
set_params_for_crop(params)
elsif variant_width.present?
params[:width... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/migrations/clean_git_files.rb | Ruby | mit | 48 | main | 801 | class Migrations::CleanGitFiles
def self.migrate
puts 'Migrations::CleanGitFiles'
new
end
def initialize
all_triplets.each do |about_type, about_id, website_id|
there_should_be_only_one(about_type, about_id, website_id)
end
end
def all_triplets
Communication::Website::GitFile.disti... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/licenses/creative_commons.rb | Ruby | mit | 48 | main | 1,868 | class Licenses::CreativeCommons
attr_reader :attribution, :commercial_use, :derivatives, :sharing
def self.create_from_block(block)
new block.template.creative_commons_attribution,
block.template.creative_commons_commercial_use,
block.template.creative_commons_derivatives,
block.templat... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/gdpr/user_deletion_service.rb | Ruby | mit | 48 | main | 1,226 | class Gdpr::UserDeletionService
DAYS_BEFORE_DELETION = 1095
WARNING_DELAY = 30
DAYS_BEFORE_WARNING = DAYS_BEFORE_DELETION - WARNING_DELAY
def handle_users
alert_users
delete_users
end
private
def users_to_alert
@users_to_alert ||= involved_users.where(current_sign_in_at: alert_period)
end... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/simple_navigation/bootstrap_renderer.rb | Ruby | mit | 48 | main | 1,386 | class SimpleNavigation::BootstrapRenderer < SimpleNavigation::Renderer::Base
def render(item_container)
# Prefix unfrozen strings with "+"
# Source: https://docs.rubocop.org/rubocop-performance/cops_performance.html#performanceunfreezestring
content = +'<ul class="navbar-nav">'
item_container.items.ea... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/simple_navigation/renderer/osuny/feature_nav.rb | Ruby | mit | 48 | main | 491 | module SimpleNavigation
module Renderer
module Osuny
class FeatureNav < SimpleNavigation::Renderer::Base
def render(item_container)
html = '<div class="feature-nav">'
item_container.items.each do |item|
html += item.selected? ? "<h1>#{item.name}</h1>"
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/simple_form/custom_inputs/tree_input.rb | Ruby | mit | 48 | main | 1,738 | module SimpleForm::CustomInputs
class TreeInput < SimpleForm::Inputs::CollectionCheckBoxesInput
def input(wrapper_options = nil)
html = "<fieldset class=\"mb-3 tree optional #{input_class}\">"
html += "<input type=\"hidden\" name=\"#{object_name}[#{attribute_name}][]\" value=\"\" autocomplete=\"off\"... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/faceted_search/facets/text.rb | Ruby | mit | 48 | main | 315 | module FacetedSearch
class Facets::Text < Facets::Default
include ActiveRecord::Sanitization
def placeholder
@options[:placeholder]
end
def add_scope(scope)
return scope if params.blank?
language = facets.language
scope.for_search_term(params, language)
end
end
end |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/faceted_search/facets/taxonomy.rb | Ruby | mit | 48 | main | 2,463 | module FacetedSearch
class Facets::Taxonomy < Facets::List
attr_reader :l10n, :taxonomy, :language, :university
def initialize(name, params, facets, options)
@name = name
@params = params
@facets = facets
@options = options
@l10n = options[:l10n]
@taxonomy = @l10n.about
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/background_jobs/analyzer.rb | Ruby | mit | 48 | main | 1,360 | class BackgroundJobs::Analyzer
def jobs
@jobs ||= GoodJob::Job.where(finished_at: nil)
end
def universities
unless @universities
extract_universities
extract_websites
sort_everything
end
@universities
end
protected
def labels
@labels ||= jobs.pluck(:labels).flatten.... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/contact_details/twitter.rb | Ruby | mit | 48 | main | 425 | class ContactDetails::Twitter < ContactDetails::SocialNetwork
protected
def url
'https://x.com/'
end
def handle
@handle ||= @string.remove('https://')
.remove('http://')
.remove('www.')
.remove('x.com')
.... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/contact_details/base.rb | Ruby | mit | 48 | main | 342 | class ContactDetails::Base
attr_accessor :value, :label
def initialize(string)
@string = string.to_s
return if @string.blank?
prepare_value
prepare_label
end
def present?
value.present?
end
protected
def prepare_value
@value = @string.dup
end
def prepare_label
@label =... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/contact_details/vimeo.rb | Ruby | mit | 48 | main | 384 | class ContactDetails::Vimeo < ContactDetails::SocialNetwork
protected
def url
'https://vimeo.com/'
end
def handle
@handle ||= @string.remove('https://')
.remove('http://')
.remove('www.')
.remove('vimeo.com')
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/contact_details/country.rb | Ruby | mit | 48 | main | 409 | class ContactDetails::Country < ContactDetails::Base
protected
def prepare_label
@label = country&.common_name || @string.to_s.titleize
end
def prepare_value
@value = country&.alpha2 || @string.to_s[0..1].upcase
end
def country
if @string.in? ISO3166::Country.codes
ISO3166::Country[@st... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/contact_details/facebook.rb | Ruby | mit | 48 | main | 397 | class ContactDetails::Facebook < ContactDetails::SocialNetwork
protected
def url
'https://www.facebook.com/'
end
def handle
@handle ||= @string.remove('https://')
.remove('http://')
.remove('www.')
.remove('facebook.com')
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/contact_details/website.rb | Ruby | mit | 48 | main | 456 | class ContactDetails::Website < ContactDetails::Base
PROTOCOL = 'https://'
protected
def prepare_value
super
if @value.start_with?('http://')
# Do nothing, this is oldie
elsif !@value.start_with?(PROTOCOL)
# www.test.com -> https://www.test.com
@value = "#{PROTOCOL}#{@value}"
e... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/contact_details/tiktok.rb | Ruby | mit | 48 | main | 392 | class ContactDetails::Tiktok < ContactDetails::SocialNetwork
protected
def url
'https://www.tiktok.com/@'
end
def handle
@handle ||= @string.remove('https://')
.remove('http://')
.remove('www.')
.remove('tiktok.com')
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/contact_details/instagram.rb | Ruby | mit | 48 | main | 396 | class ContactDetails::Instagram < ContactDetails::SocialNetwork
protected
def url
'https://instagram.com/'
end
def handle
@handle ||= @string.remove('https://')
.remove('http://')
.remove('www.')
.remove('instagram.com')
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/contact_details/youtube.rb | Ruby | mit | 48 | main | 439 | class ContactDetails::Youtube < ContactDetails::SocialNetwork
protected
def url
'https://www.youtube.com/@'
end
def handle
@handle ||= @string.remove('https://')
.remove('http://')
.remove('www.')
.remove('youtube.com')
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/contact_details/phone.rb | Ruby | mit | 48 | main | 314 | class ContactDetails::Phone < ContactDetails::Base
protected
def prepare_value
super
[' ', '.', '-'].each do |string|
@value.remove! string
end
@value = "tel:#{@value}"
end
def prepare_label
super
['.', '-'].each do |string|
@label.gsub! string, ' '
end
end
end |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/contact_details/social_network.rb | Ruby | mit | 48 | main | 236 | class ContactDetails::SocialNetwork < ContactDetails::Base
protected
def url
''
end
def prepare_value
@value = "#{url}#{handle}"
end
def prepare_label
@label = handle
end
def handle
@string
end
end |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/contact_details/linkedin.rb | Ruby | mit | 48 | main | 615 | class ContactDetails::Linkedin < ContactDetails::Base
protected
def prepare_value
@value = @string.split('?')
.first
@value << '/' unless @value.end_with?('/')
@value
end
def prepare_label
@label = @string.remove('https://')
.remove('http://')
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/contact_details/github.rb | Ruby | mit | 48 | main | 394 | class ContactDetails::Github < ContactDetails::SocialNetwork
protected
def url
'https://github.com/'
end
def handle
@handle ||= @string.remove('https://')
.remove('http://')
.remove('www.')
.remove('github.com')
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/active_storage/utils.rb | Ruby | mit | 48 | main | 2,703 | module ActiveStorage
class Utils
FORMAT_LANDSCAPE = 'landscape'
FORMAT_PORTRAIT = 'portrait'
FORMAT_SQUARE = 'square'
def self.ratio(blob)
width, height = blob.metadata.values_at('width', 'height')
# No width or height, default ratio
return 1 if width.nil? || height.nil?
widt... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/tree/positioner.rb | Ruby | mit | 48 | main | 763 | class Tree::Positioner
attr_reader :university, :klass, :website
def initialize(university, klass, website: nil)
@university = university
@klass = klass
@website = website
end
def execute
@position = 1
update_position_in_tree(root_objects)
end
protected
def root_objects
unless ... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/static/text.rb | Ruby | mit | 48 | main | 454 | class Static::Text < Static::Default
# Pour info (pas utilisé)
# https://til.codes/escaping-special-characters-like-in-rails-html-views/
def prepared
unless @prepared
@prepared = @text.to_s.strip.dup
@prepared = @prepared.ortho
@prepared = strip_tags @prepared
@prepared = CGI.unescape... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/static/html.rb | Ruby | mit | 48 | main | 2,422 | class Static::Html < Static::Default
def prepared
unless @prepared
@prepared = @text.to_s.strip.dup
# Sanitize before clean_code, otherwise we remove the spans!
@prepared = sanitize @prepared
@prepared = @prepared.ortho
@prepared = remove_line_breaks @prepared
@prepared = clea... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/static/code.rb | Ruby | mit | 48 | main | 463 | class Static::Code < Static::Default
def prepared
unless @prepared
@prepared = @text.to_s.dup
@prepared = lazy_load_iframes @prepared
@prepared = remove_linebreak @prepared
@prepared = raw @prepared
end
@prepared
end
protected
def lazy_load_iframes(text)
doc = Nokogiri... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/static/default.rb | Ruby | mit | 48 | main | 1,053 | class Static::Default
include ActionView::Helpers
def initialize(text, depth: 1, about: nil, university: nil)
@text = text
@depth = depth
@about = about
@university = university
end
def prepared
raise NoMethodError, "You must implement the `prepared` method in #{self.class.name}"
end
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/communication/website/agenda/planner.rb | Ruby | mit | 48 | main | 1,592 | class Communication::Website::Agenda::Planner
attr_reader :website,
:time_scope,
:category,
:language,
:quantity,
:include_parents,
:include_children,
:include_recurring
def initialize( website:,
tim... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/communication/website/agenda/planner/events.rb | Ruby | mit | 48 | main | 1,318 | # Instanciated only by Communication::Website::Agenda::Planner
class Communication::Website::Agenda::Planner::Events
attr_reader :planner, :events
def initialize(planner, events)
@planner = planner
@events = events
end
def to_array
remove_time_slots!
remove_drafts!
filter_by_category!
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/communication/website/agenda/planner/time_slots.rb | Ruby | mit | 48 | main | 1,296 | # Instanciated only by Communication::Website::Agenda::Planner
class Communication::Website::Agenda::Planner::TimeSlots
attr_reader :planner, :time_slots
def initialize(planner, time_slots)
@planner = planner
@time_slots = time_slots
end
def to_array
remove_drafts!
filter_by_category!
appl... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/video/provider.rb | Ruby | mit | 48 | main | 425 | class Video::Provider
PROVIDERS = [
Arte,
Canalu,
Vimeo,
Youtube,
Dailymotion,
Peertube # Comes last because detection is less reliable
]
# Block is sent to cache metadata
def self.find(video_url, block = nil)
PROVIDERS.each do |provider_class|
provider = provider_class.new(v... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/video/provider/dailymotion.rb | Ruby | mit | 48 | main | 1,098 | class Video::Provider::Dailymotion < Video::Provider::Default
DOMAINS = [
'dailymotion.com',
'www.dailymotion.com',
'geo.dailymotion.com',
'dai.ly',
'*.dmcdn.net'
]
def identifier
video_url.include?('dai.ly') ? video_url.split('dai.ly/').last
: video_url... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/video/provider/arte.rb | Ruby | mit | 48 | main | 1,435 | class Video::Provider::Arte < Video::Provider::Default
DOMAINS = [
'arte.tv',
'www.arte.tv',
'api-cdn.arte.tv'
]
# https://www.arte.tv/fr/videos/121417-001-A/lala-ce/
def identifier
video_url.split('videos/').last.split('/').first
end
def language
video_url.split('arte.tv/').last.split... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/video/provider/default.rb | Ruby | mit | 48 | main | 1,293 | class Video::Provider::Default
DOMAINS = []
attr_reader :video_url, :block
include ActionView::Helpers::TagHelper
def initialize(video_url, block = nil)
@video_url = video_url
@block = block
end
def platform
self.class.name.demodulize.downcase.to_sym
end
def iframe_url
video_url
e... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/video/provider/youtube.rb | Ruby | mit | 48 | main | 2,588 | class Video::Provider::Youtube < Video::Provider::Default
DOMAINS = [
'youtube.com',
'www.youtube.com',
'img.youtube.com',
'youtu.be',
'youtube-nocookie.com',
'www.youtube-nocookie.com',
]
STRATEGIES = [
:share,
:live,
:embed,
:short,
:channel
]
def identifier
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/video/provider/vimeo.rb | Ruby | mit | 48 | main | 836 | class Video::Provider::Vimeo < Video::Provider::Default
DOMAINS = [
'vimeo.com',
'player.vimeo.com',
'vumbnail.com'
]
def identifier
video_url.chomp('/').split('/').last
end
def csp_domains
DOMAINS
end
# https://vumbnail.com/621585396.jpg
def poster
"https://vumbnail.com/#{ide... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/video/provider/peertube.rb | Ruby | mit | 48 | main | 666 | class Video::Provider::Peertube < Video::Provider::Default
DOMAINS = [
'peertube.fr'
]
def identifier
video_url.split('/w/').last
end
# https://docs.joinpeertube.org/support/doc/api/embeds#quick-start
def iframe_url
"#{instance}/videos/embed/#{identifier}"
end
def correct?
url_in_doma... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/video/provider/canalu.rb | Ruby | mit | 48 | main | 1,523 | class Video::Provider::Canalu < Video::Provider::Default
DOMAINS = [
'canal-u.tv',
'www.canal-u.tv',
'vod.canal-u.tv'
]
def identifier
@identifier ||= find_identifier_in_oembed
end
def csp_domains
DOMAINS
end
# https://vod.canal-u.tv/videos/2026/04/112669/iran_entre_deux_feu-vf-1.jp... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/importers/alumni_cohorts.rb | Ruby | mit | 48 | main | 1,273 | module Importers
class AlumniCohorts < Base
def initialize(import)
@import = import
@language = import.language
@university = import.university
@connections = []
@errors = []
analyze_xlsx
manage_errors
save
send_extranet_invitation_emails
end
protect... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/importers/hash_to_alumnus.rb | Ruby | mit | 48 | main | 201 | module Importers
class HashToAlumnus < HashToPerson
def person
@person ||= begin
person = build_person
person.is_alumnus = true
person
end
end
end
end |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/importers/hash_to_person.rb | Ruby | mit | 48 | main | 5,117 | module Importers
class HashToPerson
NUMBER_OF_COLUMNS = 19
def initialize(university, language, hash)
@university = university
@language = language
@hash = hash
@error = nil
extract_person_variables
if valid?
person.save
add_picture_if_possible!(person)
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/importers/organizations.rb | Ruby | mit | 48 | main | 287 | module Importers
class Organizations < Base
protected
def analyze_hash(hash, index)
hash_to_organization = HashToOrganization.new(@university, @language, hash)
add_error(hash_to_organization.error, index + 1) unless hash_to_organization.valid?
end
end
end |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/importers/hash_to_cohort.rb | Ruby | mit | 48 | main | 2,060 | module Importers
class HashToCohort
def initialize(person, hash)
@university = person.university
@hash = hash
@error = nil
extract_variables
add_to_cohort(person, cohort) if valid?
end
def valid?
if school.nil?
@error = "School #{@school_id} not found"
el... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/importers/people.rb | Ruby | mit | 48 | main | 256 | module Importers
class People < Base
protected
def analyze_hash(hash, index)
hash_to_person = HashToPerson.new(@university, @language, hash)
add_error(hash_to_person.error, index + 1) unless hash_to_person.valid?
end
end
end |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/importers/base.rb | Ruby | mit | 48 | main | 1,360 | module Importers
class Base
def self.execute(import)
new(import)
end
def initialize(import)
@import = import
@language = import.language
@university = import.university
@errors = []
analyze_xlsx
manage_errors
save
end
protected
def xlsx
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/importers/hash_to_experience.rb | Ruby | mit | 48 | main | 3,234 | module Importers
class HashToExperience
def initialize(person, language, hash)
@person = person
@language = language
@university = person.university
@hash = hash
@error = nil
extract_variables
end
def valid?
if organization.nil?
@error = "Unable to create... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/importers/hash_to_organization.rb | Ruby | mit | 48 | main | 3,284 | module Importers
class HashToOrganization
def initialize(university, language, hash)
@university = university
@language = language
@hash = hash
@error = nil
extract_variables
save if valid?
end
def valid?
if country_not_found?
@error = "Country #{@country... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/importers/people_experiences.rb | Ruby | mit | 48 | main | 494 | module Importers
class PeopleExperiences < Base
protected
def analyze_hash(hash, index)
hash_to_person = HashToPerson.new(@university, @language, hash)
if hash_to_person.valid?
person = hash_to_person.person
hash_to_experience = HashToExperience.new(person, @language, hash)
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/importers/curator.rb | Ruby | mit | 48 | main | 1,992 | module Importers
class Curator
attr_reader :website, :user, :language, :url, :post, :l10n
def initialize(website, user, language, url)
@website = website
@user = user
@language = language
@url = url
unless slug_already_exists?
create_post!
set_post_author!
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/importers/hal.rb | Ruby | mit | 48 | main | 2,724 | module Importers
class Hal
# https://api.archives-ouvertes.fr/search/?q=03713859&fl=*
def self.import_publications_for_author(author)
fields = [
# '*',
'docid',
'title_s',
'citationRef_s',
'citationFull_s',
'uri_s',
'doiId_s',
'publication... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/importers/cleaner.rb | Ruby | mit | 48 | main | 2,483 | module Importers
class Cleaner
def self.html_to_string(html)
h = html
h = Importers::Cleaner.clean_html h
h = ActionController::Base.helpers.strip_tags h
h
end
def self.clean_string(string)
string = string.to_s
string = string.gsub(' ', ' ')
string = string... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/importers/api/osuny/communication/website/page.rb | Ruby | mit | 48 | main | 1,164 | class Importers::Api::Osuny::Communication::Website::Page < Importers::Api::Osuny::Communication::Website::Base
protected
def import
import_params
import_blocks
end
def import_params
object.title = Importers::Cleaner.clean_string params[:title]
object.summary = Importers::Cleaner.html_to_stri... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/importers/api/osuny/communication/website/base.rb | Ruby | mit | 48 | main | 1,313 | class Importers::Api::Osuny::Communication::Website::Base
attr_reader :university, :website, :params
def initialize(university:, website:, params:)
@university = university
@website = website
@params = params.to_unsafe_hash
import
end
protected
def import
raise NoMethodError, "You must... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/importers/api/osuny/communication/website/post.rb | Ruby | mit | 48 | main | 1,266 | class Importers::Api::Osuny::Communication::Website::Post < Importers::Api::Osuny::Communication::Website::Base
protected
def import
import_params
import_blocks
import_categories
end
def object
@object ||= website.posts.where(
university: university,
website: website,
migrat... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/importers/api/osuny/communication/website/agenda/event.rb | Ruby | mit | 48 | main | 1,642 | class Importers::Api::Osuny::Communication::Website::Agenda::Event < Importers::Api::Osuny::Communication::Website::Base
protected
def import
import_params
import_blocks
import_categories
import_featured_image
end
def object
@object ||= website.events.where(
university: university,
... |
github | osunyorg/admin | https://github.com/osunyorg/admin | app/services/brevo/contact_service.rb | Ruby | mit | 48 | main | 2,809 | module Brevo
class ContactService
def self.sync(user)
new(user).sync
end
def self.destroy(contact_id, university_id)
api_instance = Brevo::ContactsApi.new
other_user = User.where(brevo_contact_id: contact_id).first
# If another User uses this contact_id (as users of multiple ins... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.