mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-02 12:26:37 +08:00
1. remove unnecessary `.rb` filename suffixes from `require_relative` calls 2. replace `require File.expand_path(File.dirname(__FILE__) + …` with `require_relative` 3. remove `./` prefixes from `require_relative` calls
19 lines
553 B
Ruby
19 lines
553 B
Ruby
# frozen_string_literal: true
|
|
|
|
# name: discourse-affiliate
|
|
# about: Allows the creation of Amazon affiliate links on your forum.
|
|
# meta_topic_id: 101937
|
|
# version: 0.2
|
|
# authors: Régis Hanol (zogstrip), Sam Saffron
|
|
# url: https://github.com/discourse/discourse/tree/main/plugins/discourse-affiliate
|
|
|
|
enabled_site_setting :affiliate_enabled
|
|
|
|
after_initialize do
|
|
require_relative "lib/affiliate_processor"
|
|
|
|
on(:post_process_cooked) do |doc, post|
|
|
doc.css("a[href]").each { |a| a["href"] = AffiliateProcessor.apply(a["href"]) }
|
|
true
|
|
end
|
|
end
|