New and improved working version
This commit is contained in:
@@ -2,32 +2,14 @@
|
||||
|
||||
Felling nostalgic of old VBulletin days? Wanna spam and flame like it's 2000?
|
||||
|
||||

|
||||
|
||||
**Install Discourse Signatures!**
|
||||
|
||||
|
||||
## Before Installation
|
||||
|
||||
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:
|
||||
|
||||

|
||||
|
||||
|
||||
After this go to Settings -> Users -> `public user custom fields` and add the custom fields who hold sig info, like this:
|
||||
|
||||

|
||||
|
||||
PS.: This can change if you have another user fields enabled. Maybe we get to set this by field name someday.
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
Now you proceed with a normal [installation of a plugin](https://meta.discourse.org/t/install-a-plugin/19157?u=falco).
|
||||
Proceed with a normal [installation of a plugin](https://meta.discourse.org/t/install-a-plugin/19157?u=falco).
|
||||
|
||||
|
||||
## After Installation
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
{{#if Discourse.SiteSettings.signatures_enabled}}
|
||||
{{#if user_show_signatures}}
|
||||
{{#if user_signature}}
|
||||
<hr>
|
||||
<img src="{{user_signature}}">
|
||||
{{/if}}
|
||||
{{#if showSignatures}}
|
||||
{{#if user_signature_url}}
|
||||
<hr>
|
||||
<img src="{{user_signature_url}}" class="signature-img">
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
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"
|
||||
|
||||
@@ -2,9 +2,3 @@ plugins:
|
||||
signatures_enabled:
|
||||
default: true
|
||||
client: true
|
||||
signatures_user_optin:
|
||||
default: signatures-view
|
||||
client: true
|
||||
signatures_user_signature:
|
||||
default: signatures-image-url
|
||||
client: true
|
||||
|
||||
@@ -1,17 +1,35 @@
|
||||
# name: discourse-signatures
|
||||
# about: A plugin to get that nostalgia signatures in Discourse Foruns
|
||||
# version: 0.0.1
|
||||
# version: 0.1.0
|
||||
# author: Rafael Silva <xfalcox@gmail.com>
|
||||
# url: https://github.com/xfalcox/discourse-signatures
|
||||
|
||||
enabled_site_setting :signatures_enabled
|
||||
|
||||
DiscoursePluginRegistry.serialized_current_user_fields << "see_signatures"
|
||||
DiscoursePluginRegistry.serialized_current_user_fields << "signature_url"
|
||||
|
||||
after_initialize do
|
||||
|
||||
User.register_custom_field_type('see_signatures', :boolean)
|
||||
User.register_custom_field_type('signature_url', :text)
|
||||
|
||||
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}"] }
|
||||
if SiteSetting.signatures_enabled then
|
||||
add_to_serializer(:post, :user_signature_url, false) {
|
||||
object.user.custom_fields['signature_url']
|
||||
}
|
||||
|
||||
# I guess this should be the default @ discourse. PR maybe?
|
||||
add_to_serializer(:user, :custom_fields, false) {
|
||||
if object.custom_fields == nil then
|
||||
{}
|
||||
else
|
||||
object.custom_fields
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
register_asset "javascripts/discourse/templates/connectors/user-custom-preferences/signature-preferences.hbs"
|
||||
register_asset "javascripts/discourse/templates/connectors/post-after-cooked/signature.hbs"
|
||||
register_asset "stylesheets/common/signatures.scss"
|
||||
|
||||
Reference in New Issue
Block a user