From 95c518329a077997cd859a36fe3558dae325890b Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 4 Nov 2014 13:33:58 +1100 Subject: [PATCH] FEATURE: display github profile links on user card and profile Can be disabled by unchecking "public_github_screen_name" --- app/assets/javascripts/discourse/models/user.js | 10 +++++++++- .../javascripts/discourse/templates/user-card.hbs | 2 ++ .../javascripts/discourse/templates/user/user.hbs | 4 ++++ app/assets/stylesheets/desktop/user.scss | 3 +++ app/assets/stylesheets/mobile/user.scss | 3 +++ app/serializers/user_serializer.rb | 8 +++++++- config/locales/server.en.yml | 1 + config/site_settings.yml | 1 + 8 files changed, 30 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/models/user.js b/app/assets/javascripts/discourse/models/user.js index 70884339273..f7be1f75a42 100644 --- a/app/assets/javascripts/discourse/models/user.js +++ b/app/assets/javascripts/discourse/models/user.js @@ -437,7 +437,15 @@ Discourse.User = Discourse.Model.extend({ }); } }, function () {}); - } + }, + + githubProfileUrl: function(){ + + var screenName = this.get('github_screen_name'); + if(screenName) { + return "https://github.com/" + screenName; + } + }.property() }); diff --git a/app/assets/javascripts/discourse/templates/user-card.hbs b/app/assets/javascripts/discourse/templates/user-card.hbs index f81ec37ea73..5b90e0d6a90 100644 --- a/app/assets/javascripts/discourse/templates/user-card.hbs +++ b/app/assets/javascripts/discourse/templates/user-card.hbs @@ -61,6 +61,8 @@

{{i18n last_post}} {{format-date path="user.last_posted_at" leaveAgo="true"}}

{{i18n joined}} {{format-date path="user.created_at" leaveAgo="true"}}

+ {{#if user.githubProfileUrl}} +

GitHub

{{/if}}
diff --git a/app/assets/javascripts/discourse/templates/user/user.hbs b/app/assets/javascripts/discourse/templates/user/user.hbs index 5659561b6db..0eb73f8d95e 100644 --- a/app/assets/javascripts/discourse/templates/user/user.hbs +++ b/app/assets/javascripts/discourse/templates/user/user.hbs @@ -150,6 +150,10 @@ {{/if}} {{/if}} + {{#if github_screen_name}} +
GitHub
+
{{github_screen_name}}
+ {{/if}} {{plugin-outlet "user-profile-secondary"}} diff --git a/app/assets/stylesheets/desktop/user.scss b/app/assets/stylesheets/desktop/user.scss index 6b43b1dd305..bf5823f7023 100644 --- a/app/assets/stylesheets/desktop/user.scss +++ b/app/assets/stylesheets/desktop/user.scss @@ -215,6 +215,9 @@ overflow: hidden; text-overflow: ellipsis; color: $primary; + a { + color: $primary; + } } dt { diff --git a/app/assets/stylesheets/mobile/user.scss b/app/assets/stylesheets/mobile/user.scss index 7acd33b6443..33071abf679 100644 --- a/app/assets/stylesheets/mobile/user.scss +++ b/app/assets/stylesheets/mobile/user.scss @@ -257,6 +257,9 @@ overflow: hidden; text-overflow: ellipsis; color: $primary; + a { + color: $primary; + } } dt { diff --git a/app/serializers/user_serializer.rb b/app/serializers/user_serializer.rb index 00d5f27dce7..1b17b06eb8e 100644 --- a/app/serializers/user_serializer.rb +++ b/app/serializers/user_serializer.rb @@ -48,7 +48,8 @@ class UserSerializer < BasicUserSerializer :has_title_badges, :edit_history_public, :custom_fields, - :user_fields + :user_fields, + :github_screen_name has_one :invited_by, embed: :object, serializer: BasicUserSerializer has_many :custom_groups, embed: :object, serializer: BasicGroupSerializer @@ -88,6 +89,11 @@ class UserSerializer < BasicUserSerializer ### ### ATTRIBUTES ### + def github_screen_name + if SiteSetting.public_github_screen_name + object.github_user_info && object.github_user_info.screen_name + end + end def include_email? object.id && object.id == scope.user.try(:id) diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 67a2df56b8b..0dac266c15e 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -808,6 +808,7 @@ en: facebook_app_secret: "App secret for Facebook authentication, registered at https://developers.facebook.com/apps" enable_github_logins: "Enable Github authentication, requires github_client_id and github_client_secret" + public_github_screen_name: "Display Github screen names publicly in the forum (on user page and profile)" github_client_id: "Client id for Github authentication, registered at https://github.com/settings/applications" github_client_secret: "Client secret for Github authentication, registered at https://github.com/settings/applications" diff --git a/config/site_settings.yml b/config/site_settings.yml index 2274aa2350c..b97fae5f7f3 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -212,6 +212,7 @@ login: enable_github_logins: client: true default: false + public_github_screen_name: true github_client_id: default: '' regex: "^[a-f0-9]*$"