repo
stringlengths
5
92
file_url
stringlengths
80
287
file_path
stringlengths
5
197
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:37:27
2026-01-04 17:58:21
truncated
bool
2 classes
basecamp/once-campfire
https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/config/initializers/vapid.rb
config/initializers/vapid.rb
Rails.application.configure do config.x.vapid.private_key = ENV.fetch("VAPID_PRIVATE_KEY", Rails.application.credentials.dig(:vapid, :private_key)) config.x.vapid.public_key = ENV.fetch("VAPID_PUBLIC_KEY", Rails.application.credentials.dig(:vapid, :public_key)) end
ruby
MIT
1852adb06c125ac45253f2f0785ce3747694f448
2026-01-04T15:48:40.201016Z
false
basecamp/once-campfire
https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/config/initializers/inflections.rb
config/initializers/inflections.rb
# Be sure to restart your server when you modify this file. # Add new inflection rules using the following format. Inflections # are locale specific, and you may define rules for as many different # locales as you wish. All of these examples are active by default: # ActiveSupport::Inflector.inflections(:en) do |inflec...
ruby
MIT
1852adb06c125ac45253f2f0785ce3747694f448
2026-01-04T15:48:40.201016Z
false
basecamp/once-campfire
https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/config/initializers/active_storage.rb
config/initializers/active_storage.rb
ActiveSupport.on_load(:active_storage_blob) do ActiveStorage::DiskController.after_action only: :show do response.set_header("Cache-Control", "max-age=3600, public") end end
ruby
MIT
1852adb06c125ac45253f2f0785ce3747694f448
2026-01-04T15:48:40.201016Z
false
basecamp/once-campfire
https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/config/initializers/permissions_policy.rb
config/initializers/permissions_policy.rb
# Define an application-wide HTTP permissions policy. For further # information see https://developers.google.com/web/updates/2018/06/feature-policy # # Rails.application.config.permissions_policy do |f| # f.camera :none # f.gyroscope :none # f.microphone :none # f.usb :none # f.fullscreen :s...
ruby
MIT
1852adb06c125ac45253f2f0785ce3747694f448
2026-01-04T15:48:40.201016Z
false
basecamp/once-campfire
https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/config/initializers/assets.rb
config/initializers/assets.rb
# Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = "1.0"
ruby
MIT
1852adb06c125ac45253f2f0785ce3747694f448
2026-01-04T15:48:40.201016Z
false
basecamp/once-campfire
https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/config/initializers/web_push.rb
config/initializers/web_push.rb
require "web-push" require "web_push/pool" require "web_push/notification" Rails.application.configure do config.x.web_push_pool = WebPush::Pool.new( invalid_subscription_handler: ->(subscription_id) do Rails.application.executor.wrap do Rails.logger.info "Destroying push subscription: #{subscripti...
ruby
MIT
1852adb06c125ac45253f2f0785ce3747694f448
2026-01-04T15:48:40.201016Z
false
basecamp/once-campfire
https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/config/initializers/sentry.rb
config/initializers/sentry.rb
if Rails.env.production? && ENV["SKIP_TELEMETRY"].blank? Sentry.init do |config| config.dsn = ENV["SENTRY_DSN"] config.breadcrumbs_logger = [ :active_support_logger, :http_logger ] config.send_default_pii = false config.release = ENV["GIT_REVISION"] end end
ruby
MIT
1852adb06c125ac45253f2f0785ce3747694f448
2026-01-04T15:48:40.201016Z
false
basecamp/once-campfire
https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/config/environments/test.rb
config/environments/test.rb
require "active_support/core_ext/integer/time" # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between test runs. Don't rely on the data the...
ruby
MIT
1852adb06c125ac45253f2f0785ce3747694f448
2026-01-04T15:48:40.201016Z
false
basecamp/once-campfire
https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/config/environments/performance.rb
config/environments/performance.rb
require_relative "production" Rails.application.configure do config.assume_ssl = false config.force_ssl = false config.action_cable.disable_request_forgery_protection = true config.after_initialize do if defined?(Rails::Server) && User.none? Account.create!(name: "Campfire") password_digest ...
ruby
MIT
1852adb06c125ac45253f2f0785ce3747694f448
2026-01-04T15:48:40.201016Z
false
basecamp/once-campfire
https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/config/environments/development.rb
config/environments/development.rb
require "active_support/core_ext/integer/time" Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Make code changes take effect immediately without server restart. config.enable_reloading = true # Do not eager load code on boot. config.eager...
ruby
MIT
1852adb06c125ac45253f2f0785ce3747694f448
2026-01-04T15:48:40.201016Z
false
basecamp/once-campfire
https://github.com/basecamp/once-campfire/blob/1852adb06c125ac45253f2f0785ce3747694f448/config/environments/production.rb
config/environments/production.rb
require "active_support/core_ext/integer/time" require "active_support/core_ext/numeric/bytes" Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. config.enable_reloading = false # Eager load code on boot ...
ruby
MIT
1852adb06c125ac45253f2f0785ce3747694f448
2026-01-04T15:48:40.201016Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/app/controllers/peek/results_controller.rb
app/controllers/peek/results_controller.rb
module Peek class ResultsController < ApplicationController before_action :restrict_non_access def show respond_to do |format| format.json do if request.xhr? render json: Peek.adapter.get(params[:request_id]) else render nothing: true, status: :not_fo...
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/test/peek_test.rb
test/peek_test.rb
require 'test_helper' class Staff < Peek::Views::View def initialize(options = {}) @username = options.delete(:username) end def username @username end def enabled? !!@username end end describe Peek do describe "enabled?" do it "should not be enabled in test" do refute Peek.enabl...
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/test/test_helper.rb
test/test_helper.rb
ENV['RAILS_ENV'] = 'test' require File.expand_path('../dummy/config/environment.rb', __FILE__) require 'rails/test_help' Rails.backtrace_cleaner.remove_silencers! # Load support files Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f } # Load fixtures from the engine if ActiveSupport::TestCase....
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/test/controllers/requests_test.rb
test/controllers/requests_test.rb
require 'test_helper' require_relative '../dummy/lib/test_view' class RequestsTest < ActionDispatch::IntegrationTest setup do Peek.adapter.reset Peek.reset end test "the request id is set" do assert_empty Peek.adapter.requests get '/' assert_not_empty Peek.adapter.requests end test "t...
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/test/dummy/app/helpers/application_helper.rb
test/dummy/app/helpers/application_helper.rb
module ApplicationHelper end
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/test/dummy/app/controllers/home_controller.rb
test/dummy/app/controllers/home_controller.rb
class HomeController < ApplicationController def enabled @peek_enabled = true render :show end def disabled @peek_enabled = false render :show end end
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/test/dummy/app/controllers/application_controller.rb
test/dummy/app/controllers/application_controller.rb
class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception def peek_enabled? if defined?(@peek_enabled) !!@peek_enabled else true end end end
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/test/dummy/lib/test_view.rb
test/dummy/lib/test_view.rb
require 'concurrent/atomics' class TestView < Peek::Views::View class << self attr_accessor :counter end self.counter = Concurrent::AtomicFixnum.new def results { number: self.class.counter.increment } end def partial_path "peek/test_view" end end
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/test/dummy/config/application.rb
test/dummy/config/application.rb
require File.expand_path('../boot', __FILE__) require 'action_controller/railtie' require 'action_mailer/railtie' require 'sprockets/railtie' require 'rails/test_unit/railtie' Bundler.require(*Rails.groups) require 'peek' module Dummy class Application < Rails::Application # Settings in config/environments/* t...
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/test/dummy/config/environment.rb
test/dummy/config/environment.rb
# Load the rails application. require File.expand_path('../application', __FILE__) # Initialize the rails application. Dummy::Application.initialize!
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/test/dummy/config/routes.rb
test/dummy/config/routes.rb
Dummy::Application.routes.draw do mount Peek::Railtie => 'peek' get '/enabled' => 'home#enabled' get '/disabled' => 'home#disabled' root to: 'home#enabled' end
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/test/dummy/config/boot.rb
test/dummy/config/boot.rb
# Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__) require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/test/dummy/config/initializers/filter_parameter_logging.rb
test/dummy/config/initializers/filter_parameter_logging.rb
# Be sure to restart your server when you modify this file. # Configure sensitive parameters which will be filtered from the log file. Rails.application.config.filter_parameters += [:password]
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/test/dummy/config/initializers/session_store.rb
test/dummy/config/initializers/session_store.rb
# Be sure to restart your server when you modify this file. Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/test/dummy/config/initializers/wrap_parameters.rb
test/dummy/config/initializers/wrap_parameters.rb
# Be sure to restart your server when you modify this file. # This file contains settings for ActionController::ParamsWrapper which # is enabled by default. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do wrap_parameters f...
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/test/dummy/config/initializers/inflections.rb
test/dummy/config/initializers/inflections.rb
# Be sure to restart your server when you modify this file. # Add new inflection rules using the following format. Inflections # are locale specific, and you may define rules for as many different # locales as you wish. All of these examples are active by default: # ActiveSupport::Inflector.inflections(:en) do |inflec...
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/test/dummy/config/initializers/peek.rb
test/dummy/config/initializers/peek.rb
require_relative '../../../dummy/lib/test_view' Peek.into TestView
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/test/dummy/config/initializers/backtrace_silencers.rb
test/dummy/config/initializers/backtrace_silencers.rb
# Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # You can also remove all the silencers if you're trying to debug a probl...
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/test/dummy/config/initializers/mime_types.rb
test/dummy/config/initializers/mime_types.rb
# Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf # Mime::Type.register_alias "text/html", :iphone
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/test/dummy/config/initializers/secret_token.rb
test/dummy/config/initializers/secret_token.rb
# Be sure to restart your server when you modify this file. # Your secret key is used for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to diction...
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/test/dummy/config/environments/test.rb
test/dummy/config/environments/test.rb
Dummy::Application.configure do # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test sui...
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/test/dummy/config/environments/development.rb
test/dummy/config/environments/development.rb
Dummy::Application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web ser...
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/test/peek/views/view_test.rb
test/peek/views/view_test.rb
require 'test_helper' describe Peek::Views::View do before do @view = Peek::Views::View.new end describe "partial path" do it "should return correct partial class" do assert_equal 'peek/views/view', @view.partial_path end end describe "dom_id" do it "should return correct dom_id" do ...
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/lib/peek.rb
lib/peek.rb
require 'peek/version' require 'rails' require 'peek/adapters/memory' require 'peek/views/view' module Peek ALLOWED_ENVS = ['development', 'staging'].freeze def self.adapter @adapter end def self.adapter=(*adapter_options) adapter, *parameters = *Array.wrap(adapter_options).flatten @adapter = c...
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/lib/peek/version.rb
lib/peek/version.rb
module Peek VERSION = '1.1.0' end
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/lib/peek/controller_helpers.rb
lib/peek/controller_helpers.rb
module Peek module ControllerHelpers extend ActiveSupport::Concern included do if respond_to? :helper_method helper_method :peek_enabled? helper_method :peek_request_id end end protected def peek_enabled? Peek.enabled? end def peek_request_id req...
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/lib/peek/railtie.rb
lib/peek/railtie.rb
require 'peek/controller_helpers' module Peek class Railtie < ::Rails::Engine isolate_namespace Peek engine_name :peek config.peek = ActiveSupport::OrderedOptions.new # Default adapter config.peek.adapter = :memory initializer 'peek.set_configs' do |app| ActiveSupport.on_load(:peek) ...
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/lib/peek/views/view.rb
lib/peek/views/view.rb
module Peek module Views class View def initialize(options = {}) @options = options parse_options setup_subscribers end # Where any subclasses should pick and pull from @options to set any and # all instance variables they like. # # Returns nothing. ...
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/lib/peek/adapters/memory.rb
lib/peek/adapters/memory.rb
require 'peek/adapters/base' module Peek module Adapters class Memory < Base attr_accessor :requests def initialize(options = {}) @requests = {} end def get(request_id) @requests[request_id] end def save(request_id) return false if request_id.blank? ...
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/lib/peek/adapters/redis.rb
lib/peek/adapters/redis.rb
require 'peek/adapters/base' require 'redis' module Peek module Adapters class Redis < Base def initialize(options = {}) @client = options.fetch(:client, ::Redis.new) @expires_in = Integer(options.fetch(:expires_in, 60 * 30)) end def get(request_id) @client.get("peek:re...
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/lib/peek/adapters/memcache.rb
lib/peek/adapters/memcache.rb
require 'peek/adapters/base' require 'dalli' module Peek module Adapters class Memcache < Base def initialize(options = {}) @client = options.fetch(:client, ::Dalli::Client.new) @expires_in = options.fetch(:expires_in, 60 * 30) end def get(request_id) @client.get("peek:...
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/lib/peek/adapters/base.rb
lib/peek/adapters/base.rb
module Peek module Adapters class Base def initialize(options = {}) end def get(request_id) raise "#{self.class}#get(request_id) is not yet implemented" end def save raise "#{self.class}#save is not yet implemented" end end end end
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/lib/peek/adapters/elasticsearch.rb
lib/peek/adapters/elasticsearch.rb
require 'peek/adapters/base' require 'elasticsearch' module Peek module Adapters class Elasticsearch < Base def initialize(options = {}) @client = options.fetch(:client, ::Elasticsearch::Client.new) @expires_in = Integer(options.fetch(:expires_in, 60 * 30) * 1000) @index = options.f...
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
peek/peek
https://github.com/peek/peek/blob/d6c13747a4889375c7af5290af4340ad68f13f2d/config/routes.rb
config/routes.rb
Peek::Railtie.routes.draw do get '/results' => 'results#show', as: :results end
ruby
MIT
d6c13747a4889375c7af5290af4340ad68f13f2d
2026-01-04T15:51:28.834627Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/jobs/topic_reference_job.rb
app/jobs/topic_reference_job.rb
class TopicReferenceJob < AsyncJob REFERENCE_PATTERN = %r{/topics/(\d+)} def perform(item_type, item_id) item = item_type.constantize.find_by(id: item_id) return if item&.body.blank? matched_topic_ids = [] item.body.gsub(REFERENCE_PATTERN) do topic_id = Regexp.last_match(1) matched_top...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/jobs/notify_topic_job.rb
app/jobs/notify_topic_job.rb
class NotifyTopicJob < ApplicationJob queue_as :notifications def perform(topic_id) topic = Topic.find_by_id(topic_id) return if topic&.user.blank? follower_ids = topic.user.follow_by_user_ids return if follower_ids.empty? notified_user_ids = topic.mentioned_user_ids # Send notification ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/jobs/notify_reply_job.rb
app/jobs/notify_reply_job.rb
class NotifyReplyJob < ApplicationJob queue_as :notifications def perform(reply_id) reply = Reply.find_by_id(reply_id) return if reply.blank? return if reply.system_event? default_note = reply.default_notification all_records = [] reply.notification_receiver_ids.each do |user_id| all...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/jobs/topic_read_job.rb
app/jobs/topic_read_job.rb
class TopicReadJob < AsyncJob def perform(topic_id:, user_id:, replies_ids: nil) topic = Topic.find_by_id(topic_id) return if topic.blank? user = User.find_by_id(user_id) return if user.blank? return if user.topic_read?(topic) replies_ids ||= topic.replies.pluck(:id) any_sql = "(target_t...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/jobs/github_repo_fetcher_job.rb
app/jobs/github_repo_fetcher_job.rb
class GitHubRepoFetcherJob < ApplicationJob queue_as :http_request def perform(user_id) User.fetch_github_repositories(user_id) end end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/jobs/push_job.rb
app/jobs/push_job.rb
class PushJob < ApplicationJob queue_as :notifications # user_ids: Receiver ids # note: { alert: 'Hello APNS World!', sound: 'true', badge: 1 } def perform(user_ids, note = {}) return false if Setting.apns_pem.blank? note[:sound] ||= "true" devices = Device.where(user_id: user_ids).all.to_a de...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/jobs/application_job.rb
app/jobs/application_job.rb
class ApplicationJob < ActiveJob::Base end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/jobs/mention_topic_job.rb
app/jobs/mention_topic_job.rb
class MentionTopicJob < ApplicationJob queue_as :notifications def perform(topic_ids, target_type:, target_id:, user_id:) return if topic_ids.blank? topics = Topic.where(id: topic_ids) topics.each do |topic| next if topic.replies.where(target_type: target_type, target_id: target_id).any? ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/jobs/async_job.rb
app/jobs/async_job.rb
# We use ActiveJob::QueueAdapters::AsyncAdapter for lite jobs for run queue in Rails Process as async. # https://api.rubyonrails.org/classes/ActiveJob/QueueAdapters/AsyncAdapter.html class AsyncJob < ActiveJob::Base end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/jobs/notify_topic_node_changed_job.rb
app/jobs/notify_topic_node_changed_job.rb
class NotifyTopicNodeChangedJob < AsyncJob def perform(topic_id, node_id:) topic = Topic.find_by_id(topic_id) return if topic.blank? node = Node.find_by_id(node_id) return if node.blank? Notification.create! notify_type: "node_changed", user_id: topic.user_id, target: topic, second_target: node ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/jobs/scheduler/online_user_stats_job.rb
app/jobs/scheduler/online_user_stats_job.rb
module Scheduler # Cleanup inactive user record from redis class OnlineUserStatsJob < ApplicationJob def perform User.cleanup_inactive_online_stats end end end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/jobs/scheduler/total_user_stats_job.rb
app/jobs/scheduler/total_user_stats_job.rb
module Scheduler # Count user replies count in recent class TotalUserStatsJob < ApplicationJob def perform(limit: 2000) users = User.where("replies_count > 0") users = if limit.to_i > 0 users.order("updated_at desc").limit(limit) else users.where("replies_count > 0").order("upd...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/jobs/scheduler/spam_cleanup_job.rb
app/jobs/scheduler/spam_cleanup_job.rb
module Scheduler # cleanup spam topic at 1 month ago class SpamCleanupJob < ApplicationJob def perform # Clean banned topics before 1 month ago Topic.ban.where("created_at < ?", 1.month.ago).delete_all end end end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/jobs/scheduler/doorkeeper_cleanup_job.rb
app/jobs/scheduler/doorkeeper_cleanup_job.rb
module Scheduler class DoorkeeperCleanupJob < ApplicationJob def perform Doorkeeper::AccessToken.where("revoked_at IS NOT NULL").where("revoked_at < NOW()").delete_all Doorkeeper::AccessGrant.where("revoked_at IS NOT NULL").where("revoked_at < NOW()").delete_all end end end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/jobs/scheduler/notification_cleanup_job.rb
app/jobs/scheduler/notification_cleanup_job.rb
module Scheduler # cleanup notifications at 1 years ago class NotificationCleanupJob < ApplicationJob def perform Notification.where("created_at < ?", 1.years.ago).delete_all end end end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/uploaders/photo_uploader.rb
app/uploaders/photo_uploader.rb
class PhotoUploader < BaseUploader # Override the filename of the uploaded files: def filename if super.present? @name ||= SecureRandom.uuid "#{model.user&.login || Time.now.year}/#{@name}.#{file.extension.downcase}" end end end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/uploaders/avatar_uploader.rb
app/uploaders/avatar_uploader.rb
class AvatarUploader < BaseUploader def filename if super.present? @name ||= SecureRandom.hex(3) "avatar/#{model.id}/#{@name}.#{file.extension.downcase}" end end end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/uploaders/base_uploader.rb
app/uploaders/base_uploader.rb
class BaseUploader < CarrierWave::Uploader::Base THUMB_IMAGE_EXTS = %w[.jpg .jpeg .gif .png] # Avatar # # xs - 32x32 # sm - 48x48 # md - 96x96 # lg - 192x192 # # Photo # large - 1920x? - Limited width, auto height ALLOW_VERSIONS = %w[xs sm md lg large] def store_dir dir = model.class.to_s....
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/helpers/teams_helper.rb
app/helpers/teams_helper.rb
module TeamsHelper def team_member_counts_tag(team) count_text = t("teams.team_users_count", count: team.team_users_count) content_tag(:i, nil, class: "fa fa-users") + content_tag(:span, count_text, class: "team-users-count text-xs") end end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/helpers/locations_helper.rb
app/helpers/locations_helper.rb
module LocationsHelper def location_name_tag(location, _options = {}) return "" if location.blank? name = (location.is_a?(String) == true) ? location : location.name link_to(name, location_users_path(name)) end end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/helpers/users_helper.rb
app/helpers/users_helper.rb
require "digest/md5" module UsersHelper # Genrate a user name link def user_name_tag(user, options = {}) return t("common.unknow_user") if user.blank? user_type = :user login = user label = login name = login if user.is_a? User user_type = user.user_type login = user.login ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/helpers/application_helper.rb
app/helpers/application_helper.rb
module ApplicationHelper def markdown(text) return nil if text.blank? Rails.cache.fetch(["markdown", "v1.1", Digest::MD5.hexdigest(text)]) do sanitize_markdown(Homeland::Markdown.call(text)) end end # plugins/jobs required this method def sanitize_markdown(html) sanitize(html, scrubber: H...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/helpers/nodes_helper.rb
app/helpers/nodes_helper.rb
module NodesHelper end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/helpers/topics_helper.rb
app/helpers/topics_helper.rb
require "digest/md5" module TopicsHelper def topic_favorite_tag(topic, opts = {}) return "" if current_user.blank? opts[:class] ||= "" class_name = "" link_title = t("common.favorite") if current_user&.favorite_topic?(topic) class_name = "active" link_title = t("common.unfavorite") ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/helpers/likes_helper.rb
app/helpers/likes_helper.rb
module LikesHelper # Likeable Helper # # params # - likeable - Like target # - :cache - when true, will not check current user is liked, directly return no like status for cache. # - :class - Add class for link, for example: "btn btn-secondary" def likeable_tag(likeable, opts = {}) return "" if likeab...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/settings_controller.rb
app/controllers/settings_controller.rb
class SettingsController < ApplicationController before_action :authenticate_user! before_action :set_user def show end def account end def profile end def password render_404 if Setting.sso_enabled? end def reward end def update case params[:by] when "password" update_...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/topics_controller.rb
app/controllers/topics_controller.rb
class TopicsController < ApplicationController include Topics::ListActions before_action :authenticate_user!, only: %i[new edit create update destroy favorite unfavorite follow unfollow action favorites] load_and_authorize_resource only: %i[new edit create update destroy favorite unfavorite follow unfoll...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/home_controller.rb
app/controllers/home_controller.rb
class HomeController < ApplicationController def uploads return render_404 if Rails.env.production? # This is a temporary solution for help generate image thumb # that when you use :file upload_provider and you have no Nginx image_filter configurations. # DO NOT use this in production environment. ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/devices_controller.rb
app/controllers/devices_controller.rb
class DevicesController < ApplicationController before_action :authenticate_user! def destroy @device = current_user.devices.find(params[:id]) @device.delete redirect_to oauth_applications_path, notice: "设备信息已删除" end end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/users_controller.rb
app/controllers/users_controller.rb
class UsersController < ApplicationController before_action :set_user, except: %i[index city] before_action :check_exist!, except: %i[index city block unblock follow unfollow] etag { @user } etag { @user&.teams if @user&.user_type == :user } include Users::TeamActions include Users::UserActions def...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/comments_controller.rb
app/controllers/comments_controller.rb
class CommentsController < ApplicationController before_action :authenticate_user! def create @comment = Comment.new(comment_params) @comment.user = current_user @success = @comment.save end def comment_params params.require(:comment).permit(:commentable_type, :commentable_id, :body) end end...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/replies_controller.rb
app/controllers/replies_controller.rb
class RepliesController < ApplicationController load_and_authorize_resource :reply before_action :set_topic before_action :set_reply, only: %i[edit reply_to update destroy] def create @reply = Reply.new(reply_params) @reply.topic_id = @topic.id @reply.user_id = current_user.id if @reply.save ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/teams_controller.rb
app/controllers/teams_controller.rb
class TeamsController < ApplicationController require_module_enabled! :team load_resource find_by: :login load_and_authorize_resource before_action :set_team, only: %i[show edit update] def index @total_team_count = Team.count @active_teams = Team.fields_for_list.hot.limit(60) end def show ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/photos_controller.rb
app/controllers/photos_controller.rb
class PhotosController < ApplicationController load_and_authorize_resource def create if params[:file].blank? render json: { ok: false }, status: 400 return end # 浮动窗口上传 @photo = Photo.new(image: params[:file], user: current_user) if @photo.save render json: { ok: true, url: ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/nodes_controller.rb
app/controllers/nodes_controller.rb
class NodesController < ApplicationController before_action :authenticate_user!, only: %i[block unblock] def index @nodes = Node.all render json: @nodes, only: [:name], methods: [:id] end def block current_user.block_node(params[:id]) render json: { code: 0 } end def unblock current_u...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/team_users_controller.rb
app/controllers/team_users_controller.rb
class TeamUsersController < ApplicationController require_module_enabled! :team before_action :set_team before_action :set_team_user, only: %i[edit update destroy] before_action :authorize_team_owner!, except: %i[index accept reject show] load_and_authorize_resource only: %i[accept reject show] def index ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/likes_controller.rb
app/controllers/likes_controller.rb
class LikesController < ApplicationController before_action :authenticate_user!, only: %i[create destroy] before_action :set_likeable def index @users = @item.like_by_users.order("actions.id asc") render :index, layout: false end def create current_user.like(@item) render plain: @item.reload...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/application_controller.rb
app/controllers/application_controller.rb
# ApplicationController class ApplicationController < ActionController::Base include Localize include Deviseable include CurrentInfo include Turbolinks include UserNotifications protect_from_forgery prepend: true fragment_cache_key { user_locale } # Addition contents for etag etag { current_user.try...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/search_controller.rb
app/controllers/search_controller.rb
class SearchController < ApplicationController before_action :authenticate_user!, only: [:users] def index params[:q] ||= "" if params[:q].size > 64 redirect_to root_path end @search = Homeland::Search.new(params[:q]) @result = @search.query_results.includes(:searchable).page(params[:p...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/auth/sso_controller.rb
app/controllers/auth/sso_controller.rb
module Auth class SSOController < ApplicationController def show return render_404 unless Setting.sso_enabled? destination_url = cookies.delete(:destination_url) return_path = params[:return_path] || root_path if destination_url && return_path == root_path uri = URI.parse(destina...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/admin/topics_controller.rb
app/controllers/admin/topics_controller.rb
module Admin class TopicsController < Admin::ApplicationController before_action :set_topic, only: %i[show edit update destroy revert suggest unsuggest] def index @topics = Topic.unscoped if params[:q].present? qstr = "%#{params[:q].downcase}%" @topics = @topics.where("title LIKE ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/admin/locations_controller.rb
app/controllers/admin/locations_controller.rb
module Admin class LocationsController < Admin::ApplicationController before_action :set_location, only: %i[edit update] def index @locations = Location.hot.page(params[:page]) end def edit end def update if @location.update(params[:location].permit!) redirect_to(admin_l...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/admin/dashboards_controller.rb
app/controllers/admin/dashboards_controller.rb
module Admin class DashboardsController < Admin::ApplicationController def index @recent_topics = Topic.recent.limit(5) end def reboot Homeland.reboot flash[:alert] = t("admin.reboot_successfully") redirect_referrer_or_default admin_root_path end end end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/admin/stats_controller.rb
app/controllers/admin/stats_controller.rb
module Admin class StatsController < Admin::ApplicationController # GET /stats # params: # model - Model 名称 # by - day, week, month def index result = { model: params[:model] } result[:count] = klass.unscoped.count result[:week_count] = klass.unscoped.where("created_at >= ?", Dat...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/admin/plugins_controller.rb
app/controllers/admin/plugins_controller.rb
module Admin class PluginsController < Admin::ApplicationController before_action :set_plugin, only: %i[show destroy] def index end def show end def create if Homeland::Plugin.install(params[:file]) Homeland.reboot redirect_to admin_plugins_path, notice: t("views.admin....
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/admin/users_controller.rb
app/controllers/admin/users_controller.rb
module Admin class UsersController < Admin::ApplicationController def index scope = User.includes(:profile) scope = scope.where(type: params[:type]) if params[:type].present? scope = scope.where(state: params[:state]) if params[:state].present? field = params[:field] || "login" if p...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/admin/site_configs_controller.rb
app/controllers/admin/site_configs_controller.rb
module Admin class SiteConfigsController < Admin::ApplicationController before_action :set_setting, only: %i[edit update] def index params[:scope] ||= "basic" @setting_groups = Setting.defined_fields.select { |field| !field[:readonly] }.group_by { |field| field[:scope] || :other } @scope =...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/admin/comments_controller.rb
app/controllers/admin/comments_controller.rb
module Admin class CommentsController < Admin::ApplicationController before_action :set_comment, only: %i[edit update destroy] respond_to :js, :html, only: [:destroy] def index @comments = Comment.recent.includes(:user).page(params[:page]) end def edit end def update if @com...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/admin/replies_controller.rb
app/controllers/admin/replies_controller.rb
module Admin class RepliesController < Admin::ApplicationController before_action :set_reply, only: %i[show edit destroy revert] def index @replies = Reply.unscoped if params[:q].present? qstr = "%#{params[:q].downcase}%" @replies = @replies.where("body LIKE ?", qstr) end ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/admin/photos_controller.rb
app/controllers/admin/photos_controller.rb
module Admin class PhotosController < Admin::ApplicationController before_action :set_photo, only: %i[destroy] def index @photos = Photo.recent.includes(:user) if params[:login].present? u = User.find_by_login(params[:login]) @photos = @photos.where("user_id = ?", u&.id) end...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/admin/nodes_controller.rb
app/controllers/admin/nodes_controller.rb
module Admin class NodesController < Admin::ApplicationController before_action :set_node, only: %i[show edit update destroy] def index @nodes = Node.sorted end def show end def new @node = Node.new end def edit end def create @node = Node.new(params[:nod...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/admin/applications_controller.rb
app/controllers/admin/applications_controller.rb
module Admin class ApplicationsController < Admin::ApplicationController before_action :set_application, only: %i[show edit update destroy] def index @applications = Doorkeeper::Application.all if params[:q].present? qstr = "%#{params[:q].downcase}%" @applications = @applications....
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/admin/application_controller.rb
app/controllers/admin/application_controller.rb
module Admin class ApplicationController < ::ApplicationController layout "admin" before_action :authenticate_user! before_action :require_admin before_action :set_active_menu def require_admin render_404 unless current_user.admin? end def set_active_menu @current = ["/" + [...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/topics/list_actions.rb
app/controllers/topics/list_actions.rb
module Topics module ListActions extend ActiveSupport::Concern included do end # GET /topics/popular # GET /topics/no_reply %i[no_reply popular].each do |name| define_method(name) do @topics = topics_scope.send(name).last_actived.page(params[:page]) render_index(name) ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/app/controllers/api/v3/topics_controller.rb
app/controllers/api/v3/topics_controller.rb
module Api module V3 class TopicsController < Api::V3::ApplicationController before_action :doorkeeper_authorize!, except: %i[index show replies] before_action :set_topic, except: %i[index create] # Get Topic List, like /topics page. # # GET /api/v3/topics # # @param typ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false