36 lines
907 B
Ruby
36 lines
907 B
Ruby
|
|
# frozen_string_literal: true
|
||
|
|
|
||
|
|
# name: discourse-url-to-article
|
||
|
|
# about: Scrapes a URL pasted into the topic title and populates the composer body with the article content
|
||
|
|
# version: 0.1.0
|
||
|
|
# authors: Your Name
|
||
|
|
# url: https://github.com/yourname/discourse-url-to-article
|
||
|
|
|
||
|
|
gem "nokogiri", "1.16.4"
|
||
|
|
gem "reverse_markdown", "2.1.1"
|
||
|
|
|
||
|
|
enabled_site_setting :url_to_article_enabled
|
||
|
|
|
||
|
|
after_initialize do
|
||
|
|
require_relative "lib/url_to_article/article_extractor"
|
||
|
|
|
||
|
|
module ::UrlToArticle
|
||
|
|
PLUGIN_NAME = "discourse-url-to-article"
|
||
|
|
|
||
|
|
class Engine < ::Rails::Engine
|
||
|
|
engine_name PLUGIN_NAME
|
||
|
|
isolate_namespace UrlToArticle
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
require_relative "app/controllers/url_to_article/articles_controller"
|
||
|
|
|
||
|
|
UrlToArticle::Engine.routes.draw do
|
||
|
|
post "/extract" => "articles#extract"
|
||
|
|
end
|
||
|
|
|
||
|
|
Discourse::Application.routes.append do
|
||
|
|
mount UrlToArticle::Engine, at: "/url-to-article"
|
||
|
|
end
|
||
|
|
end
|