First Commit

This commit is contained in:
Rafael dos Santos Silva 2015-09-28 20:55:31 -03:00
commit abdb17f080
6 changed files with 59 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.idea/*
*.iml

17
README.md Normal file
View File

@ -0,0 +1,17 @@
# Discourse Signatures
Felling nostalgic of old VBulletin days? Wanna spam and flame like it's 2000?
**Install Discourse Signatures!**
## How to install
Since this is an early MVP the installation process is a bit, complicated.
First you need to create 2 Custom User Fields. This is easy as follow:
- Go to Admin -> Customize -> User Fields
- Make then look like this:

View File

@ -0,0 +1,8 @@
{{#if Discourse.SiteSettings.signatures_enabled}}
{{#if user_show_signatures}}
{{#if user_signature}}
<hr>
<img src="{{user_signature}}">
{{/if}}
{{/if}}
{{/if}}

View File

@ -0,0 +1,5 @@
en:
site_settings:
signatures_enabled: "Enable user-made signatures below posts?"
signatures_user_optin: "User field that contains the show signatures user option, like: signatures-view"
signatures_user_signature: "User field that contains the signature URL, like: signatures-image-url"

10
config/settings.yml Normal file
View File

@ -0,0 +1,10 @@
plugins:
signatures_enabled:
default: true
client: true
signatures_user_optin:
default: signatures-view
client: true
signatures_user_signature:
default: signatures-image-url
client: true

17
plugin.rb Normal file
View File

@ -0,0 +1,17 @@
# name: discourse-signatures
# about: A plugin to get that nostalgia signatures in Discourse Foruns
# version: 0.0.1
# author: Rafael Silva <xfalcox@gmail.com>
# url: https://github.com/xfalcox/discourse-signatures
enabled_site_setting :signatures_enabled
after_initialize do
if SiteSetting.signatures_enabled && SiteSetting.signatures_user_signature.present? && SiteSetting.signatures_user_optin.present? then
add_to_serializer(:post, :user_signature, false) { user_custom_fields["user_field_#{(UserField.find_by name: SiteSetting.signatures_user_signature).id}"] }
add_to_serializer(:post, :user_show_signatures, false) { user_custom_fields["user_field_#{(UserField.find_by name: SiteSetting.signatures_user_optin).id}"] }
end
end