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 | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/components/markdown/toc.rb | Ruby | bsd-3-clause | 99 | main | 1,214 | # Markdown::Toc == Markdown::TableOfContents
class Markdown::Toc < Markdown::Base
def view_template
@tree = []
visit(doc)
if @tree.any?
ul(class: "toc") do
@tree.each do |header, sub_headers|
li do
header_link(header)
if sub_headers.any?
ul do... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/components/markdown/article.rb | Ruby | bsd-3-clause | 99 | main | 2,385 | class Markdown::Article < Markdown::Application
prepend Markdown::AllowsErb
def header(header_level, &)
content = capture(&)
anchor = content.parameterize
send(:"h#{header_level}", id: anchor, class: "anchor group flex items-center") do
a(href: "##{anchor}", class: ["anchor-link not-prose"]) do
... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/components/markdown/allows_erb.rb | Ruby | bsd-3-clause | 99 | main | 1,684 | # DANGER! This parses Erb, which means arbitrary Ruby can be run. Make sure
# you trust the source of your markdown and that its not user input.
module Markdown::AllowsErb
ERB_TAGS = %r{s*<%.*?%>}
ERB_TAGS_START = %r{\A<%.*?%>}
def visit(node)
return if node.nil?
case node.type
in :paragraph
... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/components/dark_mode/switch.rb | Ruby | bsd-3-clause | 99 | main | 2,152 | module DarkMode
class Switch < ApplicationComponent
include PhlexConcerns::SvgTag
def initialize(enable_description: false, enable_outline: false)
@enable_description = enable_description
@enable_outline = enable_outline
end
def view_template
div(
data_controller: "darkmode... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/components/figures/image_tag.rb | Ruby | bsd-3-clause | 99 | main | 363 | class Figures::ImageTag < ApplicationComponent
include Phlex::Rails::Helpers::ImageTag
def initialize(src, title: "", alt: nil, **options)
@src = src
@title = title
@alt = alt
@options = options
end
def view_template
figure(**@options) do
image_tag(@src, title: @title, alt: @alt)
... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/components/figures/svg_tag.rb | Ruby | bsd-3-clause | 99 | main | 361 | class Figures::SvgTag < ApplicationComponent
include PhlexConcerns::SvgTag
def initialize(src, title: "", alt: nil, **options)
@src = src
@title = title
@alt = alt
@options = options
end
def view_template
figure(**@options) do
svg_tag(@src, title: @title, alt: @alt, **@options)
... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/components/pages/info.rb | Ruby | bsd-3-clause | 99 | main | 539 | module Pages
class Info < ApplicationComponent
attr_reader :title, :description, :request_path
def initialize(title:, description:, request_path:, **)
@title = title
@description = description
@request_path = request_path
end
def view_template
a(
href: request_path,
... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/components/pages/timestamp.rb | Ruby | bsd-3-clause | 99 | main | 969 | module Pages
class Timestamp < ApplicationComponent
include Phlex::Rails::Helpers::TimeTag
attr_accessor :published_on, :updated_on, :attributes
def initialize(published_on:, updated_on: nil, **attributes)
@published_on = published_on
@updated_on = updated_on
@attributes = attributes
... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/components/pages/topics.rb | Ruby | bsd-3-clause | 99 | main | 405 | module Pages
class Topics < ApplicationComponent
attr_reader :topics
def initialize(topics: [])
@topics = topics
end
def view_template
if topics.empty?
plain ""
return
end
topics.each do |topic|
a(href: topic_path(topic), class: "topic") do
... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/components/pages/summary.rb | Ruby | bsd-3-clause | 99 | main | 2,117 | module Pages
class Summary < ApplicationComponent
include Phlex::Rails::Helpers::TimeTag
include Phlex::Rails::Helpers::ImageTag
def self.from_page(page, **)
new(
title: page.title,
request_path: page.request_path,
description: page.description,
published_on: page.pu... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/components/pages/header.rb | Ruby | bsd-3-clause | 99 | main | 1,228 | module Pages
class Header < ApplicationComponent
attr_accessor :current_page, :title, :description, :published_on, :updated_on
def initialize(title: nil, description: nil, published_on: nil, updated_on: nil)
@title = title
@description = description
@published_on = published_on
@updat... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/components/pages/list.rb | Ruby | bsd-3-clause | 99 | main | 565 | module Pages
class List < ApplicationComponent
attr_reader :pages, :attributes
def initialize(pages, **attributes)
@pages = pages
@attributes = attributes
end
def view_template
div(**mix(attributes, class: "card-list grid grid-cols-1 grid-gap lg:grid-cols-3")) do
pages.each ... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/components/pages/card.rb | Ruby | bsd-3-clause | 99 | main | 1,415 | module Pages
class Card < ApplicationComponent
include Phlex::Rails::Helpers::ImageTag
attr_reader :title, :description, :image, :request_path
def initialize(title:, description:, image:, request_path:)
@title = title
@image = image
@description = description
@request_path = reque... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/components/phlex_concerns/flex_block.rb | Ruby | bsd-3-clause | 99 | main | 225 | module PhlexConcerns::FlexBlock
def flex_block(options = {}, &)
div(
**mix(options, class: "flex items-start flex-col space-col-4 grid-cols-12 md:items-center md:flex-row md:space-row-4"),
&
)
end
end |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/components/phlex_concerns/links.rb | Ruby | bsd-3-clause | 99 | main | 308 | module PhlexConcerns::Links
def link(url, title = "", **attrs, &)
extra_attrs = {}
unless url.blank? || url.start_with?("/", "#")
extra_attrs[:target] ||= "_blank"
extra_attrs[:rel] ||= "noopener noreferrer"
end
a(href: url, title: title, **extra_attrs, **attrs, &)
end
end |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/components/phlex_concerns/has_invisible_captcha.rb | Ruby | bsd-3-clause | 99 | main | 628 | module PhlexConcerns::HasInvisibleCaptcha
extend ActiveSupport::Concern
included do
# The following modules are needed to make Phlex components work with invisible_captcha
include InvisibleCaptcha::ViewHelpers
include Phlex::Rails::Helpers::ContentTag
include Phlex::Rails::Helpers::Request
incl... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/components/atom/entry_content.rb | Ruby | bsd-3-clause | 99 | main | 1,462 | # frozen_string_literal: true
# Atom::EntryContent knows how to render a Sitepress::Model as an Atom feed entry.
# It uses a different Markdown component to avoid rendering "fancy" elements in the atom feed.
# It post-processes the rendered HTML to
# - remove turbo-frames and replace them with a link
# - replace relat... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/pwa/install_button.rb | Ruby | bsd-3-clause | 99 | main | 1,663 | class Pwa::InstallButton < Phlex::HTML
include Phlex::Rails::Helpers::LinkTo
include Phlex::Rails::Helpers::Routes
include Phlex::Rails::Helpers::TurboFrameTag
include PhlexConcerns::SvgTag
include PhlexConcerns::FlexBlock
def view_template
div(data_controller: "pwa-installation") do
flex_block d... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/pwa/installation_instructions/select.rb | Ruby | bsd-3-clause | 99 | main | 1,010 | class Pwa::InstallationInstructions::Select < ApplicationComponent
include Phlex::Rails::Helpers::FormWith
def initialize(selected_nickname: nil)
@selected_nickname = selected_nickname
end
def view_template
form_with(url: pwa_installation_instructions_path, method: :get) do |f|
fieldset do
... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/share/snippets/toolbar.rb | Ruby | bsd-3-clause | 99 | main | 1,195 | class Share::Snippets::Toolbar < ApplicationComponent
include Phlex::Rails::Helpers::ButtonTo
include Phlex::Rails::Helpers::LinkTo
include PhlexConcerns::FlexBlock
attr_reader :snippet, :current_user
def initialize(snippet, current_user: nil)
@snippet = snippet
@current_user = current_user
end
... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/share/snippets/snippet.rb | Ruby | bsd-3-clause | 99 | main | 1,043 | module Share
module Snippets
class Snippet < ApplicationComponent
include Phlex::Rails::Helpers::DOMID
attr_accessor :current_user, :snippet, :attributes
def initialize(snippet, current_user: false, **attributes)
@snippet = snippet
@current_user = current_user
@attribut... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/share/polls/results.rb | Ruby | bsd-3-clause | 99 | main | 1,943 | module Share
module Polls
class Results < ApplicationComponent
include Phlex::Rails::Helpers::Pluralize
include Phlex::Rails::Helpers::DOMID
attr_reader :poll, :question
def initialize(poll, question)
@poll = poll
@question = question
end
def view_template
... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/share/polls/poll_component.rb | Ruby | bsd-3-clause | 99 | main | 814 | class Share::Polls::PollComponent < ApplicationComponent
include Phlex::Rails::Helpers::TurboFrameTag
attr_accessor :poll
def initialize(poll, completed: false)
@poll = poll
@completed = completed
end
def view_template
turbo_frame_tag poll, class: "poll joy-border-subtle rounded" do
heade... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/share/polls/question_component.rb | Ruby | bsd-3-clause | 99 | main | 743 | module Share
module Polls
class QuestionComponent < ApplicationComponent
include Phlex::Rails::Helpers::TurboFrameTag
include Phlex::Rails::Helpers::TurboStreamFrom
attr_reader :poll, :question
def initialize(poll, question, voted: false)
@poll = poll
@question = question... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/share/polls/lazy_page_poll.rb | Ruby | bsd-3-clause | 99 | main | 803 | module Share
module Polls
class LazyPagePoll < ApplicationComponent
include Phlex::Rails::Helpers::Provide
include Phlex::Rails::Helpers::TurboFrameTag
include Phlex::Rails::Helpers::TurboRefreshesWith
attr_reader :page, :title, :question_data
def initialize(page, title, question_da... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/share/polls/ballot.rb | Ruby | bsd-3-clause | 99 | main | 828 | module Share
module Polls
class Ballot < ApplicationComponent
include Phlex::Rails::Helpers::ButtonTo
include Phlex::Rails::Helpers::DOMID
include Phlex::Rails::Helpers::Pluralize
attr_reader :poll, :question
def initialize(poll, question, voted: false)
@poll = poll
... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/share/snippet_screenshots/form.rb | Ruby | bsd-3-clause | 99 | main | 1,339 | class Share::SnippetScreenshots::Form < ApplicationComponent
include Phlex::Rails::Helpers::DOMID
include Phlex::Rails::Helpers::FormWith
include Phlex::Rails::Helpers::TurboFrameTag
include Phlex::Rails::Helpers::Pluralize
attr_accessor :snippet
def initialize(snippet, auto: false)
@snippet = snippet... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/share/snippet_tweets/tweet.rb | Ruby | bsd-3-clause | 99 | main | 483 | class Share::SnippetTweets::Tweet < ApplicationComponent
include PhlexConcerns::FlexBlock
def initialize(snippet, auto: false)
@snippet = snippet
@auto = auto
end
def view_template
div(class: "snippet-tweet grid-content") do
render CodeBlock::Snippet.new(
@snippet,
screenshot... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/share/snippet_tweets/tweet_button.rb | Ruby | bsd-3-clause | 99 | main | 782 | class Share::SnippetTweets::TweetButton < ApplicationComponent
def initialize(snippet, auto: false)
@snippet = snippet
@auto = auto
end
def view_template
a(
href: tweet_url,
data: {
controller: "snippet-tweet",
action: "click->snippet-tweet#tweet",
snippet_tweet_au... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/layouts/application_layout.rb | Ruby | bsd-3-clause | 99 | main | 506 | # frozen_string_literal: true
class ApplicationLayout < ApplicationView
include Phlex::Rails::Layout
def view_template(&block)
doctype
html do
head do
title { "You're awesome" }
meta name: "viewport", content: "width=device-width,initial-scale=1"
csp_meta_tag
csrf_me... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/settings/color_schemes/preview_view.rb | Ruby | bsd-3-clause | 99 | main | 3,247 | # frozen_string_literal: true
class Settings::ColorSchemes::PreviewView < ApplicationView
include Phlex::Rails::Helpers::FormWith
include Phlex::Rails::Helpers::LinkTo
include Phlex::Rails::Helpers::ButtonTo
include Phlex::Rails::Helpers::TurboFrameTag
include Settings::ColorSchemes::PreviewRemarks
def i... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/settings/color_schemes/show_view.rb | Ruby | bsd-3-clause | 99 | main | 6,155 | # frozen_string_literal: true
class Settings::ColorSchemes::ShowView < ApplicationView
include Phlex::Rails::Helpers::ButtonTo
include Phlex::Rails::Helpers::ContentFor
include Phlex::Rails::Helpers::FormWith
include Phlex::Rails::Helpers::LinkTo
include Phlex::Rails::Helpers::TurboFrameTag
include Settin... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/settings/color_schemes/preview_remarks.rb | Ruby | bsd-3-clause | 99 | main | 468 | # frozen_string_literal: true
module Settings::ColorSchemes::PreviewRemarks
def preview_remarks = [
"Nice choice!",
"Great pick!",
"Looking good!",
"I like this one!",
"This one’s a keeper!",
"Check this one out!",
"One of my favorites.",
"Ooo, I like this one!",
"Now we’re talkin... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/settings/color_schemes/select.rb | Ruby | bsd-3-clause | 99 | main | 1,595 | # frozen_string_literal: true
class Settings::ColorSchemes::Select < ApplicationComponent
include Phlex::Rails::Helpers::FormWith
include Phlex::Rails::Helpers::LinkTo
include PhlexConcerns::FlexBlock
def initialize(settings:, preview_color_scheme:, color_scheme_options: [])
@settings = settings
@pre... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/settings/syntax_highlights/form.rb | Ruby | bsd-3-clause | 99 | main | 6,890 | class Settings::SyntaxHighlights::Form < ApplicationView
include Phlex::Rails::Helpers::FormWith
include Phlex::Rails::Helpers::LinkTo
include Phlex::Rails::Helpers::ButtonTo
include Phlex::Rails::Helpers::ContentFor
include Phlex::Rails::Helpers::StylesheetLinkTag
include Phlex::Rails::Helpers::TurboFrameT... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/settings/syntax_highlights/show_view.rb | Ruby | bsd-3-clause | 99 | main | 1,087 | class Settings::SyntaxHighlights::ShowView < ApplicationView
include Phlex::Rails::Helpers::TurboFrameTag
def initialize(
settings:,
available_highlights:,
preview_syntax_highlight:,
session_syntax_highlight:,
default_syntax_highlight:
)
@settings = settings
@available_highlights = av... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/color_schemes/show_view.rb | Ruby | bsd-3-clause | 99 | main | 1,123 | # frozen_string_literal: true
class ColorSchemes::ShowView < ApplicationView
include Phlex::Rails::Helpers::TurboFrameTag
include Phlex::Rails::Helpers::DOMID
include Phlex::Rails::Helpers::LinkTo
def initialize(color_scheme:)
@color_scheme = color_scheme
end
def view_template
render Pages::Heade... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/color_schemes/index_view.rb | Ruby | bsd-3-clause | 99 | main | 947 | # frozen_string_literal: true
class ColorSchemes::IndexView < ApplicationView
include Phlex::Rails::Helpers::LinkTo
def initialize(color_schemes:)
@color_schemes = color_schemes
end
def view_template
render Pages::Header.new(title: "Color Scheme Index")
section(class: "section-content container ... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/errors/not_found_view.rb | Ruby | bsd-3-clause | 99 | main | 910 | class Errors::NotFoundView < ApplicationView
def view_template
render Pages::Header::Container.new do |header|
header.title { "404 NOT FOUND" }
header.description { "Oops! The page you were looking for doesn’t exist 🧐" }
end
render Errors::ErrorBody do
p { "That‘s right, the page you w... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/errors/spotify_embed.rb | Ruby | bsd-3-clause | 99 | main | 481 | class Errors::SpotifyEmbed < ApplicationComponent
def initialize(src:, **iframe_options)
@src = src
@iframe_options = iframe_options
end
def view_template
iframe(
src: @src,
width: "100%",
height: "352",
frameborder: "0",
allowfullscreen: "",
allow: "autoplay; clip... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/errors/unprocessable_view.rb | Ruby | bsd-3-clause | 99 | main | 601 | class Errors::UnprocessableView < ApplicationView
def view_template
render Pages::Header::Container.new do |header|
header.title { "422 UNPROCESSABLE" }
header.description { "Oops! The change you wanted was rejected 😱" }
end
render Errors::ErrorBody do
p { "I just can‘t process this. D... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/errors/internal_server_view.rb | Ruby | bsd-3-clause | 99 | main | 972 | class Errors::InternalServerView < ApplicationView
def view_template
render Pages::Header::Container.new do |header|
header.title { "500 INTERNAL SERVER ERROR" }
header.description { "Oops! Something went wrong 😭" }
end
render Errors::ErrorBody do
p { "Well, this is embarassing." }
... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/errors/error_body.rb | Ruby | bsd-3-clause | 99 | main | 305 | class Errors::ErrorBody < ApplicationComponent
def view_template(&)
div(class: "extend-page-header-bg") do
div(class: "section-content container py-gap mb-3xl", &)
end
section(id: "newsletter-signup") do
render partial: "users/newsletter_subscriptions/banner"
end
end
end |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/sitemaps/index.xml.builder | Ruby | bsd-3-clause | 99 | main | 257 | # index.xml.builder
xml.instruct!
xml.sitemapindex xmlns: "http://www.sitemaps.org/schemas/sitemap/0.9" do
xml.sitemap do
xml.loc sitemap_pages_url(format: :xml)
xml.lastmod Time.utc(2020, 12, 21, 11).strftime("%Y-%m-%dT%H:%M:%S+00:00")
end
end |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/sitemaps/pages.xml.builder | Ruby | bsd-3-clause | 99 | main | 570 | xml.instruct!
xml.urlset xmlns: "http://www.sitemaps.org/schemas/sitemap/0.9" do
xml.url do
xml.loc root_url
xml.lastmod @last_modified_at.strftime("%Y-%m-%dT%H:%M:%S+00:00")
end
@pages.each do |page|
xml.url do
xml.loc Addressable::URI.join(root_url, page.request_path)
xml.lastmod @last_... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/feed/index.atom.builder | Ruby | bsd-3-clause | 99 | main | 610 | atom_feed do |feed|
feed.title(Rails.configuration.x.application_name)
feed.updated(@articles.first.published_at) if @articles.length > 0
@articles.take(50).each do |article|
next if article.resource_missing?
feed.entry(
article,
id: "tag:#{request.host},2005:article/#{article.atom_feed_id}",... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/searches/combobox.rb | Ruby | bsd-3-clause | 99 | main | 2,262 | module Searches
class Combobox < ApplicationComponent
include Phlex::Rails::Helpers::TurboFrameTag
include Phlex::Rails::Helpers::FormWith
include PhlexConcerns::SvgTag
attr_reader :query, :name, :attributes
def initialize(query: "", name: "search", **attributes)
@query = query
@name... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/searches/show_view.rb | Ruby | bsd-3-clause | 99 | main | 552 | class Searches::ShowView < ApplicationView
include Phlex::Rails::Helpers::LinkTo
include Phlex::Rails::Helpers::Routes
include Phlex::Rails::Helpers::TurboFrameTag
attr_reader :attributes
def initialize(**attrs)
@attributes = attrs
end
def view_template
render Pages::Header.new(title: "Search J... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/searches/result.rb | Ruby | bsd-3-clause | 99 | main | 911 | module Searches
class Result < ApplicationComponent
class_attribute :result_classes
self.result_classes = {}
def self.register(result_class, component_class)
result_classes[result_class] = component_class
end
def self.lookup_component_class(result)
component_class = result_classes[re... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/searches/listbox.rb | Ruby | bsd-3-clause | 99 | main | 1,785 | module Searches
class Listbox < ApplicationComponent
include Phlex::Rails::Helpers::DOMID
attr_reader :results, :query, :name
def self.dom_id(name)
"#{name}-listbox"
end
def initialize(results: [], query: "", name: "search")
@results = results
@query = query
@name = name... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/searches/button.rb | Ruby | bsd-3-clause | 99 | main | 754 | module Searches
class Button < ApplicationComponent
include PhlexConcerns::SvgTag
def view_template
a(
id: "search-button",
data: {
controller: "modal-opener",
action: "modal-opener#open",
"modal-opener-dialog-param": "search-dialog"
},
type... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/searches/dialog.rb | Ruby | bsd-3-clause | 99 | main | 618 | module Searches
class Dialog < ApplicationComponent
include Phlex::Rails::Helpers::TurboFrameTag
def view_template
render ::Dialog::Layout.new(
id: "search-dialog",
aria: {label: "Search Dialog"},
class: "max-w-xl p-2 mt-32 mx-auto",
data: {
controller: "dialog... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/searches/results/page.rb | Ruby | bsd-3-clause | 99 | main | 557 | module Searches
module Results
class Page < ApplicationComponent
attr_reader :page
def initialize(page)
@page = page
end
def view_template
a(
href: page.request_path,
data: {
turbo_frame: "_top"
},
class: ["p-2", "block"... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/admin_users/sessions/new_view.rb | Ruby | bsd-3-clause | 99 | main | 1,289 | # frozen_string_literal: true
class AdminUsers::Sessions::NewView < ApplicationView
include Phlex::Rails::Helpers::LinkTo
attr_reader :admin_user
def initialize(admin_user: AdminUser.new)
@admin_user = admin_user
end
def view_template
render FrontDoor::Form.new(title: "Sign in to your Admin Accoun... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/author/snippets/snippet.rb | Ruby | bsd-3-clause | 99 | main | 1,045 | module Author
module Snippets
class Snippet < ApplicationComponent
include Phlex::Rails::Helpers::DOMID
attr_accessor :current_user, :snippet, :attributes
def initialize(snippet, current_user: false, **attributes)
@snippet = snippet
@current_user = current_user
@attribu... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/author/snippets/toolbar.rb | Ruby | bsd-3-clause | 99 | main | 715 | class Author::Snippets::Toolbar < ApplicationComponent
include Phlex::Rails::Helpers::ButtonTo
include Phlex::Rails::Helpers::LinkTo
include PhlexConcerns::FlexBlock
attr_reader :snippet, :current_user
def initialize(snippet, current_user: nil)
@snippet = snippet
@current_user = current_user
end
... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/author/snippets/form.rb | Ruby | bsd-3-clause | 99 | main | 4,653 | class Author::Snippets::Form < ApplicationComponent
include Phlex::Rails::Helpers::DOMID
include Phlex::Rails::Helpers::FormWith
include Phlex::Rails::Helpers::TurboFrameTag
include Phlex::Rails::Helpers::Pluralize
include Phlex::Rails::Helpers::TurboStream
include Phlex::Rails::Helpers::ButtonTo
include ... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/examples/posts/index_view.rb | Ruby | bsd-3-clause | 99 | main | 1,578 | # frozen_string_literal: true
class Examples::Posts::IndexView < ApplicationView
include Phlex::Rails::Helpers::ClassNames
include Phlex::Rails::Helpers::ContentFor
include Phlex::Rails::Helpers::FormWith
include Phlex::Rails::Helpers::LinkTo
include Phlex::Rails::Helpers::TurboFrameTag
include Phlex::Rail... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/examples/posts/form.rb | Ruby | bsd-3-clause | 99 | main | 2,929 | # frozen_string_literal: true
class Examples::Posts::Form < ApplicationComponent
include Phlex::Rails::Helpers::FormWith
include Phlex::Rails::Helpers::LinkTo
include Phlex::Rails::Helpers::TurboFrameTag
include Phlex::Rails::Helpers::ClassNames
def initialize(post:)
@post = post
@image = post.image... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/examples/posts/new_view.rb | Ruby | bsd-3-clause | 99 | main | 689 | # frozen_string_literal: true
class Examples::Posts::NewView < ApplicationView
include Phlex::Rails::Helpers::FormWith
include Phlex::Rails::Helpers::LinkTo
include Phlex::Rails::Helpers::TurboFrameTag
include Phlex::Rails::Helpers::ClassNames
def initialize(post:)
@post = post
end
def view_templat... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/users/magic_session_tokens/show_view.rb | Ruby | bsd-3-clause | 99 | main | 451 | class Users::MagicSessionTokens::ShowView < ApplicationView
def initialize(user:, magic_session_token:)
@user = user
@magic_session_token = magic_session_token
end
def view_template
render FrontDoor::Form.new(title: "Click to sign in") do |layout|
layout.form_with model: @user,
url: use... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/users/magic_session_tokens/new_view.rb | Ruby | bsd-3-clause | 99 | main | 604 | # frozen_string_literal: true
class Users::MagicSessionTokens::NewView < ApplicationView
def initialize(user:)
@user = user
end
def view_template
render FrontDoor::Form.new(title: "Sign in by email") do |layout|
layout.form_with model: @user, url: users_magic_session_tokens_path do |form|
... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/users/dashboard/index_view.rb | Ruby | bsd-3-clause | 99 | main | 1,503 | # frozen_string_literal: true
class Users::Dashboard::IndexView < ApplicationView
include Phlex::Rails::Helpers::LinkTo
def view_template
article do
render Pages::Header.new(
title: "Welcome to Joy of Rails!",
description: "Thank you for signing up 😂"
)
div(class: "article-... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/users/sessions/new_view.rb | Ruby | bsd-3-clause | 99 | main | 1,642 | # frozen_string_literal: true
class Users::Sessions::NewView < ApplicationView
include Phlex::Rails::Helpers::LinkTo
def initialize(user: User.new)
@user = user
end
def view_template
render FrontDoor::Form.new(title: "Sign in") do |layout|
layout.form_with model: @user,
data: {turbo: fa... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/users/registrations/new_view.rb | Ruby | bsd-3-clause | 99 | main | 1,278 | class Users::Registrations::NewView < ApplicationView
include PhlexConcerns::HasInvisibleCaptcha
def initialize(user:)
@user = user
end
def view_template
render FrontDoor::Form.new(title: "Create a new account") do |layout|
layout.form_with model: @user,
url: users_registration_path do |... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/users/registrations/edit_view.rb | Ruby | bsd-3-clause | 99 | main | 1,908 | # frozen_string_literal: true
class Users::Registrations::EditView < ApplicationView
def initialize(user:)
@user = user
end
def view_template
render FrontDoor::Form.new(title: "Edit your account") do |layout|
layout.form_with model: @user,
url: users_registration_path do |form|
if ... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/users/passwords/edit_view.rb | Ruby | bsd-3-clause | 99 | main | 977 | # frozen_string_literal: true
class Users::Passwords::EditView < ApplicationView
def initialize(user:, password_reset_token:)
@user = user
@password_reset_token = password_reset_token
end
def view_template
render FrontDoor::Form.new(title: "Reset your password") do |layout|
layout.form_with mo... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/users/passwords/new_view.rb | Ruby | bsd-3-clause | 99 | main | 727 | # frozen_string_literal: true
class Users::Passwords::NewView < ApplicationView
include Phlex::Rails::Helpers::FormWith
include Phlex::Rails::Helpers::Object
include Phlex::Rails::Helpers::Routes
def initialize(user:)
@user = user
end
def view_template
render FrontDoor::Form.new(title: "Forgot yo... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/users/header_navigations/show_view.rb | Ruby | bsd-3-clause | 99 | main | 5,804 | module Users
module HeaderNavigations
class ShowView < ApplicationView
include Phlex::Rails::Helpers::Routes
include Phlex::Rails::Helpers::TurboFrameTag
include Phlex::Rails::Helpers::ButtonTo
include Phlex::Rails::Helpers::LinkTo
include PhlexConcerns::FlexBlock
attr_reader ... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/users/newsletter_subscriptions/new_view.rb | Ruby | bsd-3-clause | 99 | main | 674 | # frozen_string_literal: true
class Users::NewsletterSubscriptions::NewView < ApplicationView
include Phlex::Rails::Helpers::TurboFrameTag
def initialize(newsletter_subscription:)
@newsletter_subscription = newsletter_subscription
end
def view_template
render Users::NewsletterSubscriptions::Banner.ne... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/users/newsletter_subscriptions/show_view.rb | Ruby | bsd-3-clause | 99 | main | 1,856 | # frozen_string_literal: true
class Users::NewsletterSubscriptions::ShowView < ApplicationView
include Phlex::Rails::Helpers::LinkTo
include Phlex::Rails::Helpers::TurboFrameTag
def initialize(newsletter_subscription:, show_unsubscribe: false)
@newsletter_subscription = newsletter_subscription
@show_uns... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/users/newsletter_subscriptions/subscribe_button.rb | Ruby | bsd-3-clause | 99 | main | 513 | class Users::NewsletterSubscriptions::SubscribeButton < ApplicationComponent
include Phlex::Rails::Helpers::LinkTo
include Phlex::Rails::Helpers::ButtonTo
def view_template
return plain "" unless helpers.user_signed_in?
if helpers.current_user.subscribed_to_newsletter?
link_to "Manage subscription... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/users/newsletter_subscriptions/form.rb | Ruby | bsd-3-clause | 99 | main | 1,371 | class Users::NewsletterSubscriptions::Form < ApplicationComponent
include Phlex::Rails::Helpers::EmailField
include Phlex::Rails::Helpers::FormWith
include Phlex::Rails::Helpers::Object
include Phlex::Rails::Helpers::Routes
include PhlexConcerns::HasInvisibleCaptcha
def initialize(newsletter_subscription:... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/users/newsletter_subscriptions/banner.rb | Ruby | bsd-3-clause | 99 | main | 628 | # frozen_string_literal: true
class Users::NewsletterSubscriptions::Banner < ApplicationComponent
include Phlex::Rails::Helpers::TurboFrameTag
def view_template(&block)
div(class: "newsletter-banner section-content container py-gap mb-3xl lg:py-3xl lg:grid-cols-1/2") do
h3(class: "font-semibold") do
... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/users/newsletter_subscriptions/unsubscribe_button.rb | Ruby | bsd-3-clause | 99 | main | 470 | class Users::NewsletterSubscriptions::UnsubscribeButton < ApplicationComponent
include Phlex::Rails::Helpers::ButtonTo
# TODO: Make this button work for users who are not signed in—first we need to figure out when to show it for them
def view_template
button_to "Unsubscribe", unsubscribe_users_newsletter_sub... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/users/confirmations/new_view.rb | Ruby | bsd-3-clause | 99 | main | 783 | class Users::Confirmations::NewView < ApplicationView
def initialize(user:)
@user = user
end
def view_template
render FrontDoor::Form.new(title: "Resend confirmation instructions") do |layout|
layout.form_with model: @user,
url: users_confirmations_path do |form|
if form.object.erro... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/users/confirmations/edit_view.rb | Ruby | bsd-3-clause | 99 | main | 457 | class Users::Confirmations::EditView < ApplicationView
def initialize(user:, confirmation_token:)
@user = user
@confirmation_token = confirmation_token
end
def view_template
render FrontDoor::Form.new(title: "Click to confirm") do |layout|
layout.form_with model: @user,
url: users_confi... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/users/thank_yous/show_view.rb | Ruby | bsd-3-clause | 99 | main | 2,037 | # frozen_string_literal: true
class Users::ThankYous::ShowView < ApplicationView
include Phlex::Rails::Helpers::LinkTo
def view_template
article do
render Pages::Header.new(
title: "Welcome to Joy of Rails!",
description: "Thank you for signing up 😂"
)
div(class: "section-c... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/views/topics/nav.rb | Ruby | bsd-3-clause | 99 | main | 1,777 | module Topics
class Nav < ApplicationComponent
include Phlex::Rails::Helpers::CurrentPage
include Phlex::Rails::Helpers::DOMID
include Phlex::Rails::Helpers::Request
include PhlexConcerns::FlexBlock
attr_reader :topics, :attributes
def initialize(topics = [], **attributes)
@topics = to... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/mailers/application_mailer.rb | Ruby | bsd-3-clause | 99 | main | 555 | # frozen_string_literal: true
class ApplicationMailer < ActionMailer::Base
prepend_view_path "app/views/emails"
FROM_ADDRESS = Rails.configuration.x.emails.transactional_from_address
FROM_NAME = Rails.configuration.x.emails.transactional_from_name
default from: email_address_with_name(FROM_ADDRESS, FROM_NAME... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/mailers/emails/admin_user_mailer.rb | Ruby | bsd-3-clause | 99 | main | 207 | class Emails::AdminUserMailer < ApplicationMailer
def new_user(admin_user:, user:)
@admin_user = admin_user
@user = user
mail to: @admin_user.email, subject: "New Joy of Rails User"
end
end |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/mailers/emails/user_mailer.rb | Ruby | bsd-3-clause | 99 | main | 782 | # frozen_string_literal: true
class Emails::UserMailer < ApplicationMailer
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.emails.user_mailer.confirmation.subject
def confirmation(user, confirmation_token)
@user = user
@confirmation_token = confi... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/mailers/emails/magic_session_mailer.rb | Ruby | bsd-3-clause | 99 | main | 344 | class Emails::MagicSessionMailer < ApplicationMailer
def sign_in_link(user, magic_session_token)
@user = user
@magic_session_token = magic_session_token
mail to: @user.email, subject: "Your sign-in link"
end
def no_account_found(email)
mail to: email, subject: "No account found", support_email: ... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/mailers/emails/newsletter_mailer.rb | Ruby | bsd-3-clause | 99 | main | 708 | # frozen_string_literal: true
class Emails::NewsletterMailer < ApplicationMailer
default from: email_address_with_name(
Rails.configuration.x.emails.broadcast_from_address,
Rails.configuration.x.emails.broadcast_from_name
)
def newsletter(newsletter:, user:, unsubscribe_token:)
@newsletter = newslet... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/lib/refinements/emojoy.rb | Ruby | bsd-3-clause | 99 | main | 258 | module Refinements
module Emojoy
EMOJOYS = %w[🎸 🚴🏼♂️ 🛜 🍿 👻 🤠 ✌️ 🦸🏻♀️ 🐙 🌈 ⚡️ 🔥 🏆].freeze
refine String do
def emojoy
self + " #{EMOJOYS.sample}"
end
end
end
end |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/lib/litestream_extensions/setup.rb | Ruby | bsd-3-clause | 99 | main | 1,501 | module LitestreamExtensions
module Setup
module_function
def configure_litestream
if litestream_bucket.blank?
Rails.logger.debug "[#{self}] Skipping Litestream configuration"
return
end
File.write(config_path, YAML.dump(litestream_config))
# Here’s the command needed ... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/lib/warden_extensions/setup.rb | Ruby | bsd-3-clause | 99 | main | 772 | module WardenExtensions
module Setup
module_function
def configure_manager
Warden::Manager.serialize_into_session do |user|
[user.class.name, user.id]
end
Warden::Manager.serialize_from_session do |(class_name, id)|
class_name.constantize.find(id)
end
Warden::M... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/lib/warden_extensions/strategies/magic_session.rb | Ruby | bsd-3-clause | 99 | main | 641 | module WardenExtensions::Strategies
class MagicSession < ::Warden::Strategies::Base
def self.key
name.demodulize.underscore.to_sym
end
def key
self.class.key
end
def valid?
!!token
end
def authenticate!
user = scope_class.find_by_token_for(:magic_session, token)
... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/lib/warden_extensions/strategies/password.rb | Ruby | bsd-3-clause | 99 | main | 815 | module WardenExtensions::Strategies
class Password < ::Warden::Strategies::Base
def self.key
name.demodulize.underscore.to_sym
end
def key
self.class.key
end
def valid?
!!(scoped_params["email"] && scoped_params["password"])
end
def authenticate!
user = scope_cla... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/channels/application_cable/connection.rb | Ruby | bsd-3-clause | 99 | main | 481 | module ApplicationCable
class Connection < ActionCable::Connection::Base
rescue_from StandardError, with: :report_error
identified_by :current_user
def connect
self.current_user = find_current_user
logger.add_tags "ActionCable", current_user.id
end
private
def find_current_user... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/feed_controller.rb | Ruby | bsd-3-clause | 99 | main | 393 | class FeedController < ApplicationController
include CurrentPage
def index
@articles = Page.published.order(published_at: :desc).limit(50)
if Rails.configuration.skip_http_cache || stale?(@articles, public: true)
respond_to do |format|
format.html { redirect_to feed_path(format: :atom), stat... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/color_schemes_controller.rb | Ruby | bsd-3-clause | 99 | main | 568 | class ColorSchemesController < ApplicationController
def index
@color_schemes = ColorScheme.curated
render ColorSchemes::IndexView.new(color_schemes: @color_schemes)
end
def show
@color_scheme = ColorScheme.find(params[:id])
if Rails.configuration.skip_http_cache || stale?(@color_scheme, public... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/examples_controller.rb | Ruby | bsd-3-clause | 99 | main | 408 | class ExamplesController < ApplicationController
def index
end
def show
paths = Dir.glob(Rails.root.join("app", "views", "examples", "ruby", "*.rb"))
path = paths.find { |path| File.basename(path, ".rb") == params[:id] } or raise ActiveRecord::RecordNotFound, "Could not find example: #{params[:id]}"
... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/topics_controller.rb | Ruby | bsd-3-clause | 99 | main | 252 | class TopicsController < ApplicationController
def index
@topics = Topic.approved.with_pages.order(name: :asc)
end
def show
@topics = Topic.approved.with_pages.order(name: :asc)
@topic = Topic.find_by!(slug: params[:slug])
end
end |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/errors_controller.rb | Ruby | bsd-3-clause | 99 | main | 275 | class ErrorsController < ApplicationController
def not_found
render Errors::NotFoundView, status: 404
end
def internal_server
render Errors::InternalServerView, status: 500
end
def unprocessable
render Errors::UnprocessableView, status: 422
end
end |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/searches_controller.rb | Ruby | bsd-3-clause | 99 | main | 1,092 | # frozen_string_literal: true
class SearchesController < ApplicationController
rescue_from Searches::ParseFailed do |error|
query = params.fetch(:query, "")
respond_to do |format|
format.html { render Searches::ShowView.new(query:, name:) }
format.turbo_stream {
render turbo_stream: [
... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/sitemaps_controller.rb | Ruby | bsd-3-clause | 99 | main | 402 | class SitemapsController < ApplicationController
def index
respond_to do |format|
format.xml
end
end
def pages
@last_modified_at = Time.now.middle_of_day.utc
@pages = Page.all.published.order(published_at: :desc)
@slash_pages = %w[
about
articles
contact
meta
... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/site_controller.rb | Ruby | bsd-3-clause | 99 | main | 1,426 | class SiteController < Sitepress::SiteController
include CurrentPage
before_action do
@current_page = Page.find_or_initialize_by(request_path: request.path)
end
# This is the default controller for Sitepress. It is used to render the pages of the site.
# We prefer not to override this method but instead... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/examples/posts_controller.rb | Ruby | bsd-3-clause | 99 | main | 971 | class Examples::PostsController < ApplicationController
before_action :feature_enabled!
def index
render Examples::Posts::IndexView.new(posts: Examples::Post.limit(25).order(created_at: :desc))
end
def new
post = Examples::Post.new(post_params_permitted)
render Examples::Posts::NewView.new(post: ... |
github | joyofrails/joyofrails.com | https://github.com/joyofrails/joyofrails.com | app/controllers/examples/counters_controller.rb | Ruby | bsd-3-clause | 99 | main | 741 | class Examples::CountersController < ApplicationController
def show
@examples_counter = Examples::Counter.new(count: get_session_count)
end
def update
@examples_counter = Examples::Counter.new(count: get_session_count)
@examples_counter.assign_attributes(examples_counter_params)
session[:example... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.