Merge pull request #1173 from git/constants

Move constants out of lib and freeze them
This commit is contained in:
Mark Tareshawty 2018-03-07 09:28:48 -05:00 коммит произвёл GitHub
Родитель 9986521401 c80113f8f3
Коммит 0892d28ef3
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 22 добавлений и 93 удалений

Просмотреть файл

@ -1,6 +1,5 @@
class BooksController < ApplicationController
before_filter :book_resource, only: [:section, :chapter]
before_filter :redirect_book, only: [:show]
def show
lang = params[:lang] || "en"
@ -52,16 +51,6 @@ class BooksController < ApplicationController
return redirect_to "/book/#{lang}/v2/#{@content.slug}"
end
def redirect_book
uri_path = params[:lang]
if slug = REDIRECT[uri_path]
/^(.*?)\/(.*)/.match(slug) do |m|
return redirect_to slug_book_path(lang: m[1], slug: m[2])
end
return redirect_to lang_book_path(lang: slug)
end
end
def book_resource
if edition = params[:edition]
@book ||= Book.where(:code => (params[:lang] || "en"), :edition => edition).first

Просмотреть файл

@ -25,12 +25,12 @@ class DocController < ApplicationController
end
def videos
@videos = VIDEOS
@videos = Gitscm::VIDEOS
end
def watch
slug = params[:id]
@video = VIDEOS.select{|a| a[4] == slug}.first
@video = Gitscm::VIDEOS.select{|a| a[4] == slug}.first
if !@video
redirect_to :videos
end

Просмотреть файл

@ -17,7 +17,7 @@ module ApplicationHelper
end
def random_tagline
content_tag(:em, '-' * 2) + TAGLINES.sample
content_tag(:em, '-' * 2) + Gitscm::TAGLINES.sample
end
def latest_version

Просмотреть файл

@ -3,7 +3,7 @@
<a href="/"><img src="/images/logo@2x.png" width="110" height="46" alt="Git" /></a>
<span id="tagline"></span>
<script type="text/javascript">
var taglines = <%= raw JSON.generate(TAGLINES) %>;
var taglines = <%= raw JSON.generate(Gitscm::TAGLINES) %>;
var tagline = taglines[Math.floor(Math.random() * taglines.length)];
document.getElementById('tagline').innerHTML = '--' + tagline;
</script>

Просмотреть файл

@ -22,10 +22,5 @@ module Gitscm
config.assets.enabled = true
config.assets.initialize_on_precompile = false
initializer(:load_constants) do
require Rails.root.join("lib/constants.rb").to_s
end
end
end

Просмотреть файл

@ -0,0 +1,18 @@
# frozen_string_literal: true
module Gitscm
TAGLINES = %w[
fast-version-control
everything-is-local
distributed-even-if-your-workflow-isnt
local-branching-on-the-cheap
distributed-is-the-new-centralized
].freeze
VIDEOS = [
[1, "41027679", "Git Basics", "What is Version Control?", "what-is-version-control", "05:59"],
[2, "41381741", "Git Basics", "What is Git?", "what-is-git", "08:15"],
[3, "41493906", "Git Basics", "Get Going with Git", "get-going", "04:26"],
[4, "41516942", "Git Basics", "Quick Wins with Git", "quick-wins", "05:06"],
].freeze
end

Просмотреть файл

