From ec332cf903354f8ab291ea33962d244a879c330d Mon Sep 17 00:00:00 2001 From: Unknwon Date: Wed, 17 Aug 2016 16:10:07 -0700 Subject: [PATCH] Minor naming improvement --- modules/context/auth.go | 4 +- modules/setting/setting.go | 9 ++-- modules/sync/single_instance_pool.go | 2 + public/js/gogs.js | 77 ++++++++++++++-------------- 4 files changed, 47 insertions(+), 45 deletions(-) diff --git a/modules/context/auth.go b/modules/context/auth.go index bc19467d44..746771791e 100644 --- a/modules/context/auth.go +++ b/modules/context/auth.go @@ -37,8 +37,8 @@ func Toggle(options *ToggleOptions) macaron.Handler { } // Check non-logged users landing page. - if !ctx.IsSigned && ctx.Req.RequestURI == "/" && setting.LandingPageUrl != setting.LANDING_PAGE_HOME { - ctx.Redirect(setting.AppSubUrl + string(setting.LandingPageUrl)) + if !ctx.IsSigned && ctx.Req.RequestURI == "/" && setting.LandingPageURL != setting.LANDING_PAGE_HOME { + ctx.Redirect(setting.AppSubUrl + string(setting.LandingPageURL)) return } diff --git a/modules/setting/setting.go b/modules/setting/setting.go index fe9c854953..1128e08ed0 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -46,7 +46,7 @@ const ( ) var ( - // Build information + // Build information should only be set by -ldflags. BuildTime string BuildGitHash string @@ -69,7 +69,7 @@ var ( CertFile, KeyFile string StaticRootPath string EnableGzip bool - LandingPageUrl LandingPage + LandingPageURL LandingPage UnixSocketPermission uint32 SSH struct { @@ -258,6 +258,7 @@ var ( HasRobotsTxt bool ) +// DateLang transforms standard language locale name to corresponding value in datetime plugin. func DateLang(lang string) string { name, ok := dateLangs[lang] if ok { @@ -407,9 +408,9 @@ func NewContext() { switch sec.Key("LANDING_PAGE").MustString("home") { case "explore": - LandingPageUrl = LANDING_PAGE_EXPLORE + LandingPageURL = LANDING_PAGE_EXPLORE default: - LandingPageUrl = LANDING_PAGE_HOME + LandingPageURL = LANDING_PAGE_HOME } SSH.RootPath = path.Join(homeDir, ".ssh") diff --git a/modules/sync/single_instance_pool.go b/modules/sync/single_instance_pool.go index 4a00d5283d..01d95fd0b5 100644 --- a/modules/sync/single_instance_pool.go +++ b/modules/sync/single_instance_pool.go @@ -24,6 +24,8 @@ type SingleInstancePool struct { // count maintains the number of times an instance with same identity checks in // to the pool, and should be reduced to 0 (removed from map) by checking out // with same number of times. + // The purpose of count is to delete lock when count down to 0 and recycle memory + // from map object. count map[string]int } diff --git a/public/js/gogs.js b/public/js/gogs.js index 677598753c..8204149fc2 100644 --- a/public/js/gogs.js +++ b/public/js/gogs.js @@ -4,21 +4,21 @@ var csrf; var suburl; function initCommentPreviewTab($form) { - var $tab_menu = $form.find('.tabular.menu'); - $tab_menu.find('.item').tab(); - $tab_menu.find('.item[data-tab="' + $tab_menu.data('preview') + '"]').click(function () { + var $tabMenu = $form.find('.tabular.menu'); + $tabMenu.find('.item').tab(); + $tabMenu.find('.item[data-tab="' + $tabMenu.data('preview') + '"]').click(function () { var $this = $(this); $.post($this.data('url'), { "_csrf": csrf, "mode": "gfm", "context": $this.data('context'), - "text": $form.find('.tab.segment[data-tab="' + $tab_menu.data('write') + '"] textarea').val() + "text": $form.find('.tab.segment[data-tab="' + $tabMenu.data('write') + '"] textarea').val() }, function (data) { - var $preview_tab = $form.find('.tab.segment[data-tab="' + $tab_menu.data('preview') + '"]'); - $preview_tab.html(data); - emojify.run($preview_tab[0]); - $('pre code', $preview_tab[0]).each(function (i, block) { + var $previewSegment = $form.find('.tab.segment[data-tab="' + $tabMenu.data('preview') + '"]'); + $previewSegment.html(data); + emojify.run($previewSegment[0]); + $('pre code', $previewSegment[0]).each(function (i, block) { hljs.highlightBlock(block); }); } @@ -28,61 +28,65 @@ function initCommentPreviewTab($form) { buttonsClickOnEnter(); } -var previewTab; var previewFileModes; function initEditPreviewTab($form) { - var $tab_menu = $form.find('.tabular.menu'); - $tab_menu.find('.item').tab(); - previewTab = $tab_menu.find('.item[data-tab="' + $tab_menu.data('preview') + '"]'); - - if (previewTab.length) { - previewFileModes = previewTab.data('preview-file-modes').split(','); - previewTab.click(function () { + var $tabMenu = $form.find('.tabular.menu'); + $tabMenu.find('.item').tab(); + var $previewTab = $tabMenu.find('.item[data-tab="' + $tabMenu.data('preview') + '"]'); + if ($previewTab.length) { + previewFileModes = $previewTab.data('preview-file-modes').split(','); + $previewTab.click(function () { var $this = $(this); $.post($this.data('url'), { "_csrf": csrf, "mode": "gfm", "context": $this.data('context'), - "text": $form.find('.tab.segment[data-tab="' + $tab_menu.data('write') + '"] textarea').val() + "text": $form.find('.tab.segment[data-tab="' + $tabMenu.data('write') + '"] textarea').val() }, function (data) { - var $preview_tab = $form.find('.tab.segment[data-tab="' + $tab_menu.data('preview') + '"]'); - $preview_tab.html(data); - emojify.run($preview_tab[0]); - $('pre code', $preview_tab[0]).each(function (i, block) { + var $previewSegment = $form.find('.tab.segment[data-tab="' + $tabMenu.data('preview') + '"]'); + $previewSegment.html(data); + emojify.run($previewSegment[0]); + $('pre code', $previewSegment[0]).each(function (i, block) { hljs.highlightBlock(block); }); } ); }); } - - buttonsClickOnEnter(); } function initEditDiffTab($form) { - var $tab_menu = $form.find('.tabular.menu'); - $tab_menu.find('.item').tab(); - $tab_menu.find('.item[data-tab="' + $tab_menu.data('diff') + '"]').click(function () { + var $tabMenu = $form.find('.tabular.menu'); + $tabMenu.find('.item').tab(); + $tabMenu.find('.item[data-tab="' + $tabMenu.data('diff') + '"]').click(function () { var $this = $(this); $.post($this.data('url'), { "_csrf": csrf, "context": $this.data('context'), - "content": $form.find('.tab.segment[data-tab="' + $tab_menu.data('write') + '"] textarea').val() + "content": $form.find('.tab.segment[data-tab="' + $tabMenu.data('write') + '"] textarea').val() }, function (data) { - var $diff_tab = $form.find('.tab.segment[data-tab="' + $tab_menu.data('diff') + '"]'); - $diff_tab.html(data); - emojify.run($diff_tab[0]); - initCodeView() + var $diffPreviewSegment = $form.find('.tab.segment[data-tab="' + $tabMenu.data('diff') + '"]'); + $diffPreviewSegment.html(data); + emojify.run($diffPreviewSegment[0]); } ); }); - - buttonsClickOnEnter(); } + +function initEditForm() { + if ($('.edit.form').length == 0) { + return; + } + + initEditPreviewTab($('.edit.form')); + initEditDiffTab($('.edit.form')); +} + + function initCommentForm() { if ($('.comment.form').length == 0) { return @@ -200,11 +204,6 @@ function initCommentForm() { selectItem('.select-assignee', '#assignee_id'); } -function initEditForm() { - initEditPreviewTab($('.edit.form')); - initEditDiffTab($('.edit.form')); -} - function initInstall() { if ($('.install').length == 0) { return; @@ -612,7 +611,7 @@ function initWikiForm() { "code", "quote", "|", "unordered-list", "ordered-list", "|", "link", "image", "table", "horizontal-rule", "|", - "clean-block", "preview", "fullscreen", "side-by-side"] + "clean-block", "preview", "fullscreen"] }) } }