1
0
mirror of synced 2026-08-05 18:26:57 +00:00

New and improved working version

This commit is contained in:
Rafael dos Santos Silva
2015-12-06 15:56:46 -02:00
parent f0a0a43d8e
commit 1ff4e7e1d5
6 changed files with 29 additions and 39 deletions
+3 -21
View File
@@ -2,32 +2,14 @@
Felling nostalgic of old VBulletin days? Wanna spam and flame like it's 2000?
![signature](https://cloud.githubusercontent.com/assets/1385470/11614719/c94ba4aa-9c31-11e5-9f32-67decaf0f3d3.png)
**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:
![user_fields](https://cloud.githubusercontent.com/assets/1385470/10153953/ecc5375a-6637-11e5-81a7-727deec3e41a.png)
After this go to Settings -> Users -> `public user custom fields` and add the custom fields who hold sig info, like this:
![public_fields](https://cloud.githubusercontent.com/assets/1385470/10153952/ecc38392-6637-11e5-9353-86e1832c2a1f.png)
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}}
-2
View File
@@ -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"
-6
View File
@@ -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
+22 -4
View File
@@ -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"