DEV: General cleanup (#28)

Drop es6 suffix, fix Ember global usage, fix typos, update deps, add prettierrc, remove an obsolete codepath, fix pluginId.
This commit is contained in:
Jarek Radosz 2022-04-06 12:19:24 +02:00 committed by GitHub
parent de225b0a8b
commit 18b047121b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 1184 additions and 906 deletions

1
.prettierrc Normal file
View File

@ -0,0 +1 @@
{}

View File

@ -1,28 +1,31 @@
GEM
remote: https://rubygems.org/
specs:
ast (2.4.0)
jaro_winkler (1.5.4)
parallel (1.19.1)
parser (2.7.1.2)
ast (~> 2.4.0)
rainbow (3.0.0)
rexml (3.2.4)
rubocop (0.82.0)
jaro_winkler (~> 1.5.1)
ast (2.4.2)
parallel (1.22.1)
parser (3.1.1.0)
ast (~> 2.4.1)
rainbow (3.1.1)
regexp_parser (2.2.1)
rexml (3.2.5)
rubocop (1.26.1)
parallel (~> 1.10)
parser (>= 2.7.0.1)
parser (>= 3.1.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.16.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-discourse (2.1.2)
rubocop (>= 0.69.0)
rubocop-rspec (>= 1.39.0)
rubocop-rspec (1.39.0)
rubocop (>= 0.68.1)
ruby-progressbar (1.10.1)
unicode-display_width (1.7.0)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.16.0)
parser (>= 3.1.1.0)
rubocop-discourse (2.5.0)
rubocop (>= 1.1.0)
rubocop-rspec (>= 2.0.0)
rubocop-rspec (2.9.0)
rubocop (~> 1.19)
ruby-progressbar (1.11.0)
unicode-display_width (2.1.0)
PLATFORMS
ruby

View File

@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -8,27 +8,22 @@ Felling nostalgic of old VBulletin days? Wanna spam and flame like it's 2000?
**Install Discourse Signatures!**
## Installation
Proceed with a normal [installation of a plugin](https://meta.discourse.org/t/install-a-plugin/19157?u=falco).
## After Installation
You need to enable the plugins options for all users on Settings -> Plugins:
![signatures-admin](https://cloud.githubusercontent.com/assets/1385470/11616473/2c29715c-9c63-11e5-832d-6d171ca5ad79.png)
And each user need to enable and select a signature on his/her profile:
![signatures-preferencs](https://cloud.githubusercontent.com/assets/1385470/11616474/2c4426d2-9c63-11e5-88c6-93712ad0bb74.png)
![signatures-preferences](https://cloud.githubusercontent.com/assets/1385470/11616474/2c4426d2-9c63-11e5-88c6-93712ad0bb74.png)
and thats it!
## Advanced Mode
You can now enable **advanced mode** on the plugin settings and use a full blow post editor to create your signature! With text, multiple images, etc.
@ -39,5 +34,5 @@ This is a work in progress! Feel free to use and ask questions here, or on [Disc
## TODO
- Figure out a way so the user doens't have to refresh te browser to change the `see signatures` options.
- Figure out a way so the user doesn't have to refresh te browser to change the `see signatures` options
- Cache the cooked signatures

View File

@ -1,12 +1,13 @@
import { withPluginApi } from "discourse/lib/plugin-api";
import RawHtml from "discourse/widgets/raw-html";
import { isEmpty } from "@ember/utils";
function attachSignature(api, siteSettings) {
api.includePostAttributes("user_signature");
api.decorateWidget("post-contents:after-cooked", (dec) => {
const attrs = dec.attrs;
if (Ember.isEmpty(attrs.user_signature)) {
if (isEmpty(attrs.user_signature)) {
return;
}
@ -45,6 +46,8 @@ function attachSignature(api, siteSettings) {
function addSetting(api) {
api.modifyClass("controller:preferences/profile", {
pluginId: "discourse-signatures",
actions: {
save() {
this.set(

View File

@ -1,7 +1,10 @@
{
"name": "discourse-signatures",
"version": "2.1.0",
"repository": "https://github.com/discourse/discourse-signatures",
"author": "Discourse",
"license": "MIT",
"devDependencies": {
"eslint-config-discourse": "1.1.9"
"eslint-config-discourse": "^3.0.0"
}
}

View File

@ -5,6 +5,7 @@
# version: 2.1.0
# author: Rafael Silva <xfalcox@gmail.com>
# url: https://github.com/discourse/discourse-signatures
# transpile_js: true
enabled_site_setting :signatures_enabled
@ -13,7 +14,6 @@ DiscoursePluginRegistry.serialized_current_user_fields << "signature_url"
DiscoursePluginRegistry.serialized_current_user_fields << "signature_raw"
after_initialize do
User.register_custom_field_type('see_signatures', :boolean)
User.register_custom_field_type('signature_url', :text)
User.register_custom_field_type('signature_raw', :text)
@ -33,22 +33,16 @@ after_initialize do
register_editable_user_custom_field [:see_signatures, :signature_url, :signature_raw]
# TODO Drop after Discourse 2.6.0 release
if respond_to?(:allow_public_user_custom_field)
allow_public_user_custom_field :signature_cooked
allow_public_user_custom_field :signature_url
else
whitelist_public_user_custom_field :signature_cooked
whitelist_public_user_custom_field :signature_url
end
allow_public_user_custom_field :signature_cooked
allow_public_user_custom_field :signature_url
add_to_serializer(:post, :user_signature) {
if SiteSetting.signatures_advanced_mode then
add_to_serializer(:post, :user_signature) do
if SiteSetting.signatures_advanced_mode
object.user.custom_fields['signature_cooked'] if object.user
else
object.user.custom_fields['signature_url'] if object.user
end
}
end
# This is the code responsible for cooking a new advanced mode sig on user update
DiscourseEvent.on(:user_updated) do |user|

2012
yarn.lock

File diff suppressed because it is too large Load Diff