@ -1,73 +0,0 @@
# ApplicationHelper
TAGLINES = %w{
fast-version-control
everything-is-local
distributed-even-if-your-workflow-isnt
local-branching-on-the-cheap
distributed-is-the-new-centralized
}
#DocsControllers#watch
VIDEOS = [
[1, "41027679", "Git Basics", "What is Version Control?", "what-is-version-control", "05:59"],
[2, "41381741", "Git Basics", "What is Git?", "what-is-git", "08:15"],
[3, "41493906", "Git Basics", "Get Going with Git", "get-going", "04:26"],
[4, "41516942", "Git Basics", "Quick Wins with Git", "quick-wins", "05:06"],
]
# SiteController#redirect_combook
REDIRECT = {
"1_welcome_to_git" => "en/Getting-Started",
"1_the_git_object_model" => "en/Git-Internals-Git-Objects",
"1_git_directory_and_working_directory" => "en/Git-Basics-Recording-Changes-to-the-Repository",
"1_the_git_index" => "en/Git-Basics-Recording-Changes-to-the-Repository",
"2_installing_git" => "en/Getting-Started-Installing-Git",
"2_setup_and_initialization" => "en/Getting-Started-First-Time-Git-Setup",
"3_getting_a_git_repository" => "en/Git-Basics-Getting-a-Git-Repository",
"3_normal_workflow" => "en/Git-Basics-Recording-Changes-to-the-Repository",
"3_basic_branching_and_merging" => "en/Git-Branching-Basic-Branching-and-Merging",
"3_reviewing_history_-_git_log" => "en/Git-Basics-Viewing-the-Commit-History",
"3_comparing_commits_-_git_diff" => "en/Git-Basics-Recording-Changes-to-the-Repository#Viewing-Your-Staged-and-Unstaged-Changes",
"3_distributed_workflows" => "en/Distributed-Git-Distributed-Workflows",
"3_git_tag" => "en/Git-Basics-Tagging",
"4_ignoring_files" => "en/Git-Basics-Recording-Changes-to-the-Repository#Ignoring-Files",
"4_rebasing" => "en/Git-Branching-Rebasing",
"4_interactive_rebasing" => "en/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages",
"4_interactive_adding" => "en/Git-Tools-Interactive-Staging",
"4_stashing" => "en/Git-Tools-Stashing",
"4_git_treeishes" => "en/Git-Tools-Revision-Selection",
"4_tracking_branches" => "en/Git-Branching-Remote-Branches#Tracking-Branches",
"4_finding_with_git_grep" => "",
"4_undoing_in_git_-_reset,_checkout_and_revert" => "en/Git-Basics-Undoing-Things",
"4_maintaining_git" => "en/Git-Internals-Maintenance-and-Data-Recovery",
"4_setting_up_a_public_repository" => "en/Git-on-the-Server-Public-Access",
"4_setting_up_a_private_repository" => "en/Git-on-the-Server-Setting-Up-the-Server",
"5_creating_new_empty_branches" => "",
"5_modifying_your_history" => "en/Git-Tools-Rewriting-History",
"5_advanced_branching_and_merging" => "en/Git-Branching-Basic-Branching-and-Merging",
"5_finding_issues_-_git_bisect" => "en/Git-Tools-Debugging-with-Git#Binary-Search",
"5_finding_issues_-_git_blame" => "en/Git-Tools-Debugging-with-Git#File-Annotation",
"5_git_and_email" => "en/Distributed-Git-Contributing-to-a-Project#Public-Large-Project",
"5_customizing_git" => "en/Customizing-Git-Git-Configuration",
"5_git_hooks" => "en/Customizing-Git-Git-Hooks",
"5_recovering_corrupted_objects" => "en/Git-Internals-Maintenance-and-Data-Recovery#Data-Recovery",
"5_submodules" => "en/Git-Tools-Submodules",
"6_git_on_windows" => "",
"6_deploying_with_git" => "",
"6_subversion_integration" => "en/Git-and-Other-Systems-Git-and-Subversion",
"6_scm_migration" => "en/Git-and-Other-Systems-Migrating-to-Git",
"6_graphical_git" => "",
"6_hosted_git" => "en/Git-on-the-Server-Hosted-Git",
"6_alternative_uses" => "",
"6_scripting_and_git" => "en/Customizing-Git-An-Example-Git-Enforced-Policy",
"6_git_and_editors" => "",
"7_how_git_stores_objects" => "en/Git-Internals-Git-Objects",
"7_browsing_git_objects" => "en/Git-Internals-Git-Objects",
"7_git_references" => "en/Git-Internals-Git-References",
"7_the_git_index" => "",
"7_the_packfile" => "en/Git-Internals-Packfiles",
"7_raw_git" => "en/Git-Internals-Git-Objects",
"7_transfer_protocols" => "en/Git-Internals-Transfer-Protocols",
"7_glossary" => "commands"
}