aboutsummaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
authorSandro Santilli <strk@kbt.io>2016-08-07 19:27:38 +0200
committer无闻 <u@gogs.io>2016-08-07 10:27:38 -0700
commit90dd0657b564210746c9c494c8c5b07dd8eee91f (patch)
tree228f1f1a684e355ef77c6d6798027dac76ce1d73 /templates
parentec92565f234deb75ea8df0c30a8772c4cd72bc2d (diff)
downloadgitea-90dd0657b564210746c9c494c8c5b07dd8eee91f.tar.gz
gitea-90dd0657b564210746c9c494c8c5b07dd8eee91f.zip
Add support for federated avatars (#3320)
* Add support for federated avatars Fixes #3105 Removes avatar fetching duplication code Adds an "Enable Federated Avatar" checkbox in user settings (defaults to unchecked) Moves avatar settings all in the same form, making local and remote avatars mutually exclusive Renames UploadAvatarForm to AvatarForm as it's not anymore only for uploading * Run gofmt on all modified files * Move Avatar form in its own page * Add go-libravatar dependency to vendor/ dir Hopefully helps with accepting the contribution. See also #3214 * Revert "Add go-libravatar dependency to vendor/ dir" This reverts commit a8cb93ae640bbb90f7d25012fc257bda9fae9b82. * Make federated avatar setting a global configuration Removes the per-user setting * Move avatar handling back to base tool, disable federated avatar in offline mode * Format, handle error * Properly set fallback host * Use unsupported github.com mirror for importing go-libravatar * Remove comment showing life exists outside of github.com ... pity, but contribution would not be accepted otherwise * Use Combo for Get and Post methods over /avatar * FEDERATED_AVATAR -> ENABLE_FEDERATED_AVATAR * Fix persistance of federated avatar lookup checkbox at install time * Federated Avatars -> Enable Federated Avatars * Use len(string) == 0 instead of string == "" * Move import line where it belong See https://github.com/Unknwon/go-code-convention/blob/master/en-US/import_packages.md Pity the import url is still the unofficial one, but oh well... * Save a line (and waste much more expensive time) * Remove redundant parens * Remove an empty line * Remove empty lines * Reorder lines to make diff smaller * Remove another newline Unknwon review got me start a fight against newlines * Move DISABLE_GRAVATAR and ENABLE_FEDERATED_AVATAR after OFFLINE_MODE On re-reading the diff I figured what Unknwon meant here: https://github.com/gogits/gogs/pull/3320/files#r73741106 * Remove newlines that weren't there before my intervention
Diffstat (limited to 'templates')
-rw-r--r--templates/admin/config.tmpl6
-rw-r--r--templates/install.tmpl6
-rw-r--r--templates/user/settings/avatar.tmpl50
-rw-r--r--templates/user/settings/navbar.tmpl3
-rw-r--r--templates/user/settings/profile.tmpl26
5 files changed, 65 insertions, 26 deletions
diff --git a/templates/admin/config.tmpl b/templates/admin/config.tmpl
index 880fca713b..93fc404ba1 100644
--- a/templates/admin/config.tmpl
+++ b/templates/admin/config.tmpl
@@ -215,6 +215,12 @@
<dd><i class="fa fa{{if .DisableGravatar}}-check{{end}}-square-o"></i></dd>
</dl>
</div>
+ <div class="ui attached table segment">
+ <dl class="dl-horizontal admin-dl-horizontal">
+ <dt>{{.i18n.Tr "admin.config.enable_federated_avatar"}}</dt>
+ <dd><i class="fa fa{{if .EnableFederatedAvatar}}-check{{end}}-square-o"></i></dd>
+ </dl>
+ </div>
<h4 class="ui top attached header">
{{.i18n.Tr "admin.config.log_config"}}
diff --git a/templates/install.tmpl b/templates/install.tmpl
index b3d4d7339d..496c425654 100644
--- a/templates/install.tmpl
+++ b/templates/install.tmpl
@@ -178,6 +178,12 @@
</div>
</div>
<div class="inline field">
+ <div class="ui checkbox" id="federated-avatar-lookup">
+ <label class="poping up" data-content="{{.i18n.Tr "install.federated_avatar_lookup"}}"><strong>{{.i18n.Tr "install.federated_avatar_lookup"}}</strong></label>
+ <input name="enable_federated_avatar" type="checkbox" {{if .enable_federated_avatar}}checked{{end}}>
+ </div>
+ </div>
+ <div class="inline field">
<div class="ui checkbox" id="disable-registration">
<label class="poping up" data-content="{{.i18n.Tr "install.disable_registration_popup"}}"><strong>{{.i18n.Tr "install.disable_registration"}}</strong></label>
<input name="disable_registration" type="checkbox" {{if .disable_registration}}checked{{end}}>
diff --git a/templates/user/settings/avatar.tmpl b/templates/user/settings/avatar.tmpl
new file mode 100644
index 0000000000..926c9d8508
--- /dev/null
+++ b/templates/user/settings/avatar.tmpl
@@ -0,0 +1,50 @@
+{{template "base/head" .}}
+<div class="user settings avatar">
+ <div class="ui container">
+ <div class="ui grid">
+ {{template "user/settings/navbar" .}}
+ <div class="twelve wide column content">
+ {{template "base/alert" .}}
+ <h4 class="ui top attached header">
+ {{.i18n.Tr "settings.avatar"}}
+ </h4>
+ <div class="ui attached segment">
+
+ <form class="ui form" action="{{.Link}}" method="post" enctype="multipart/form-data">
+ {{.CsrfTokenHtml}}
+ {{if not DisableGravatar}}
+ <div class="inline field">
+ <div class="ui radio">
+ <input name="source" value="lookup" type="radio" {{if not .SignedUser.UseCustomAvatar}}checked{{end}}>
+ <label>{{.i18n.Tr "settings.lookup_avatar_by_mail"}}</label>
+ </div>
+ </div>
+ <div class="field {{if .Err_Gravatar}}error{{end}}">
+ <label for="gravatar">Avatar {{.i18n.Tr "email"}}</label>
+ <input id="gravatar" name="gravatar" value="{{.SignedUser.AvatarEmail}}" />
+ </div>
+ {{end}}
+
+ <div class="inline field">
+ <div class="ui radio">
+ <input name="source" value="local" type="radio" {{if .SignedUser.UseCustomAvatar}}checked{{end}}>
+ <label>{{.i18n.Tr "settings.enable_custom_avatar"}}</label>
+ </div>
+ </div>
+
+ <div class="inline field">
+ <label for="avatar">{{.i18n.Tr "settings.choose_new_avatar"}}</label>
+ <input name="avatar" type="file" >
+ </div>
+
+ <div class="field">
+ <button class="ui green button">{{$.i18n.Tr "settings.update_avatar"}}</button>
+ <a class="ui red button delete-post" data-request-url="{{.Link}}/delete" data-done-url="{{.Link}}">{{$.i18n.Tr "settings.delete_current_avatar"}}</a>
+ </div>
+ </form>
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
+{{template "base/footer" .}}
diff --git a/templates/user/settings/navbar.tmpl b/templates/user/settings/navbar.tmpl
index 87e24522b4..5166bafaba 100644
--- a/templates/user/settings/navbar.tmpl
+++ b/templates/user/settings/navbar.tmpl
@@ -4,6 +4,9 @@
<a class="{{if .PageIsSettingsProfile}}active{{end}} item" href="{{AppSubUrl}}/user/settings">
{{.i18n.Tr "settings.profile"}}
</a>
+ <a class="{{if .PageIsSettingsAvatar}}active{{end}} item" href="{{AppSubUrl}}/user/settings/avatar">
+ {{.i18n.Tr "settings.avatar"}}
+ </a>
<a class="{{if .PageIsSettingsPassword}}active{{end}} item" href="{{AppSubUrl}}/user/settings/password">
{{.i18n.Tr "settings.password"}}
</a>
diff --git a/templates/user/settings/profile.tmpl b/templates/user/settings/profile.tmpl
index a1328a2210..a42d9c49c3 100644
--- a/templates/user/settings/profile.tmpl
+++ b/templates/user/settings/profile.tmpl
@@ -35,38 +35,12 @@
<label for="location">{{.i18n.Tr "settings.location"}}</label>
<input id="location" name="location" value="{{.SignedUser.Location}}">
</div>
- {{if not DisableGravatar}}
- <div class="field {{if .Err_Gravatar}}error{{end}}">
- <label for="gravatar">Gravatar {{.i18n.Tr "email"}}</label>
- <input id="gravatar" name="gravatar" value="{{.SignedUser.AvatarEmail}}" />
- </div>
- {{end}}
<div class="field">
<button class="ui green button">{{$.i18n.Tr "settings.update_profile"}}</button>
</div>
</form>
- <div class="ui divider"></div>
-
- <form class="ui form" action="{{.Link}}/avatar" method="post" enctype="multipart/form-data">
- {{.CsrfTokenHtml}}
- <div class="inline field">
- <div class="ui checkbox">
- <input name="enable" type="checkbox" {{if .SignedUser.UseCustomAvatar}}checked{{end}}>
- <label>{{.i18n.Tr "settings.enable_custom_avatar"}}</label>
- </div>
- </div>
- <div class="inline field">
- <label for="avatar">{{.i18n.Tr "settings.choose_new_avatar"}}</label>
- <input name="avatar" type="file" >
- </div>
-
- <div class="field">
- <button class="ui green button">{{$.i18n.Tr "settings.update_avatar"}}</button>
- <a class="ui red button delete-post" data-request-url="{{.Link}}/avatar/delete" data-done-url="{{.Link}}">{{$.i18n.Tr "settings.delete_current_avatar"}}</a>
- </div>
- </form>
</div>
</div>
</div>