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
postalserver/postal
https://github.com/postalserver/postal
spec/lib/smtp_client/server_spec.rb
Ruby
mit
16,477
main
2,230
# frozen_string_literal: true require "rails_helper" module SMTPClient RSpec.describe Server do let(:hostname) { "example.com" } let(:port) { 25 } let(:ssl_mode) { SSLModes::AUTO } subject(:server) { described_class.new(hostname, port: port, ssl_mode: ssl_mode) } describe "#endpoints" do ...
github
postalserver/postal
https://github.com/postalserver/postal
spec/lib/worker/jobs/process_queued_messages_job_spec.rb
Ruby
mit
16,477
main
5,072
# frozen_string_literal: true require "rails_helper" module Worker module Jobs RSpec.describe ProcessQueuedMessagesJob do subject(:job) { described_class.new(logger: Postal.logger) } before do allow(MessageDequeuer).to receive(:process) end describe "#call" do context ...
github
postalserver/postal
https://github.com/postalserver/postal
spec/lib/worker/jobs/process_webhook_requests_job_spec.rb
Ruby
mit
16,477
main
1,845
# frozen_string_literal: true require "rails_helper" module Worker module Jobs RSpec.describe ProcessWebhookRequestsJob do subject(:job) { described_class.new(logger: Postal.logger) } let(:mocked_service) { double("Service") } before do allow(WebhookDeliveryService).to receive(:new)...
github
postalserver/postal
https://github.com/postalserver/postal
spec/lib/smtp_server/client/rcpt_to_spec.rb
Ruby
mit
16,477
main
7,396
# frozen_string_literal: true require "rails_helper" module SMTPServer describe Client do let(:ip_address) { "1.2.3.4" } subject(:client) { described_class.new(ip_address) } describe "RCPT TO" do let(:helo) { "test.example.com" } let(:mail_from) { "test@example.com" } before do ...
github
postalserver/postal
https://github.com/postalserver/postal
spec/lib/smtp_server/client/finished_spec.rb
Ruby
mit
16,477
main
8,405
# frozen_string_literal: true require "rails_helper" module SMTPServer describe Client do let(:ip_address) { "1.2.3.4" } let(:server) { create(:server) } subject(:client) { described_class.new(ip_address) } let(:credential) { create(:credential, server: server, type: "SMTP") } let(:auth_plain)...
github
postalserver/postal
https://github.com/postalserver/postal
spec/lib/smtp_server/client/data_spec.rb
Ruby
mit
16,477
main
3,385
# frozen_string_literal: true require "rails_helper" module SMTPServer describe Client do let(:ip_address) { "1.2.3.4" } subject(:client) { described_class.new(ip_address) } describe "DATA" do it "returns an error if no helo" do expect(client.handle("DATA")).to eq "503 HELO/EHLO, MAIL FR...
github
postalserver/postal
https://github.com/postalserver/postal
spec/lib/smtp_server/client/proxy_spec.rb
Ruby
mit
16,477
main
775
# frozen_string_literal: true require "rails_helper" module SMTPServer describe Client do let(:ip_address) { nil } subject(:client) { described_class.new(ip_address) } describe "PROXY" do context "when the proxy header is sent correctly" do it "sets the IP address" do expect(cl...
github
postalserver/postal
https://github.com/postalserver/postal
spec/lib/smtp_server/client/helo_spec.rb
Ruby
mit
16,477
main
1,209
# frozen_string_literal: true require "rails_helper" module SMTPServer describe Client do let(:ip_address) { "1.2.3.4" } subject(:client) { described_class.new(ip_address) } describe "HELO" do it "returns the hostname" do expect(client.state).to eq :welcome expect(client.handle("...
github
postalserver/postal
https://github.com/postalserver/postal
spec/lib/smtp_server/client/mail_from_spec.rb
Ruby
mit
16,477
main
1,057
# frozen_string_literal: true require "rails_helper" module SMTPServer describe Client do let(:ip_address) { "1.2.3.4" } subject(:client) { described_class.new(ip_address) } describe "MAIL FROM" do it "returns an error if no HELO is provided" do expect(client.handle("MAIL FROM: test@exam...
github
postalserver/postal
https://github.com/postalserver/postal
spec/lib/smtp_server/client/auth_spec.rb
Ruby
mit
16,477
main
5,202
# frozen_string_literal: true require "rails_helper" module SMTPServer describe Client do let(:ip_address) { "1.2.3.4" } subject(:client) { described_class.new(ip_address) } before do client.handle("HELO test.example.com") end describe "AUTH PLAIN" do context "when no credentials ...
github
postalserver/postal
https://github.com/postalserver/postal
lib/tracking_middleware.rb
Ruby
mit
16,477
main
3,882
# frozen_string_literal: true class TrackingMiddleware TRACKING_PIXEL = File.read(Rails.root.join("app", "assets", "images", "tracking_pixel.png")) def initialize(app = nil) @app = app end def call(env) unless env["HTTP_X_POSTAL_TRACK_HOST"].to_i == 1 return @app.call(env) end request...
github
postalserver/postal
https://github.com/postalserver/postal
lib/migration_waiter.rb
Ruby
mit
16,477
main
1,666
# frozen_string_literal: true # This initializer will wait for all pending migrations to be applied before # continuing to start the application. This is useful when running the application # in a cluster where migrations are run in a separate job which runs at the same # time as the other processes. class MigrationW...
github
postalserver/postal
https://github.com/postalserver/postal
lib/tasks/auto_annotate_models.rake
Ruby
mit
16,477
main
2,619
# NOTE: only doing this in development as some production environments (Heroku) # NOTE: are sensitive to local FS writes, and besides -- it's just not proper # NOTE: to have a dev-mode tool do its thing in production. if Rails.env.development? require 'annotate' task :set_annotation_options do # You can overrid...
github
postalserver/postal
https://github.com/postalserver/postal
lib/tasks/postal.rake
Ruby
mit
16,477
main
1,550
# frozen_string_literal: true namespace :postal do desc "Run all migrations on message databases" task migrate_message_databases: :environment do Server.all.each do |server| puts "Running migrations for #{server.organization.permalink}/#{server.permalink} (ID: #{server.id})" server.message_db.provi...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/config.rb
Ruby
mit
16,477
main
5,623
# frozen_string_literal: true require "erb" require "yaml" require "pathname" require "cgi" require "openssl" require "fileutils" require "konfig" require "konfig/sources/environment" require "konfig/sources/yaml" require "dotenv" require "klogger" require_relative "error" require_relative "config_schema" require_rel...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/helm_config_exporter.rb
Ruby
mit
16,477
main
650
# frozen_string_literal: true require "konfig/exporters/abstract" module Postal class HelmConfigExporter < Konfig::Exporters::Abstract def export contents = [] path = [] @schema.groups.each do |group_name, group| path << group_name group.attributes.each do |name, _| ...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/yaml_config_exporter.rb
Ruby
mit
16,477
main
869
# frozen_string_literal: true require "konfig/exporters/abstract" module Postal class YamlConfigExporter < Konfig::Exporters::Abstract def export contents = [] contents << "version: 2" contents << "" @schema.groups.each do |group_name, group| contents << "#{group_name}:" ...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/legacy_config_source.rb
Ruby
mit
16,477
main
6,632
# frozen_string_literal: true require "konfig/sources/abstract" require "konfig/error" module Postal class LegacyConfigSource < Konfig::Sources::Abstract # This maps all the new configuration values to where they # exist in the old YAML file. The source will load any YAML # file that has been provided ...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/error.rb
Ruby
mit
16,477
main
330
# frozen_string_literal: true module Postal class Error < StandardError end module Errors class AuthenticationError < Error attr_reader :error def initialize(error) super() @error = error end def to_s "Authentication Failed: #{@error}" end end ...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/helpers.rb
Ruby
mit
16,477
main
234
# frozen_string_literal: true module Postal module Helpers def self.strip_name_from_address(address) return nil if address.nil? address.gsub(/.*</, "").gsub(/>.*/, "").gsub(/\(.+?\)/, "").strip end end end
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/signer.rb
Ruby
mit
16,477
main
1,642
# frozen_string_literal: true require "base64" module Postal class Signer # Create a new Signer # # @param [OpenSSL::PKey::RSA] private_key The private key to use for signing # @return [Signer] def initialize(private_key) @private_key = private_key end # Return the private key ...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/config_schema.rb
Ruby
mit
16,477
main
17,066
# frozen_string_literal: true require "uri" module Postal # REMEMBER: If you change the schema, remember to regenerate the configuration docs # using the rake command below: # # rake postal:generate_config_docs ConfigSchema = Konfig::Schema.draw do group :postal do string :web_hostname do ...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_inspector.rb
Ruby
mit
16,477
main
947
# frozen_string_literal: true module Postal class MessageInspector def initialize(config) @config = config end # Inspect a message and update the inspection with the results # as appropriate. def inspect_message(message, scope, inspection) end private def logger Postal...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_inspection.rb
Ruby
mit
16,477
main
735
# frozen_string_literal: true module Postal class MessageInspection attr_reader :message attr_reader :scope attr_reader :spam_checks attr_accessor :threat attr_accessor :threat_message def initialize(message, scope) @message = message @scope = scope @spam_checks = [] ...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/http.rb
Ruby
mit
16,477
main
2,740
# frozen_string_literal: true require "net/https" require "uri" module Postal module HTTP def self.get(url, options = {}) request(Net::HTTP::Get, url, options) end def self.post(url, options = {}) request(Net::HTTP::Post, url, options) end def self.request(method, url, options = {...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/spam_check.rb
Ruby
mit
16,477
main
368
# frozen_string_literal: true module Postal class SpamCheck attr_reader :code, :score, :description def initialize(code, score, description = nil) @code = code @score = score @description = description end def to_hash { code: code, score: score, desc...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_parser.rb
Ruby
mit
16,477
main
4,153
# frozen_string_literal: true module Postal class MessageParser URL_REGEX = /(?<url>(?<protocol>https?):\/\/(?<domain>[A-Za-z0-9\-.:]+)(?<path>\/[A-Za-z0-9.\/+?&\-_%=~:;()\[\]#]*)?+)/ def initialize(message) @message = message @actioned = false @tracked_links = 0 @tracked_images = 0...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_inspectors/clamav.rb
Ruby
mit
16,477
main
1,554
# frozen_string_literal: true module Postal module MessageInspectors class Clamav < MessageInspector def inspect_message(inspection) raw_message = inspection.message.raw_message data = nil Timeout.timeout(10) do tcp_socket = TCPSocket.new(@config.host, @config.port) ...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_inspectors/rspamd.rb
Ruby
mit
16,477
main
2,370
# frozen_string_literal: true require "net/http" module Postal module MessageInspectors class Rspamd < MessageInspector class Error < StandardError end def inspect_message(inspection) response = request(inspection.message, inspection.scope) response = JSON.parse(response.body...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_inspectors/spam_assassin.rb
Ruby
mit
16,477
main
1,979
# frozen_string_literal: true module Postal module MessageInspectors class SpamAssassin < MessageInspector EXCLUSIONS = { outgoing: ["NO_RECEIVED", "NO_RELAYS", "ALL_TRUSTED", "FREEMAIL_FORGED_REPLYTO", "RDNS_DYNAMIC", "CK_HELO_GENERIC", /^SPF_/, /^HELO_/, /DKIM_/, /^RCVD_IN_/], incoming: ...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/migration.rb
Ruby
mit
16,477
main
1,340
# frozen_string_literal: true module Postal module MessageDB class Migration def initialize(database) @database = database end def up end def self.run(database, start_from: database.schema_version, silent: false) files = Dir[Rails.root.join("lib", "postal", "messa...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/webhooks.rb
Ruby
mit
16,477
main
2,048
# frozen_string_literal: true module Postal module MessageDB class Webhooks def initialize(database) @database = database end def record(attributes = {}) @database.insert(:webhook_requests, attributes) end def list(page = 1) result = @database.select_with_...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/delivery.rb
Ruby
mit
16,477
main
2,596
# frozen_string_literal: true module Postal module MessageDB class Delivery def self.create(message, attributes = {}) attributes = message.database.stringify_keys(attributes) attributes = attributes.merge("message_id" => message.id, "timestamp" => Time.now.to_f) # Ensure that outp...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/suppression_list.rb
Ruby
mit
16,477
main
1,446
# frozen_string_literal: true module Postal module MessageDB class SuppressionList def initialize(database) @database = database end def add(type, address, options = {}) keep_until = (options[:days] || Postal::Config.postal.default_suppression_list_automatic_removal_days).days...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/click.rb
Ruby
mit
16,477
main
442
# frozen_string_literal: true module Postal module MessageDB class Click def initialize(attributes, link) @url = link["url"] @ip_address = attributes["ip_address"] @user_agent = attributes["user_agent"] @timestamp = Time.zone.at(attributes["timestamp"]) end att...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/connection_pool.rb
Ruby
mit
16,477
main
1,749
# frozen_string_literal: true module Postal module MessageDB class ConnectionPool attr_reader :connections def initialize @connections = [] @lock = Mutex.new end def use retried = false do_not_checkin = false begin connection = checkout...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/message.rb
Ruby
mit
16,477
main
16,313
# frozen_string_literal: true module Postal module MessageDB class Message class NotFound < Postal::Error end def self.find_one(database, query) query = { id: query.to_i } if query.is_a?(Integer) raise NotFound, "No message found matching provided query #{query}" unless messag...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/live_stats.rb
Ruby
mit
16,477
main
1,463
# frozen_string_literal: true module Postal module MessageDB class LiveStats def initialize(database) @database = database end # # Increment the live stats by one for the current minute # def increment(type) time = Time.now.utc type = @database.escape...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/statistics.rb
Ruby
mit
16,477
main
1,868
# frozen_string_literal: true module Postal module MessageDB class Statistics def initialize(database) @database = database end STATS_GAPS = { hourly: :hour, daily: :day, monthly: :month, yearly: :year }.freeze COUNTERS = [:incoming, :outgoing, :spam, :bounces, :held].freeze ...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/database.rb
Ruby
mit
16,477
main
11,221
# frozen_string_literal: true module Postal module MessageDB class Database class << self def connection_pool @connection_pool ||= ConnectionPool.new end end def initialize(organization_id, server_id, database_name: nil) @organization_id = organization_id ...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/load.rb
Ruby
mit
16,477
main
385
# frozen_string_literal: true module Postal module MessageDB class Load def initialize(attributes) @ip_address = attributes["ip_address"] @user_agent = attributes["user_agent"] @timestamp = Time.zone.at(attributes["timestamp"]) end attr_reader :ip_address attr_re...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/provisioner.rb
Ruby
mit
16,477
main
6,483
# frozen_string_literal: true module Postal module MessageDB class Provisioner def initialize(database) @database = database end # # Provisions a new database # def provision drop create migrate(silent: true) end # # Migrate...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/migrations/11_add_time_to_deliveries.rb
Ruby
mit
16,477
main
320
# frozen_string_literal: true module Postal module MessageDB module Migrations class AddTimeToDeliveries < Postal::MessageDB::Migration def up @database.query("ALTER TABLE `#{@database.database_name}`.`deliveries` ADD COLUMN `time` decimal(8,2)") end end end end end
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/migrations/03_create_deliveries.rb
Ruby
mit
16,477
main
1,302
# frozen_string_literal: true module Postal module MessageDB module Migrations class CreateDeliveries < Postal::MessageDB::Migration def up @database.provisioner.create_table(:deliveries, columns: { ...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/migrations/16_add_url_and_hook_to_webhooks.rb
Ruby
mit
16,477
main
592
# frozen_string_literal: true module Postal module MessageDB module Migrations class AddUrlAndHookToWebhooks < Postal::MessageDB::Migration def up @database.query("ALTER TABLE `#{@database.database_name}`.`webhook_requests` ADD COLUMN `url` varchar(255)") @database.query("ALTER...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/migrations/14_create_suppressions.rb
Ruby
mit
16,477
main
1,138
# frozen_string_literal: true module Postal module MessageDB module Migrations class CreateSuppressions < Postal::MessageDB::Migration def up @database.provisioner.create_table(:suppressions, columns: { ...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/migrations/06_create_clicks.rb
Ruby
mit
16,477
main
1,289
# frozen_string_literal: true module Postal module MessageDB module Migrations class CreateClicks < Postal::MessageDB::Migration def up @database.provisioner.create_table(:clicks, columns: { id: "...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/migrations/18_add_endpoints_to_messages.rb
Ruby
mit
16,477
main
364
# frozen_string_literal: true module Postal module MessageDB module Migrations class AddEndpointsToMessages < Postal::MessageDB::Migration def up @database.query("ALTER TABLE `#{@database.database_name}`.`messages` ADD COLUMN `endpoint_id` int(11), ADD COLUMN `endpoint_type` varchar(255)...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/migrations/20_increase_links_url_size.rb
Ruby
mit
16,477
main
303
# frozen_string_literal: true module Postal module MessageDB module Migrations class IncreaseLinksUrlSize < Postal::MessageDB::Migration def up @database.query("ALTER TABLE `#{@database.database_name}`.`links` MODIFY `url` TEXT") end end end end end
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/migrations/15_create_webhook_requests.rb
Ruby
mit
16,477
main
1,430
# frozen_string_literal: true module Postal module MessageDB module Migrations class CreateWebhookRequests < Postal::MessageDB::Migration def up @database.provisioner.create_table(:webhook_requests, columns: { ...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/migrations/13_add_index_to_message_status.rb
Ruby
mit
16,477
main
339
# frozen_string_literal: true module Postal module MessageDB module Migrations class AddIndexToMessageStatus < Postal::MessageDB::Migration def up @database.query("ALTER TABLE `#{@database.database_name}`.`messages` ADD INDEX `on_status` (`status`(8)) USING BTREE") end end...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/migrations/04_create_live_stats.rb
Ruby
mit
16,477
main
762
# frozen_string_literal: true module Postal module MessageDB module Migrations class CreateLiveStats < Postal::MessageDB::Migration def up @database.provisioner.create_table(:live_stats, columns: { ...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/migrations/17_add_replaced_link_count_to_messages.rb
Ruby
mit
16,477
main
589
# frozen_string_literal: true module Postal module MessageDB module Migrations class AddReplacedLinkCountToMessages < Postal::MessageDB::Migration def up @database.query("ALTER TABLE `#{@database.database_name}`.`messages` ADD COLUMN `tracked_links` int(11) DEFAULT 0") @databas...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/migrations/02_create_messages.rb
Ruby
mit
16,477
main
4,037
# frozen_string_literal: true module Postal module MessageDB module Migrations class CreateMessages < Postal::MessageDB::Migration def up @database.provisioner.create_table(:messages, columns: { i...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/migrations/07_create_loads.rb
Ruby
mit
16,477
main
1,135
# frozen_string_literal: true module Postal module MessageDB module Migrations class CreateLoads < Postal::MessageDB::Migration def up @database.provisioner.create_table(:loads, columns: { id: "in...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/migrations/10_create_spam_checks.rb
Ruby
mit
16,477
main
1,038
# frozen_string_literal: true module Postal module MessageDB module Migrations class CreateSpamChecks < Postal::MessageDB::Migration def up @database.provisioner.create_table(:spam_checks, columns: { ...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/migrations/09_create_links.rb
Ruby
mit
16,477
main
1,109
# frozen_string_literal: true module Postal module MessageDB module Migrations class CreateLinks < Postal::MessageDB::Migration def up @database.provisioner.create_table(:links, columns: { id: "in...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/migrations/05_create_raw_message_sizes.rb
Ruby
mit
16,477
main
811
# frozen_string_literal: true module Postal module MessageDB module Migrations class CreateRawMessageSizes < Postal::MessageDB::Migration def up @database.provisioner.create_table(:raw_message_sizes, columns: { ...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/migrations/12_add_hold_expiry.rb
Ruby
mit
16,477
main
320
# frozen_string_literal: true module Postal module MessageDB module Migrations class AddHoldExpiry < Postal::MessageDB::Migration def up @database.query("ALTER TABLE `#{@database.database_name}`.`messages` ADD COLUMN `hold_expiry` decimal(18,6)") end end end end end
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/migrations/01_create_migrations.rb
Ruby
mit
16,477
main
511
# frozen_string_literal: true module Postal module MessageDB module Migrations class CreateMigrations < Postal::MessageDB::Migration def up @database.provisioner.create_table(:migrations, columns: { ...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/migrations/08_create_stats.rb
Ruby
mit
16,477
main
1,207
# frozen_string_literal: true module Postal module MessageDB module Migrations class CreateStats < Postal::MessageDB::Migration def up [:hourly, :daily, :monthly, :yearly].each do |table_name| @database.provisioner.create_table("stats_#{table_name}", ...
github
postalserver/postal
https://github.com/postalserver/postal
lib/postal/message_db/migrations/19_convert_database_to_utf8mb4.rb
Ruby
mit
16,477
main
2,486
# frozen_string_literal: true module Postal module MessageDB module Migrations class ConvertDatabaseToUtf8mb4 < Postal::MessageDB::Migration def up @database.query("ALTER DATABASE `#{@database.database_name}` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci") @database.query("A...
github
postalserver/postal
https://github.com/postalserver/postal
script/queue_size.rb
Ruby
mit
16,477
main
576
#!/usr/bin/env ruby # frozen_string_literal: true require_relative "../lib/postal/config" require "mysql2" client = Mysql2::Client.new( host: Postal::Config.main_db.host, username: Postal::Config.main_db.username, password: Postal::Config.main_db.password, port: Postal::Config.main_db.port, database: Postal...
github
postalserver/postal
https://github.com/postalserver/postal
script/make_user.rb
Ruby
mit
16,477
main
206
#!/usr/bin/env ruby # frozen_string_literal: true trap("INT") do puts exit end require_relative "../config/environment" UserCreator.start do |u| u.admin = true u.email_verified_at = Time.now end
github
postalserver/postal
https://github.com/postalserver/postal
script/send_html_email.rb
Ruby
mit
16,477
main
1,288
# frozen_string_literal: true # This script will automatically send an HTML email to the # SMTP server given. require "mail" require "net/smtp" from = ARGV[0] to = ARGV[1] if from.nil? || to.nil? puts "Usage: ruby send-html-email.rb <from> <to>" exit 1 end mail = Mail.new mail.to = to mail.from = from mail.sub...
github
postalserver/postal
https://github.com/postalserver/postal
script/smtp_server.rb
Ruby
mit
16,477
main
356
# frozen_string_literal: true $stdout.sync = true $stderr.sync = true require_relative "../config/environment" HealthServer.start( name: "smtp-server", default_port: Postal::Config.smtp_server.default_health_server_port, default_bind_address: Postal::Config.smtp_server.default_health_server_bind_address ) SMTP...
github
postalserver/postal
https://github.com/postalserver/postal
script/test_app_smtp.rb
Ruby
mit
16,477
main
792
#!/usr/bin/env ruby # frozen_string_literal: true trap("INT") do puts exit end if ARGV[0].nil? || ARGV[0] !~ /@/ puts "usage: postal test-app-smtp [email address]" exit 1 end require_relative "../config/environment" begin Timeout.timeout(10) do AppMailer.test_message(ARGV[0]).deliver end puts "\e...
github
postalserver/postal
https://github.com/postalserver/postal
script/generate_tls_certificate.rb
Ruby
mit
16,477
main
968
# frozen_string_literal: true require File.expand_path("../lib/postal/config", __dir__) require "openssl" key_path = Postal::Config.smtp_server.tls_private_key_path cert_path = Postal::Config.smtp_server.tls_certificate_path unless File.exist?(key_path) key = OpenSSL::PKey::RSA.new(2048).to_s File.write(key_path...
github
postalserver/postal
https://github.com/postalserver/postal
script/worker.rb
Ruby
mit
16,477
main
346
#!/usr/bin/env ruby # frozen_string_literal: true $stdout.sync = true $stderr.sync = true require_relative "../config/environment" HealthServer.start( name: "worker", default_port: Postal::Config.worker.default_health_server_port, default_bind_address: Postal::Config.worker.default_health_server_bind_address )...
github
postalserver/postal
https://github.com/postalserver/postal
script/insert-bounce.rb
Ruby
mit
16,477
main
1,045
#!/usr/bin/env ruby # frozen_string_literal: true # This script will insert a message into your database that looks like a bounce # for a message that you specify. # usage: insert-bounce.rb [serverid] [messageid] if ARGV[0].nil? || ARGV[1].nil? puts "usage: #{__FILE__} [server-id] [message-id]" exit 1 end requi...
github
gollum/gollum
https://github.com/gollum/gollum
config.ru
Ruby
mit
14,262
master
303
=begin You should use this file, if you wish to: - launch Gollum as a Rack app, - alter certain startup behaviour of Gollum. For more information and examples: - https://github.com/gollum/gollum/wiki/Gollum-via-Rack - https://github.com/gollum/gollum#config-file =end # enter your Ruby code here ...
github
gollum/gollum
https://github.com/gollum/gollum
Gemfile
Ruby
mit
14,262
master
972
source 'https://rubygems.org' gem 'warbler', git: 'https://github.com/jruby/warbler' if RUBY_PLATFORM == 'java' # FIXME: There is an upstream JRuby 9.4.9.0 issue with `psych` and the latest # version of `jar-dependencies`. The issue will be resolved with the release of # 9.4.10.0. Then, we can remove this `jar-depend...
github
gollum/gollum
https://github.com/gollum/gollum
config.rb
Ruby
mit
14,262
master
354
=begin This file can be used to (e.g.): - alter certain inner parts of Gollum, - extend it with your stuff. It is especially useful for customizing supported formats/markups. For more information and examples: - https://github.com/gollum/gollum#config-file - https://github.com/gollum/gollum/wiki/Sample-config.rb =end...
github
gollum/gollum
https://github.com/gollum/gollum
gollum.gemspec
Ruby
mit
14,262
master
14,671
Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version= s.required_ruby_version = '>= 2.6' s.name = 'gollum' s.version = '6.1.0' s.license = 'MIT' s.summary = 'A simple, Git-powered wiki.' ...
github
gollum/gollum
https://github.com/gollum/gollum
Rakefile
Ruby
mit
14,262
master
7,888
require 'rubygems' require 'rake' require 'date' require 'tempfile' NODE_MODULES = File.join(File.dirname(__FILE__), 'node_modules') ############################################################################# # # Helper functions # ############################################################################# def r...
github
gollum/gollum
https://github.com/gollum/gollum
lib/gollum.rb
Ruby
mit
14,262
master
1,001
# ~*~ encoding: utf-8 ~*~ # stdlib require 'digest/md5' require 'digest/sha1' require 'ostruct' # external require 'i18n' require 'github/markup' require 'rhino' if RUBY_PLATFORM == 'java' # internal require ::File.expand_path('../gollum/uri_encode_component', __FILE__) module Gollum VERSION = '6.1.0' KEYBINDING...
github
gollum/gollum
https://github.com/gollum/gollum
lib/gollum/uri_encode_component.rb
Ruby
mit
14,262
master
6,395
# ~*~ encoding: utf-8 ~*~ =begin Copyright 2006-2008 the V8 project authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright...
github
gollum/gollum
https://github.com/gollum/gollum
lib/gollum/app.rb
Ruby
mit
14,262
master
25,084
# encoding: UTF-8 require 'cgi' require 'sinatra' require 'sinatra/namespace' require 'gollum-lib' require 'mustache/sinatra' require 'json' require 'sprockets' require 'sprockets-helpers' require 'octicons' require 'pathname' require 'gollum' require 'gollum/assets' # Requirements for loading the layout view: requi...
github
gollum/gollum
https://github.com/gollum/gollum
lib/gollum/assets.rb
Ruby
mit
14,262
master
1,848
require 'octicons' module Precious module Assets MANIFEST = %w(app.js editor.js gollum.mermaid.js gollum.katex.js app.css criticmarkup.css fileview.css ie7.css print.css katex/dist/katex.css *.png *.jpg *.svg *.eot *.ttf) ASSET_URL = 'gollum/assets' def self.sprockets(dir = File.dirname(File.expand_path...
github
gollum/gollum
https://github.com/gollum/gollum
lib/gollum/helpers.rb
Ruby
mit
14,262
master
2,262
# ~*~ encoding: utf-8 ~*~ require 'gemojione' module Precious module Helpers EMOJI_PATHNAME = Pathname.new(Gemojione.images_path).freeze def find_per_page_upload_subdir(referer, host_with_port, base_path) base = base_path ? remove_leading_and_trailing_slashes(base_path) : '' dir = referer.m...
github
gollum/gollum
https://github.com/gollum/gollum
lib/gollum/views/commit.rb
Ruby
mit
14,262
master
990
require_relative 'compare.rb' module Precious module Views class Commit < Compare attr_reader :version def title "Changes in #{@version[0..6]}: #{message}" end def author @commit.author.name end def authored_date @commit.authored_date end ...
github
gollum/gollum
https://github.com/gollum/gollum
lib/gollum/views/history.rb
Ruby
mit
14,262
master
1,704
module Precious module Views class History < Layout DATE_FORMAT = '%B %d, %Y' include HasPage include Pagination include HasUserIcons include Sprockets::Helpers include Precious::Views::SprocketsHelpers attr_reader :page, :allow_editing def title @page.ti...
github
gollum/gollum
https://github.com/gollum/gollum
lib/gollum/views/overview.rb
Ruby
mit
14,262
master
2,486
require 'pathname' module Precious module Views class Overview < Layout attr_reader :name, :results, :ref, :allow_editing, :newable HIDDEN_PATHS = ['.gitkeep'] def title t[:title] end # def editable # false # end def current_path @path ? @path ...
github
gollum/gollum
https://github.com/gollum/gollum
lib/gollum/views/create.rb
Ruby
mit
14,262
master
861
module Precious module Views class Create < Layout include Editable include HasMath attr_reader :page, :name def title "Create a new page" end def is_create_page true end def is_edit_page false end def allow_uploads @...
github
gollum/gollum
https://github.com/gollum/gollum
lib/gollum/views/has_math.rb
Ruby
mit
14,262
master
218
module Precious module HasMath def mathjax @math == :mathjax end def katex @math == :katex end def math_config @math_config ? page_route(@math_config) : false end end end
github
gollum/gollum
https://github.com/gollum/gollum
lib/gollum/views/pagination.rb
Ruby
mit
14,262
master
254
module Precious module Pagination def next_page result_set = @versions || results result_set.length < @max_count ? nil : (@page_num + 1).to_s end def previous_page @page_num == 1 ? nil : (@page_num - 1).to_s end end end
github
gollum/gollum
https://github.com/gollum/gollum
lib/gollum/views/has_user_icons.rb
Ruby
mit
14,262
master
297
module Precious module HasUserIcons def user_icon_code(str) Digest::MD5.hexdigest(str.strip.downcase) end def partial(name) if name == :author_template self.class.partial("history_authors/#{@wiki.user_icons}") else super end end end end
github
gollum/gollum
https://github.com/gollum/gollum
lib/gollum/views/helpers.rb
Ruby
mit
14,262
master
3,493
require 'json' module Precious module Views module AppHelpers def extract_page_dir(path) return path unless @page_dir @path_to_extract ||= "#{Pathname.new(@page_dir).cleanpath}/" path.start_with?(@path_to_extract) ? path.slice(@path_to_extract.length, path.length) : path end ...
github
gollum/gollum
https://github.com/gollum/gollum
lib/gollum/views/editable.rb
Ruby
mit
14,262
master
697
module Precious module Editable def has_editor true end def default_keybinding @default_keybinding end def keybindings Gollum::KEYBINDINGS.map do |kb| { :name => kb, :selected => default_keybinding == kb } end end def formats(selected = ...
github
gollum/gollum
https://github.com/gollum/gollum
lib/gollum/views/search.rb
Ruby
mit
14,262
master
977
module Precious module Views class Search < Layout attr_reader :query, :search_terms include Pagination def results sorted = @results.sort do |a, b| if b.nil? b_filename_count = 0 b_count = 0 else b_filename_count = b[:fil...
github
gollum/gollum
https://github.com/gollum/gollum
lib/gollum/views/has_page.rb
Ruby
mit
14,262
master
232
module Precious module HasPage def path @page.url_path end def escaped_url_path @page.escaped_url_path end def format @page.format.to_s end def id @page.sha end end end
github
gollum/gollum
https://github.com/gollum/gollum
lib/gollum/views/layout.rb
Ruby
mit
14,262
master
1,778
require 'cgi' module Precious module Views class Layout < Mustache include Sprockets::Helpers include Precious::Views::AppHelpers include Precious::Views::LocaleHelpers include Precious::Views::SprocketsHelpers include Precious::Views::RouteHelpers include Precious::Views::Oct...
github
gollum/gollum
https://github.com/gollum/gollum
lib/gollum/views/page.rb
Ruby
mit
14,262
master
7,159
module Precious module Views class Page < Layout include HasPage include HasMath attr_reader :page, :header, :footer, :preview, :historical, :version VALID_COUNTER_STYLES = ['decimal', 'decimal-leading-zero', 'arabic-indic', 'armenian', 'upper-armenian', 'lower-armenian', '...
github
gollum/gollum
https://github.com/gollum/gollum
lib/gollum/views/edit.rb
Ruby
mit
14,262
master
1,299
module Precious module Views class Edit < Layout include Editable include HasPage include HasMath attr_reader :page, :content # return path set in app.rb not @page.path def path @path end def title "#{@page.title}" end def page_name ...
github
gollum/gollum
https://github.com/gollum/gollum
lib/gollum/views/rss.rb
Ruby
mit
14,262
master
2,209
require 'rss' class RSSView include Precious::Views::AppHelpers include Precious::Views::RouteHelpers attr_reader :base_url def initialize(base_url, wiki_title, url, changes) @base_url = base_url @wiki_title = wiki_title @url = url @changes = changes end def render RSS::Maker.make('2...
github
gollum/gollum
https://github.com/gollum/gollum
lib/gollum/views/template_cascade.rb
Ruby
mit
14,262
master
802
module Precious module Views module TemplateCascade def template_priority_path @@template_priority_path ||= nil end def template_priority_path=(path) @@template_priority_path = File.expand_path(path) @template = nil end def first_path_available(name) ...
github
gollum/gollum
https://github.com/gollum/gollum
lib/gollum/views/latest_changes.rb
Ruby
mit
14,262
master
1,407
module Precious module Views class LatestChanges < Layout DATE_FORMAT = '%B %d, %Y' include Pagination include HasUserIcons attr_reader :wiki def title t[:title] end def versions i = @versions.size + 1 @versions.map do |v| i -= 1 ...
github
gollum/gollum
https://github.com/gollum/gollum
lib/gollum/views/compare.rb
Ruby
mit
14,262
master
3,012
module Precious module Views class Compare < Layout include HasPage attr_reader :page, :diff, :versions, :message, :allow_editing def title [t[:comparison_of], @page.title].join(" ") end def before @versions[0][0..6] end def after @versions[1][...
github
gollum/gollum
https://github.com/gollum/gollum
lib/gollum/views/helpers/locale_helpers.rb
Ruby
mit
14,262
master
2,702
module Precious module Views module LocaleHelpers NO_METHOD_MESSAGE = 'Argument must be a view method' YAML_VARIABLE_REGEXP = /\%\{[\w]+\}/ # Returns all I18n translation strings for the current view class. # This method support YAML arguments. For example: # # last_edited...
github
gollum/gollum
https://github.com/gollum/gollum
test/test_local_time_option.rb
Ruby
mit
14,262
master
1,620
# ~*~ encoding: utf-8 ~*~ require File.expand_path(File.join(File.dirname(__FILE__), 'helper')) require 'nokogiri' require 'json' require 'time' def local_time Precious::App.set(:wiki_options, { show_local_time: true}) end def no_local_time Precious::App.set(:wiki_options, { show_local_time: false}) end def asse...