Albirew/nyaa-pantsu
Albirew
/
nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/controllers/settings/settings.go

96 lignes
3.9 KiB
Go
Brut Vue normale Historique

package settingsController
First batch of changes for the refactor (#1078) * First batch of changes for the refactor Added the support of gin in routes and other services/utils Begining implementation of JetHTML * Remove os folder * Move scrapers to own repo * Second batch of changes All .jet.html are the working templates. You can now test this PR, the index Page and upload works. If you want to complete the other html templates, you're welcome * Move captcha to util * Move uploadService to utils * Use govalidator instead of regex * Third batch of changes All the front end should as previously. I also fixed some minor things unrelated to the refactor (mostly style issues on static pages) Now errors can be accessed by importing the "errors" helpers and using the `yield errors(name="xxx")` command in templates. Same for infos. Templates are now more hierarchized with a base template "base.jet.html" which is extended depending on the context in "index_site" or "index_admin" layouts. Those layouts are extended than in every pages. Other helpers are captcha to render a captcha `yield captcha(captchaid="xxx")` And also csrf, with the command `yield csrf_field()` To translate, you don't have anymore to do `call $.T "xxx"`, you just have to do `T("xxx")`. Pages for the website part are in folders in the folder "templates/site". Pages for the admin part are in "templates/admin". Layouts are separated in "templates/layouts". Helpers and menu are in "templates/layouts/helpers" and "templates/layouts/menu". Error pages should be put in "templates/errors" * Added test on templates When adding a new template, you have to tell to template_test.go, the context of the new template (if it doesn't use the common context) * Panel admin works Now the templating part should work. The PR can now be fully tested. I think we should push the templating PR and do the routes/controllers/removal of services in another branch. So we know that this one is functional * Updated dependencies * Fixed test for modelhelper * Fix testing for commentlist * Fix travis :') * Just renamed router and removed network * Applying same SEO fix * Update form_validator.go * Added back regexp package
2017-06-28 13:42:38 +02:00
import (
"net/http"
"net/url"
"time"
First batch of changes for the refactor (#1078) * First batch of changes for the refactor Added the support of gin in routes and other services/utils Begining implementation of JetHTML * Remove os folder * Move scrapers to own repo * Second batch of changes All .jet.html are the working templates. You can now test this PR, the index Page and upload works. If you want to complete the other html templates, you're welcome * Move captcha to util * Move uploadService to utils * Use govalidator instead of regex * Third batch of changes All the front end should as previously. I also fixed some minor things unrelated to the refactor (mostly style issues on static pages) Now errors can be accessed by importing the "errors" helpers and using the `yield errors(name="xxx")` command in templates. Same for infos. Templates are now more hierarchized with a base template "base.jet.html" which is extended depending on the context in "index_site" or "index_admin" layouts. Those layouts are extended than in every pages. Other helpers are captcha to render a captcha `yield captcha(captchaid="xxx")` And also csrf, with the command `yield csrf_field()` To translate, you don't have anymore to do `call $.T "xxx"`, you just have to do `T("xxx")`. Pages for the website part are in folders in the folder "templates/site". Pages for the admin part are in "templates/admin". Layouts are separated in "templates/layouts". Helpers and menu are in "templates/layouts/helpers" and "templates/layouts/menu". Error pages should be put in "templates/errors" * Added test on templates When adding a new template, you have to tell to template_test.go, the context of the new template (if it doesn't use the common context) * Panel admin works Now the templating part should work. The PR can now be fully tested. I think we should push the templating PR and do the routes/controllers/removal of services in another branch. So we know that this one is functional * Updated dependencies * Fixed test for modelhelper * Fix testing for commentlist * Fix travis :') * Just renamed router and removed network * Applying same SEO fix * Update form_validator.go * Added back regexp package
2017-06-28 13:42:38 +02:00
"github.com/NyaaPantsu/nyaa/config"
"github.com/NyaaPantsu/nyaa/controllers/router"
"github.com/NyaaPantsu/nyaa/templates"
msg "github.com/NyaaPantsu/nyaa/utils/messages"
"github.com/NyaaPantsu/nyaa/utils/publicSettings"
"github.com/NyaaPantsu/nyaa/utils/timeHelper"
First batch of changes for the refactor (#1078) * First batch of changes for the refactor Added the support of gin in routes and other services/utils Begining implementation of JetHTML * Remove os folder * Move scrapers to own repo * Second batch of changes All .jet.html are the working templates. You can now test this PR, the index Page and upload works. If you want to complete the other html templates, you're welcome * Move captcha to util * Move uploadService to utils * Use govalidator instead of regex * Third batch of changes All the front end should as previously. I also fixed some minor things unrelated to the refactor (mostly style issues on static pages) Now errors can be accessed by importing the "errors" helpers and using the `yield errors(name="xxx")` command in templates. Same for infos. Templates are now more hierarchized with a base template "base.jet.html" which is extended depending on the context in "index_site" or "index_admin" layouts. Those layouts are extended than in every pages. Other helpers are captcha to render a captcha `yield captcha(captchaid="xxx")` And also csrf, with the command `yield csrf_field()` To translate, you don't have anymore to do `call $.T "xxx"`, you just have to do `T("xxx")`. Pages for the website part are in folders in the folder "templates/site". Pages for the admin part are in "templates/admin". Layouts are separated in "templates/layouts". Helpers and menu are in "templates/layouts/helpers" and "templates/layouts/menu". Error pages should be put in "templates/errors" * Added test on templates When adding a new template, you have to tell to template_test.go, the context of the new template (if it doesn't use the common context) * Panel admin works Now the templating part should work. The PR can now be fully tested. I think we should push the templating PR and do the routes/controllers/removal of services in another branch. So we know that this one is functional * Updated dependencies * Fixed test for modelhelper * Fix testing for commentlist * Fix travis :') * Just renamed router and removed network * Applying same SEO fix * Update form_validator.go * Added back regexp package
2017-06-28 13:42:38 +02:00
"github.com/gin-gonic/gin"
)
// SeePublicSettingsHandler : Controller to view the languages and themes
func SeePublicSettingsHandler(c *gin.Context) {
_, Tlang := publicSettings.GetTfuncAndLanguageFromRequest(c)
availableLanguages := publicSettings.GetAvailableLanguages()
2017-07-23 07:46:29 +02:00
languagesJSON := templates.LanguagesJSONResponse{Tlang.Tag, availableLanguages}
First batch of changes for the refactor (#1078) * First batch of changes for the refactor Added the support of gin in routes and other services/utils Begining implementation of JetHTML * Remove os folder * Move scrapers to own repo * Second batch of changes All .jet.html are the working templates. You can now test this PR, the index Page and upload works. If you want to complete the other html templates, you're welcome * Move captcha to util * Move uploadService to utils * Use govalidator instead of regex * Third batch of changes All the front end should as previously. I also fixed some minor things unrelated to the refactor (mostly style issues on static pages) Now errors can be accessed by importing the "errors" helpers and using the `yield errors(name="xxx")` command in templates. Same for infos. Templates are now more hierarchized with a base template "base.jet.html" which is extended depending on the context in "index_site" or "index_admin" layouts. Those layouts are extended than in every pages. Other helpers are captcha to render a captcha `yield captcha(captchaid="xxx")` And also csrf, with the command `yield csrf_field()` To translate, you don't have anymore to do `call $.T "xxx"`, you just have to do `T("xxx")`. Pages for the website part are in folders in the folder "templates/site". Pages for the admin part are in "templates/admin". Layouts are separated in "templates/layouts". Helpers and menu are in "templates/layouts/helpers" and "templates/layouts/menu". Error pages should be put in "templates/errors" * Added test on templates When adding a new template, you have to tell to template_test.go, the context of the new template (if it doesn't use the common context) * Panel admin works Now the templating part should work. The PR can now be fully tested. I think we should push the templating PR and do the routes/controllers/removal of services in another branch. So we know that this one is functional * Updated dependencies * Fixed test for modelhelper * Fix testing for commentlist * Fix travis :') * Just renamed router and removed network * Applying same SEO fix * Update form_validator.go * Added back regexp package
2017-06-28 13:42:38 +02:00
contentType := c.Request.Header.Get("Content-Type")
if contentType == "application/json" {
c.Header("Content-Type", "application/json")
2017-07-23 07:46:29 +02:00
c.JSON(http.StatusOK, languagesJSON)
First batch of changes for the refactor (#1078) * First batch of changes for the refactor Added the support of gin in routes and other services/utils Begining implementation of JetHTML * Remove os folder * Move scrapers to own repo * Second batch of changes All .jet.html are the working templates. You can now test this PR, the index Page and upload works. If you want to complete the other html templates, you're welcome * Move captcha to util * Move uploadService to utils * Use govalidator instead of regex * Third batch of changes All the front end should as previously. I also fixed some minor things unrelated to the refactor (mostly style issues on static pages) Now errors can be accessed by importing the "errors" helpers and using the `yield errors(name="xxx")` command in templates. Same for infos. Templates are now more hierarchized with a base template "base.jet.html" which is extended depending on the context in "index_site" or "index_admin" layouts. Those layouts are extended than in every pages. Other helpers are captcha to render a captcha `yield captcha(captchaid="xxx")` And also csrf, with the command `yield csrf_field()` To translate, you don't have anymore to do `call $.T "xxx"`, you just have to do `T("xxx")`. Pages for the website part are in folders in the folder "templates/site". Pages for the admin part are in "templates/admin". Layouts are separated in "templates/layouts". Helpers and menu are in "templates/layouts/helpers" and "templates/layouts/menu". Error pages should be put in "templates/errors" * Added test on templates When adding a new template, you have to tell to template_test.go, the context of the new template (if it doesn't use the common context) * Panel admin works Now the templating part should work. The PR can now be fully tested. I think we should push the templating PR and do the routes/controllers/removal of services in another branch. So we know that this one is functional * Updated dependencies * Fixed test for modelhelper * Fix testing for commentlist * Fix travis :') * Just renamed router and removed network * Applying same SEO fix * Update form_validator.go * Added back regexp package
2017-06-28 13:42:38 +02:00
} else {
2017-07-23 07:46:29 +02:00
templates.Form(c, "site/user/public/settings.jet.html", languagesJSON)
First batch of changes for the refactor (#1078) * First batch of changes for the refactor Added the support of gin in routes and other services/utils Begining implementation of JetHTML * Remove os folder * Move scrapers to own repo * Second batch of changes All .jet.html are the working templates. You can now test this PR, the index Page and upload works. If you want to complete the other html templates, you're welcome * Move captcha to util * Move uploadService to utils * Use govalidator instead of regex * Third batch of changes All the front end should as previously. I also fixed some minor things unrelated to the refactor (mostly style issues on static pages) Now errors can be accessed by importing the "errors" helpers and using the `yield errors(name="xxx")` command in templates. Same for infos. Templates are now more hierarchized with a base template "base.jet.html" which is extended depending on the context in "index_site" or "index_admin" layouts. Those layouts are extended than in every pages. Other helpers are captcha to render a captcha `yield captcha(captchaid="xxx")` And also csrf, with the command `yield csrf_field()` To translate, you don't have anymore to do `call $.T "xxx"`, you just have to do `T("xxx")`. Pages for the website part are in folders in the folder "templates/site". Pages for the admin part are in "templates/admin". Layouts are separated in "templates/layouts". Helpers and menu are in "templates/layouts/helpers" and "templates/layouts/menu". Error pages should be put in "templates/errors" * Added test on templates When adding a new template, you have to tell to template_test.go, the context of the new template (if it doesn't use the common context) * Panel admin works Now the templating part should work. The PR can now be fully tested. I think we should push the templating PR and do the routes/controllers/removal of services in another branch. So we know that this one is functional * Updated dependencies * Fixed test for modelhelper * Fix testing for commentlist * Fix travis :') * Just renamed router and removed network * Applying same SEO fix * Update form_validator.go * Added back regexp package
2017-06-28 13:42:38 +02:00
}
}
// ChangePublicSettingsHandler : Controller for changing the current language and theme
func ChangePublicSettingsHandler(c *gin.Context) {
theme := c.PostForm("theme")
lang := c.PostForm("lang")
First batch of changes for the refactor (#1078) * First batch of changes for the refactor Added the support of gin in routes and other services/utils Begining implementation of JetHTML * Remove os folder * Move scrapers to own repo * Second batch of changes All .jet.html are the working templates. You can now test this PR, the index Page and upload works. If you want to complete the other html templates, you're welcome * Move captcha to util * Move uploadService to utils * Use govalidator instead of regex * Third batch of changes All the front end should as previously. I also fixed some minor things unrelated to the refactor (mostly style issues on static pages) Now errors can be accessed by importing the "errors" helpers and using the `yield errors(name="xxx")` command in templates. Same for infos. Templates are now more hierarchized with a base template "base.jet.html" which is extended depending on the context in "index_site" or "index_admin" layouts. Those layouts are extended than in every pages. Other helpers are captcha to render a captcha `yield captcha(captchaid="xxx")` And also csrf, with the command `yield csrf_field()` To translate, you don't have anymore to do `call $.T "xxx"`, you just have to do `T("xxx")`. Pages for the website part are in folders in the folder "templates/site". Pages for the admin part are in "templates/admin". Layouts are separated in "templates/layouts". Helpers and menu are in "templates/layouts/helpers" and "templates/layouts/menu". Error pages should be put in "templates/errors" * Added test on templates When adding a new template, you have to tell to template_test.go, the context of the new template (if it doesn't use the common context) * Panel admin works Now the templating part should work. The PR can now be fully tested. I think we should push the templating PR and do the routes/controllers/removal of services in another branch. So we know that this one is functional * Updated dependencies * Fixed test for modelhelper * Fix testing for commentlist * Fix travis :') * Just renamed router and removed network * Applying same SEO fix * Update form_validator.go * Added back regexp package
2017-06-28 13:42:38 +02:00
mascot := c.PostForm("mascot")
mascotURL := c.PostForm("mascot_url")
"Alternating Colors" option in settings (#1440) * Non-bold torrent name when using alternating background colors * Add alternating colors for g.css * Add alternating colors for classic.css * Add alternating colors for tomorreuw * Update classic.css * Add alternating colors to settings page * Add alt-colors class to tbody if enabled * Add GetAltColorsFromRequest() function to get AltColors cookie value * Create AltColors variable for usage in listing * Make settings handle altColors input * Add AltColors in user struct * Returned the wrong variable here * Turn function return value into bool * Condition checks variable like a bool * ditto * better color for g.css * even better color * better * Last change for g.css * Improvement for tomorrow * Update classic.css * add alt-colors class to upload preview * Add alt-colors to user profile * more vivid color for g * Fix typo * Remove browser outline for refine when clicked on * remove browser outline * Fix rules that didn't apply and category icon being way too small on user profile thanks to usage of percentage * Remove show-xs class for search inputs * Turn refine button back into position: absolute to pin at very bottom of refine * Alternating colors for g's trusted, remake & aplus * Update tomorrow.css * attempt at fixing travis * test (will have to rollback that change) * rollback * will have to rollback * will have to rollback * will have to rollback * will have to rollback * add AltColors variable to template test * rollback * rollback * rollback * rollback
2017-08-30 07:21:45 +02:00
altColors := c.PostForm("altColors")
"No comments" message, avatar in comments, classic theme improvements, some other changes, Old Navigation (#1545) * Update view.jet.html * Update en-us.all.json * Update view.jet.html * Update CHANGELOG.md * fix travis * Update classic.css * Update view.jet.html * Update main.css * Update classic.css * Update classic.css * Update classic.css * add link to user page & avatar in comment * stylisation for avatar in main.css * Update classic.css * Fix wrongly placed ::before * Add rule list to terms of service * import rules on register * fix refine-container-2's inputs * Update base.jet.html * Update en-us.all.json * Update CHANGELOG.md * GenNav changes to constantly put HTML for nav arrows regardless of page * css changes for website nav etc etc * add OldNav global variable * Add OldNav to test.go * Update publicSettings.go * change OldNav's value type * Old navigation in settings * add OldNav in user variables * add oldNav input handler in settings.go * Change OldNav's default value into false * Create OldNav.jet.html * Update search.jet.html * remove character that had nothing to do here * fix wrong variable name * fix worng variable name and travis * Update classic.css * Add sort order & type to old nav * add toString() function in test * add toString() function * translation string for oldnav setting * Use translation string in settings.jet.html * fix few html errors * ditto * travis fix test * remove useless charset * remove useless things * add spaces before attributes * attempt at fixing travis 2 * fix wrong variable name * Update classic.css * fix travis plsss
2017-09-11 19:45:39 +02:00
oldNav := c.PostForm("oldNav")
First batch of changes for the refactor (#1078) * First batch of changes for the refactor Added the support of gin in routes and other services/utils Begining implementation of JetHTML * Remove os folder * Move scrapers to own repo * Second batch of changes All .jet.html are the working templates. You can now test this PR, the index Page and upload works. If you want to complete the other html templates, you're welcome * Move captcha to util * Move uploadService to utils * Use govalidator instead of regex * Third batch of changes All the front end should as previously. I also fixed some minor things unrelated to the refactor (mostly style issues on static pages) Now errors can be accessed by importing the "errors" helpers and using the `yield errors(name="xxx")` command in templates. Same for infos. Templates are now more hierarchized with a base template "base.jet.html" which is extended depending on the context in "index_site" or "index_admin" layouts. Those layouts are extended than in every pages. Other helpers are captcha to render a captcha `yield captcha(captchaid="xxx")` And also csrf, with the command `yield csrf_field()` To translate, you don't have anymore to do `call $.T "xxx"`, you just have to do `T("xxx")`. Pages for the website part are in folders in the folder "templates/site". Pages for the admin part are in "templates/admin". Layouts are separated in "templates/layouts". Helpers and menu are in "templates/layouts/helpers" and "templates/layouts/menu". Error pages should be put in "templates/errors" * Added test on templates When adding a new template, you have to tell to template_test.go, the context of the new template (if it doesn't use the common context) * Panel admin works Now the templating part should work. The PR can now be fully tested. I think we should push the templating PR and do the routes/controllers/removal of services in another branch. So we know that this one is functional * Updated dependencies * Fixed test for modelhelper * Fix testing for commentlist * Fix travis :') * Just renamed router and removed network * Applying same SEO fix * Update form_validator.go * Added back regexp package
2017-06-28 13:42:38 +02:00
messages := msg.GetMessages(c)
availableLanguages := publicSettings.GetAvailableLanguages()
if !availableLanguages.Exist(lang) {
First batch of changes for the refactor (#1078) * First batch of changes for the refactor Added the support of gin in routes and other services/utils Begining implementation of JetHTML * Remove os folder * Move scrapers to own repo * Second batch of changes All .jet.html are the working templates. You can now test this PR, the index Page and upload works. If you want to complete the other html templates, you're welcome * Move captcha to util * Move uploadService to utils * Use govalidator instead of regex * Third batch of changes All the front end should as previously. I also fixed some minor things unrelated to the refactor (mostly style issues on static pages) Now errors can be accessed by importing the "errors" helpers and using the `yield errors(name="xxx")` command in templates. Same for infos. Templates are now more hierarchized with a base template "base.jet.html" which is extended depending on the context in "index_site" or "index_admin" layouts. Those layouts are extended than in every pages. Other helpers are captcha to render a captcha `yield captcha(captchaid="xxx")` And also csrf, with the command `yield csrf_field()` To translate, you don't have anymore to do `call $.T "xxx"`, you just have to do `T("xxx")`. Pages for the website part are in folders in the folder "templates/site". Pages for the admin part are in "templates/admin". Layouts are separated in "templates/layouts". Helpers and menu are in "templates/layouts/helpers" and "templates/layouts/menu". Error pages should be put in "templates/errors" * Added test on templates When adding a new template, you have to tell to template_test.go, the context of the new template (if it doesn't use the common context) * Panel admin works Now the templating part should work. The PR can now be fully tested. I think we should push the templating PR and do the routes/controllers/removal of services in another branch. So we know that this one is functional * Updated dependencies * Fixed test for modelhelper * Fix testing for commentlist * Fix travis :') * Just renamed router and removed network * Applying same SEO fix * Update form_validator.go * Added back regexp package
2017-06-28 13:42:38 +02:00
messages.AddErrorT("errors", "language_not_available")
}
// FIXME Are the settings actually sanitized?
// Limit the mascot URL, so base64-encoded images aren't valid
if len(mascotURL) > 256 {
messages.AddErrorT("errors", "mascot_url_too_long")
}
_, err := url.Parse(mascotURL)
if err != nil {
messages.AddErrorTf("errors", "mascor_url_parse_error", err.Error())
}
// If logged in, update user settings.
user := router.GetUser(c)
First batch of changes for the refactor (#1078) * First batch of changes for the refactor Added the support of gin in routes and other services/utils Begining implementation of JetHTML * Remove os folder * Move scrapers to own repo * Second batch of changes All .jet.html are the working templates. You can now test this PR, the index Page and upload works. If you want to complete the other html templates, you're welcome * Move captcha to util * Move uploadService to utils * Use govalidator instead of regex * Third batch of changes All the front end should as previously. I also fixed some minor things unrelated to the refactor (mostly style issues on static pages) Now errors can be accessed by importing the "errors" helpers and using the `yield errors(name="xxx")` command in templates. Same for infos. Templates are now more hierarchized with a base template "base.jet.html" which is extended depending on the context in "index_site" or "index_admin" layouts. Those layouts are extended than in every pages. Other helpers are captcha to render a captcha `yield captcha(captchaid="xxx")` And also csrf, with the command `yield csrf_field()` To translate, you don't have anymore to do `call $.T "xxx"`, you just have to do `T("xxx")`. Pages for the website part are in folders in the folder "templates/site". Pages for the admin part are in "templates/admin". Layouts are separated in "templates/layouts". Helpers and menu are in "templates/layouts/helpers" and "templates/layouts/menu". Error pages should be put in "templates/errors" * Added test on templates When adding a new template, you have to tell to template_test.go, the context of the new template (if it doesn't use the common context) * Panel admin works Now the templating part should work. The PR can now be fully tested. I think we should push the templating PR and do the routes/controllers/removal of services in another branch. So we know that this one is functional * Updated dependencies * Fixed test for modelhelper * Fix testing for commentlist * Fix travis :') * Just renamed router and removed network * Applying same SEO fix * Update form_validator.go * Added back regexp package
2017-06-28 13:42:38 +02:00
if user.ID > 0 {
user.Language = lang
user.Theme = theme
user.Mascot = mascot
user.MascotURL = mascotURL
"Alternating Colors" option in settings (#1440) * Non-bold torrent name when using alternating background colors * Add alternating colors for g.css * Add alternating colors for classic.css * Add alternating colors for tomorreuw * Update classic.css * Add alternating colors to settings page * Add alt-colors class to tbody if enabled * Add GetAltColorsFromRequest() function to get AltColors cookie value * Create AltColors variable for usage in listing * Make settings handle altColors input * Add AltColors in user struct * Returned the wrong variable here * Turn function return value into bool * Condition checks variable like a bool * ditto * better color for g.css * even better color * better * Last change for g.css * Improvement for tomorrow * Update classic.css * add alt-colors class to upload preview * Add alt-colors to user profile * more vivid color for g * Fix typo * Remove browser outline for refine when clicked on * remove browser outline * Fix rules that didn't apply and category icon being way too small on user profile thanks to usage of percentage * Remove show-xs class for search inputs * Turn refine button back into position: absolute to pin at very bottom of refine * Alternating colors for g's trusted, remake & aplus * Update tomorrow.css * attempt at fixing travis * test (will have to rollback that change) * rollback * will have to rollback * will have to rollback * will have to rollback * will have to rollback * add AltColors variable to template test * rollback * rollback * rollback * rollback
2017-08-30 07:21:45 +02:00
user.AltColors = altColors
"No comments" message, avatar in comments, classic theme improvements, some other changes, Old Navigation (#1545) * Update view.jet.html * Update en-us.all.json * Update view.jet.html * Update CHANGELOG.md * fix travis * Update classic.css * Update view.jet.html * Update main.css * Update classic.css * Update classic.css * Update classic.css * add link to user page & avatar in comment * stylisation for avatar in main.css * Update classic.css * Fix wrongly placed ::before * Add rule list to terms of service * import rules on register * fix refine-container-2's inputs * Update base.jet.html * Update en-us.all.json * Update CHANGELOG.md * GenNav changes to constantly put HTML for nav arrows regardless of page * css changes for website nav etc etc * add OldNav global variable * Add OldNav to test.go * Update publicSettings.go * change OldNav's value type * Old navigation in settings * add OldNav in user variables * add oldNav input handler in settings.go * Change OldNav's default value into false * Create OldNav.jet.html * Update search.jet.html * remove character that had nothing to do here * fix wrong variable name * fix worng variable name and travis * Update classic.css * Add sort order & type to old nav * add toString() function in test * add toString() function * translation string for oldnav setting * Use translation string in settings.jet.html * fix few html errors * ditto * travis fix test * remove useless charset * remove useless things * add spaces before attributes * attempt at fixing travis 2 * fix wrong variable name * Update classic.css * fix travis plsss
2017-09-11 19:45:39 +02:00
user.OldNav = oldNav
user.UpdateRaw()
First batch of changes for the refactor (#1078) * First batch of changes for the refactor Added the support of gin in routes and other services/utils Begining implementation of JetHTML * Remove os folder * Move scrapers to own repo * Second batch of changes All .jet.html are the working templates. You can now test this PR, the index Page and upload works. If you want to complete the other html templates, you're welcome * Move captcha to util * Move uploadService to utils * Use govalidator instead of regex * Third batch of changes All the front end should as previously. I also fixed some minor things unrelated to the refactor (mostly style issues on static pages) Now errors can be accessed by importing the "errors" helpers and using the `yield errors(name="xxx")` command in templates. Same for infos. Templates are now more hierarchized with a base template "base.jet.html" which is extended depending on the context in "index_site" or "index_admin" layouts. Those layouts are extended than in every pages. Other helpers are captcha to render a captcha `yield captcha(captchaid="xxx")` And also csrf, with the command `yield csrf_field()` To translate, you don't have anymore to do `call $.T "xxx"`, you just have to do `T("xxx")`. Pages for the website part are in folders in the folder "templates/site". Pages for the admin part are in "templates/admin". Layouts are separated in "templates/layouts". Helpers and menu are in "templates/layouts/helpers" and "templates/layouts/menu". Error pages should be put in "templates/errors" * Added test on templates When adding a new template, you have to tell to template_test.go, the context of the new template (if it doesn't use the common context) * Panel admin works Now the templating part should work. The PR can now be fully tested. I think we should push the templating PR and do the routes/controllers/removal of services in another branch. So we know that this one is functional * Updated dependencies * Fixed test for modelhelper * Fix testing for commentlist * Fix travis :') * Just renamed router and removed network * Applying same SEO fix * Update form_validator.go * Added back regexp package
2017-06-28 13:42:38 +02:00
}
if getDomainName() != "" {
//Clear every cookie from current domain so that users that old cookies from current domain do not interfere with new ones, should new one be shared within multiple subdomains
http.SetCookie(c.Writer, &http.Cookie{Name: "lang", Value: "", Domain: "", Path: "/", Expires: time.Now().AddDate(-1, -1, -1)})
http.SetCookie(c.Writer, &http.Cookie{Name: "theme", Value: "", Domain: "", Path: "/", Expires: time.Now().AddDate(-1, -1, -1)})
http.SetCookie(c.Writer, &http.Cookie{Name: "mascot", Value: "", Domain: "", Path: "/", Expires: time.Now().AddDate(-1, -1, -1)})
http.SetCookie(c.Writer, &http.Cookie{Name: "mascot_url", Value: "", Domain: "", Path: "/", Expires: time.Now().AddDate(-1, -1, -1)})
http.SetCookie(c.Writer, &http.Cookie{Name: "oldNav", Value: "", Domain: "", Path: "/", Expires: time.Now().AddDate(-1, -1, -1)})
}
First batch of changes for the refactor (#1078) * First batch of changes for the refactor Added the support of gin in routes and other services/utils Begining implementation of JetHTML * Remove os folder * Move scrapers to own repo * Second batch of changes All .jet.html are the working templates. You can now test this PR, the index Page and upload works. If you want to complete the other html templates, you're welcome * Move captcha to util * Move uploadService to utils * Use govalidator instead of regex * Third batch of changes All the front end should as previously. I also fixed some minor things unrelated to the refactor (mostly style issues on static pages) Now errors can be accessed by importing the "errors" helpers and using the `yield errors(name="xxx")` command in templates. Same for infos. Templates are now more hierarchized with a base template "base.jet.html" which is extended depending on the context in "index_site" or "index_admin" layouts. Those layouts are extended than in every pages. Other helpers are captcha to render a captcha `yield captcha(captchaid="xxx")` And also csrf, with the command `yield csrf_field()` To translate, you don't have anymore to do `call $.T "xxx"`, you just have to do `T("xxx")`. Pages for the website part are in folders in the folder "templates/site". Pages for the admin part are in "templates/admin". Layouts are separated in "templates/layouts". Helpers and menu are in "templates/layouts/helpers" and "templates/layouts/menu". Error pages should be put in "templates/errors" * Added test on templates When adding a new template, you have to tell to template_test.go, the context of the new template (if it doesn't use the common context) * Panel admin works Now the templating part should work. The PR can now be fully tested. I think we should push the templating PR and do the routes/controllers/removal of services in another branch. So we know that this one is functional * Updated dependencies * Fixed test for modelhelper * Fix testing for commentlist * Fix travis :') * Just renamed router and removed network * Applying same SEO fix * Update form_validator.go * Added back regexp package
2017-06-28 13:42:38 +02:00
// Set cookie with http and not gin for expires (maxage not supported in <IE8)
http.SetCookie(c.Writer, &http.Cookie{Name: "lang", Value: lang, Domain: getDomainName(), Path: "/", Expires: timeHelper.FewDaysLater(365)})
http.SetCookie(c.Writer, &http.Cookie{Name: "theme", Value: theme, Domain: getDomainName(), Path: "/", Expires: timeHelper.FewDaysLater(365)})
http.SetCookie(c.Writer, &http.Cookie{Name: "mascot", Value: mascot, Domain: getDomainName(), Path: "/", Expires: timeHelper.FewDaysLater(365)})
http.SetCookie(c.Writer, &http.Cookie{Name: "mascot_url", Value: mascotURL, Domain: getDomainName(), Path: "/", Expires: timeHelper.FewDaysLater(365)})
"No comments" message, avatar in comments, classic theme improvements, some other changes, Old Navigation (#1545) * Update view.jet.html * Update en-us.all.json * Update view.jet.html * Update CHANGELOG.md * fix travis * Update classic.css * Update view.jet.html * Update main.css * Update classic.css * Update classic.css * Update classic.css * add link to user page & avatar in comment * stylisation for avatar in main.css * Update classic.css * Fix wrongly placed ::before * Add rule list to terms of service * import rules on register * fix refine-container-2's inputs * Update base.jet.html * Update en-us.all.json * Update CHANGELOG.md * GenNav changes to constantly put HTML for nav arrows regardless of page * css changes for website nav etc etc * add OldNav global variable * Add OldNav to test.go * Update publicSettings.go * change OldNav's value type * Old navigation in settings * add OldNav in user variables * add oldNav input handler in settings.go * Change OldNav's default value into false * Create OldNav.jet.html * Update search.jet.html * remove character that had nothing to do here * fix wrong variable name * fix worng variable name and travis * Update classic.css * Add sort order & type to old nav * add toString() function in test * add toString() function * translation string for oldnav setting * Use translation string in settings.jet.html * fix few html errors * ditto * travis fix test * remove useless charset * remove useless things * add spaces before attributes * attempt at fixing travis 2 * fix wrong variable name * Update classic.css * fix travis plsss
2017-09-11 19:45:39 +02:00
http.SetCookie(c.Writer, &http.Cookie{Name: "oldNav", Value: oldNav, Domain: getDomainName(), Path: "/", Expires: timeHelper.FewDaysLater(365)})
First batch of changes for the refactor (#1078) * First batch of changes for the refactor Added the support of gin in routes and other services/utils Begining implementation of JetHTML * Remove os folder * Move scrapers to own repo * Second batch of changes All .jet.html are the working templates. You can now test this PR, the index Page and upload works. If you want to complete the other html templates, you're welcome * Move captcha to util * Move uploadService to utils * Use govalidator instead of regex * Third batch of changes All the front end should as previously. I also fixed some minor things unrelated to the refactor (mostly style issues on static pages) Now errors can be accessed by importing the "errors" helpers and using the `yield errors(name="xxx")` command in templates. Same for infos. Templates are now more hierarchized with a base template "base.jet.html" which is extended depending on the context in "index_site" or "index_admin" layouts. Those layouts are extended than in every pages. Other helpers are captcha to render a captcha `yield captcha(captchaid="xxx")` And also csrf, with the command `yield csrf_field()` To translate, you don't have anymore to do `call $.T "xxx"`, you just have to do `T("xxx")`. Pages for the website part are in folders in the folder "templates/site". Pages for the admin part are in "templates/admin". Layouts are separated in "templates/layouts". Helpers and menu are in "templates/layouts/helpers" and "templates/layouts/menu". Error pages should be put in "templates/errors" * Added test on templates When adding a new template, you have to tell to template_test.go, the context of the new template (if it doesn't use the common context) * Panel admin works Now the templating part should work. The PR can now be fully tested. I think we should push the templating PR and do the routes/controllers/removal of services in another branch. So we know that this one is functional * Updated dependencies * Fixed test for modelhelper * Fix testing for commentlist * Fix travis :') * Just renamed router and removed network * Applying same SEO fix * Update form_validator.go * Added back regexp package
2017-06-28 13:42:38 +02:00
c.Redirect(http.StatusSeeOther, "/")
}
func getDomainName() string {
domain := config.Get().Cookies.DomainName
if config.Get().Environment == "DEVELOPMENT" {
First batch of changes for the refactor (#1078) * First batch of changes for the refactor Added the support of gin in routes and other services/utils Begining implementation of JetHTML * Remove os folder * Move scrapers to own repo * Second batch of changes All .jet.html are the working templates. You can now test this PR, the index Page and upload works. If you want to complete the other html templates, you're welcome * Move captcha to util * Move uploadService to utils * Use govalidator instead of regex * Third batch of changes All the front end should as previously. I also fixed some minor things unrelated to the refactor (mostly style issues on static pages) Now errors can be accessed by importing the "errors" helpers and using the `yield errors(name="xxx")` command in templates. Same for infos. Templates are now more hierarchized with a base template "base.jet.html" which is extended depending on the context in "index_site" or "index_admin" layouts. Those layouts are extended than in every pages. Other helpers are captcha to render a captcha `yield captcha(captchaid="xxx")` And also csrf, with the command `yield csrf_field()` To translate, you don't have anymore to do `call $.T "xxx"`, you just have to do `T("xxx")`. Pages for the website part are in folders in the folder "templates/site". Pages for the admin part are in "templates/admin". Layouts are separated in "templates/layouts". Helpers and menu are in "templates/layouts/helpers" and "templates/layouts/menu". Error pages should be put in "templates/errors" * Added test on templates When adding a new template, you have to tell to template_test.go, the context of the new template (if it doesn't use the common context) * Panel admin works Now the templating part should work. The PR can now be fully tested. I think we should push the templating PR and do the routes/controllers/removal of services in another branch. So we know that this one is functional * Updated dependencies * Fixed test for modelhelper * Fix testing for commentlist * Fix travis :') * Just renamed router and removed network * Applying same SEO fix * Update form_validator.go * Added back regexp package
2017-06-28 13:42:38 +02:00
domain = ""
}
return domain
}