generated from discourse/discourse-plugin-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
39 additions
and
63 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# **Plugin Name** Plugin | ||
# Discourse Onebox Bilibili Plugin | ||
|
||
**Plugin Summary** | ||
|
||
For more information, please see: **url to meta topic** | ||
Add support for Bilibili video embeds in Discourse. |
Empty file.
This file was deleted.
Oops, something went wrong.
Empty file.
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,45 @@ | ||
# frozen_string_literal: true | ||
|
||
# name: discourse-plugin-name | ||
# about: TODO | ||
# meta_topic_id: TODO | ||
# version: 0.0.1 | ||
# authors: Discourse | ||
# url: TODO | ||
# name: discourse-onebox-bilibili | ||
# about: Add support for Bilibili video embeds in Discourse | ||
# version: 1.0.0 | ||
# authors: TreeNewBee | ||
# url: https://github.com/TheTNB/discourse-onebox-bilibili | ||
# required_version: 2.7.0 | ||
|
||
enabled_site_setting :plugin_name_enabled | ||
require "onebox" | ||
|
||
module ::MyPluginModule | ||
PLUGIN_NAME = "discourse-plugin-name" | ||
end | ||
class Onebox::Engine::BilibiliOnebox | ||
include Onebox::Engine | ||
|
||
matches_regexp(/^https?:\/\/(?:www\.)?bilibili\.com\/video\/([a-zA-Z0-9]+)\/?$/) | ||
always_https | ||
|
||
def video_id | ||
match = uri.path.match(/\/video\/av(\d+)(\.html)?.*/) | ||
return "aid=#{match[1]}" if match && match[1] | ||
match = uri.path.match(/\/video\/BV([a-zA-Z0-9]+)(\.html)?.*/) | ||
return "bvid=#{match[1]}" if match && match[1] | ||
|
||
nil | ||
rescue | ||
return nil | ||
end | ||
|
||
require_relative "lib/my_plugin_module/engine" | ||
def to_html | ||
<<-HTML | ||
<iframe | ||
src='https://player.bilibili.com/player.html?#{video_id}&p=1' | ||
frameborder="0" | ||
framespacing="0" | ||
width='100%' | ||
style='aspect-ratio: 16/9;margin:auto;' | ||
allowfullscreen> | ||
</iframe> | ||
HTML | ||
end | ||
|
||
after_initialize do | ||
# Code which should run after Rails has finished booting | ||
def placeholder_html | ||
to_html | ||
end | ||
end |
Empty file.
Empty file.