From 94f505ea4777f4406b819a376b0df8a0e41adaf0 Mon Sep 17 00:00:00 2001 From: Olivier Lacan Date: Tue, 20 Jun 2017 06:38:17 +0200 Subject: [PATCH] Add legacy styles for old versions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also improved the messages indicating a new version is available for each language so they can be written in the target language otherwise they default to English just like the notice that a version isn’t the latest but hasn’t yet been translated for the newer version. --- config.rb | 23 ++-- source/assets/stylesheets/legacy.css.sass | 127 ++++++++++++++++++++++ source/layouts/layout.html.haml | 25 +++-- 3 files changed, 153 insertions(+), 22 deletions(-) create mode 100644 source/assets/stylesheets/legacy.css.sass diff --git a/config.rb b/config.rb index f204783..0557690 100644 --- a/config.rb +++ b/config.rb @@ -11,8 +11,7 @@ $last_version = (Dir.entries("source/en") - %w[. ..]).last issues_url = 'https://github.com/olivierlacan/keep-a-changelog/issues' $languages = { "cs" => { - name: "Čeština", - notice: "" + name: "Čeština" }, "de" => { name: "Deutsch", @@ -23,7 +22,7 @@ $languages = { "en" => { default: true, name: "English", - notice: "" + new: "A new version is available" }, "es-ES" => { name: "Español", @@ -35,7 +34,8 @@ $languages = { name: "Français", notice: "La dernière version (#{$last_version}) n'est pas encore disponible en français, mais vous pouvez la lire en anglais pour - l'instant et aider à la traduire." + l'instant et aider à la traduire.", + new: "Une nouvelle version est disponible" }, "it-IT" => { name: "Italiano", @@ -44,8 +44,7 @@ $languages = { potete contribuire a tradurla." }, "pl-PL" => { - name: "Polskie", - notice: "" + name: "Polskie" }, "pt-BR" => { name: "Brazilian Portugese", @@ -60,8 +59,7 @@ $languages = { href='#{issues_url}'>помочь с переводом." }, "sl" => { - name: "Slovenščina", - notice: "" + name: "Slovenščina" }, "sv" => { name: "Svenska", @@ -70,16 +68,13 @@ $languages = { href='#{issues_url}'>hjälpa till att översätta det." }, "tr-TR" => { - name: "Türkçe", - notice: "" + name: "Türkçe" }, "zh-CN" => { - name: "简体中文", - notice: "" + name: "简体中文" }, "zh-TW" => { - name: "繁體中文", - notice: "" + name: "繁體中文" } } diff --git a/source/assets/stylesheets/legacy.css.sass b/source/assets/stylesheets/legacy.css.sass new file mode 100644 index 0000000..d255884 --- /dev/null +++ b/source/assets/stylesheets/legacy.css.sass @@ -0,0 +1,127 @@ +$base-font-family: "Carrois Gothic", "Helvetica Neue", Helvetica, Arial, sans-serif +$source-code-font-family: "Source Code Pro", monospace + +html + font: 14px/1.4 $base-font-family + color: #333 + +a + color: #E10FCE + font-weight: bold + text-decoration: none + +a:hover + text-decoration: underline + +h1 + color: #C647BF + font-size: 4.1em + font-weight: bold + font-family: $source-code-font-family + margin-bottom: 0 + line-height: 1 + word-spacing: -0.3em + +h2 + margin-top: 0 + margin-bottom: 2em + +h1, h2 + text-align: center + +h3 + font-size: 1.3em + font-family: $source-code-font-family + margin-bottom: 0 + position: relative + padding-left: .1em + +h3:hover .anchor, h3:focus .anchor + display: block + +.anchor + display: none + font-style: normal + font-weight: normal + position: absolute + right: 100% + top: 0 + +.anchor::before + content: '¶' + +.anchor:hover + text-decoration: none + +h3 ~ p + margin-top: 0 + +article + margin: 0 auto + width: 640px + +article p + font-size: 1.3em + +article code + border-radius: 0.315em + border: 1px solid #ccc + padding: 0 0.3em 0.040em + font-size: 0.9em + +article img + margin: 0 auto + max-width: 100% + text-align: center + display: block + box-shadow: rgba(0, 0, 0, 0.37) 0px 0px 6px + border-radius: 7px + padding: 0.4em 0.9em + +article > ul + font-size: 1.2em + padding-left: 0 + +article > ul ul + padding-left: 1em + +article ul + line-height: 1.5 + list-style-position: inside + list-style-type: square + +footer + font-size: .7em + border-top: 1px solid #e9e6e1 + margin-top: 1em + margin-bottom: 2em + padding-top: 1em + +.license + float: left + +.about + float: right + +.about, .license + margin-top: 0 + +.changelog + border: 1px solid #aaa + margin: 0 0.5em + padding: 1em + overflow-x: auto + height: 20em + +.locales li + display: inline + list-style-type: none + padding-right: 20px + white-space: nowrap + +pre, code + font-family: $source-code-font-family + +.newer, .last-version-notice + text-align: center + margin: 1em diff --git a/source/layouts/layout.html.haml b/source/layouts/layout.html.haml index c7ab1d4..6eac48e 100644 --- a/source/layouts/layout.html.haml +++ b/source/layouts/layout.html.haml @@ -1,8 +1,9 @@ // Variables -- latest_version= current_page.metadata[:page][:version] != $last_version +- latest_version = current_page.metadata[:page][:version] == $last_version - language_code = current_page.metadata[:page][:language] - versions = Dir.entries("source/#{language_code}") - %w[. ..] - current_version = current_page.metadata[:page][:version] +- newer_version_available = File.exists?("source/#{language_code}/#{$last_version}") !!! 5 %html @@ -29,13 +30,17 @@ %link{ rel: "stylesheet", href: "https://fonts.googleapis.com/css?family=Muli:400,700" } = stylesheet_link_tag '//fonts.googleapis.com/css?family=Source+Code+Pro:400,700' - = stylesheet_link_tag 'application' + - if latest_version + = stylesheet_link_tag 'application' + - else + = stylesheet_link_tag 'legacy' = javascript_include_tag 'all' - %body{ class: latest_version ? "latest" : "legacy" } + %body %article %header{ role: "banner" } - = image_tag "keep-a-changelog-mark.svg", width: 100, class: "mark" + - if latest_version + = image_tag "keep-a-changelog-mark.svg", width: 100, class: "mark" %nav.locales{ role: "navigation" } %select - $languages.each do |language| @@ -45,15 +50,19 @@ %option{ selected: selected, label: language.last[:name], value: language.first } .main{ role: "main" } - - if latest_version - + - if !latest_version - if versions.include?($last_version) - = link_to "Version #{$last_version}", "#{language_code}/#{$last_version}" + %p.newer + - if $languages[language_code][:new] + = "#{$languages[language_code][:new]}: " + - else + There is a newer version available: + = link_to "#{$languages[language_code][:name]} #{$last_version}", "/#{language_code}/#{$last_version}" - else - if $languages[language_code][:notice] %p.last-version-notice= $languages[language_code][:notice] - else - %p + %p.last-version-notice The latest version (#{$last_version}) is not yet available in this language but = link_to "you can read it in English", "/en/#{$last_version}"