aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <msabate@suse.com>2018-02-19 17:02:50 +0100
committerMiquel Sabaté Solà <msabate@suse.com>2018-02-19 17:02:50 +0100
commit77cd36c158624808e657e5dbb5ec8bc026fafa55 (patch)
tree4141e83d8cd37e7403ebec66bd1f3dcf11a4b8c7
parent3c62a936378e490e99c2ac8955797464216b1691 (diff)
downloadjo.mssola.com-77cd36c158624808e657e5dbb5ec8bc026fafa55.tar.gz
jo.mssola.com-77cd36c158624808e657e5dbb5ec8bc026fafa55.zip
Sorted out how to properly deploy
Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
-rw-r--r--.gitignore1
-rw-r--r--.rubocop.yml55
-rw-r--r--Gemfile28
-rw-r--r--Gemfile.lock46
-rw-r--r--Rakefile38
-rw-r--r--_i18n/ca.yml2
-rw-r--r--_i18n/ca/_posts/2018-02-17-llegint-capital.html1
-rw-r--r--_i18n/en.yml2
-rw-r--r--_includes/header.html12
-rw-r--r--org/ca/_posts/2018-02-17-llegint-capital.org1
-rwxr-xr-xscript/build.sh35
-rw-r--r--script/post-receive43
12 files changed, 258 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index 45c1505..0d96cc9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
_site
.sass-cache
.jekyll-metadata
+tmp
diff --git a/.rubocop.yml b/.rubocop.yml
new file mode 100644
index 0000000..edc5960
--- /dev/null
+++ b/.rubocop.yml
@@ -0,0 +1,55 @@
+AllCops:
+ TargetRubyVersion: 2.5
+
+ DisplayCopNames: true
+ DisplayStyleGuide: false
+
+ Exclude:
+ - './_site/**/*'
+
+#
+# Layout
+#
+
+# This is a remnant of old SUSE-style alignment for hashes, The table format
+# looks more human readable.
+Layout/AlignHash:
+ EnforcedHashRocketStyle: table
+ EnforcedColonStyle: table
+
+#
+# Metrics
+#
+
+# The default is just too small.
+Metrics/AbcSize:
+ Max: 30
+
+# The default is just too small. A limit of 100 looks reasonable and many other
+# projects (including inside of SUSE) are also using this value.
+Metrics/LineLength:
+ Max: 100
+
+Metrics/MethodLength:
+ Max: 20
+
+#
+# Style
+#
+
+# This forces us to create a new object for no real reason.
+Style/MultipleComparison:
+ Enabled: false
+
+# This is a common SUSE configuration value: the performance difference between
+# single and double quotes is no longer there, and so it's better to be
+# consistent and force only double quotes.
+Style/StringLiterals:
+ EnforcedStyle: double_quotes
+
+# Same as Style/StringLiterals.
+Style/StringLiteralsInInterpolation:
+ EnforcedStyle: double_quotes
+
+Style/AsciiComments:
+ Enabled: false
diff --git a/Gemfile b/Gemfile
index 8ff0e7d..603235a 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,8 +1,28 @@
-source 'https://rubygems.org'
+# frozen_string_literal: true
-gem 'jekyll', '~> 3.7.2'
-gem 'sass'
+# Copyright (C) 2018 Miquel Sabaté Solà <mikisabate@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+source "https://rubygems.org"
+
+gem "html-proofer"
+gem "jekyll", "~> 3.7.2"
+gem "rake"
+gem "rubocop"
+gem "sass"
group :jekyll_plugins do
- gem 'jekyll-multiple-languages-plugin'
+ gem "jekyll-multiple-languages-plugin"
end
diff --git a/Gemfile.lock b/Gemfile.lock
index 628c73a..9b1f40e 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,16 +1,34 @@
GEM
remote: https://rubygems.org/
specs:
+ activesupport (5.1.5)
+ concurrent-ruby (~> 1.0, >= 1.0.2)
+ i18n (~> 0.7)
+ minitest (~> 5.1)
+ tzinfo (~> 1.1)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
+ ast (2.4.0)
colorator (1.1.0)
+ colorize (0.8.1)
concurrent-ruby (1.0.5)
em-websocket (0.5.1)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0.6.0)
+ ethon (0.11.0)
+ ffi (>= 1.3.0)
eventmachine (1.2.5)
ffi (1.9.21)
forwardable-extended (2.6.0)
+ html-proofer (3.8.0)
+ activesupport (>= 4.2, < 6.0)
+ addressable (~> 2.3)
+ colorize (~> 0.8)
+ mercenary (~> 0.3.2)
+ nokogiri (~> 1.8.1)
+ parallel (~> 1.3)
+ typhoeus (~> 1.3)
+ yell (~> 2.0)
http_parser.rb (0.6.0)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
@@ -40,13 +58,31 @@ GEM
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
mercenary (0.3.6)
+ mini_portile2 (2.3.0)
+ minitest (5.11.3)
+ nokogiri (1.8.2)
+ mini_portile2 (~> 2.3.0)
+ parallel (1.12.1)
+ parser (2.4.0.2)
+ ast (~> 2.3)
pathutil (0.16.1)
forwardable-extended (~> 2.6)
+ powerpack (0.1.1)
public_suffix (3.0.2)
+ rainbow (3.0.0)
+ rake (12.3.0)
rb-fsevent (0.10.2)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
rouge (3.1.1)
+ rubocop (0.52.1)
+ parallel (~> 1.10)
+ parser (>= 2.4.0.2, < 3.0)
+ powerpack (~> 0.1)
+ rainbow (>= 2.2.2, < 4.0)
+ ruby-progressbar (~> 1.7)
+ unicode-display_width (~> 1.0, >= 1.0.1)
+ ruby-progressbar (1.9.0)
ruby_dep (1.5.0)
safe_yaml (1.0.4)
sass (3.5.5)
@@ -54,13 +90,23 @@ GEM
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
+ thread_safe (0.3.6)
+ typhoeus (1.3.0)
+ ethon (>= 0.9.0)
+ tzinfo (1.2.5)
+ thread_safe (~> 0.1)
+ unicode-display_width (1.3.0)
+ yell (2.0.7)
PLATFORMS
ruby
DEPENDENCIES
+ html-proofer
jekyll (~> 3.7.2)
jekyll-multiple-languages-plugin
+ rake
+ rubocop
sass
BUNDLED WITH
diff --git a/Rakefile b/Rakefile
new file mode 100644
index 0000000..1fb29c0
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+# Copyright (C) 2018 Miquel Sabaté Solà <mikisabate@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+abort("Please run this using `bundle exec rake`") unless ENV["BUNDLE_BIN_PATH"]
+require "html-proofer"
+
+desc "Test the website"
+task :test do
+ options = {
+ check_sri: true,
+ check_html: true,
+ check_img_http: true,
+ check_opengraph: true,
+ typhoeus: {
+ timeout: 120
+ },
+ cache: {
+ timeframe: "6w"
+ }
+ }
+ HTMLProofer.check_directory("./_site", options).run
+end
+
+task default: [:test]
diff --git a/_i18n/ca.yml b/_i18n/ca.yml
index 559812f..6298312 100644
--- a/_i18n/ca.yml
+++ b/_i18n/ca.yml
@@ -21,6 +21,8 @@ blog:
posted_on: "Escrit"
read: "Llegir"
more: "més"
+ no_english_post: "Aquesta entrada no està disponible en anglès"
+ no_catalan_post: "Aquesta entrada no està disponible en català"
intro: >-
Aquesta és la pàgina que mostra les entrades en català del meu blog. Totes
les opinions exposades aquí són únicament meves a no ser que indiqui el
diff --git a/_i18n/ca/_posts/2018-02-17-llegint-capital.html b/_i18n/ca/_posts/2018-02-17-llegint-capital.html
index d68071b..d65c38e 100644
--- a/_i18n/ca/_posts/2018-02-17-llegint-capital.html
+++ b/_i18n/ca/_posts/2018-02-17-llegint-capital.html
@@ -3,6 +3,7 @@ layout: post
title: posts.first
subtitle: Una mirada o quelcom similar
lang: ca
+english_available: false
---
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean imperdiet
diff --git a/_i18n/en.yml b/_i18n/en.yml
index cb0df2f..04259ea 100644
--- a/_i18n/en.yml
+++ b/_i18n/en.yml
@@ -21,6 +21,8 @@ blog:
posted_on: "Posted on"
read: "Read"
more: "more"
+ no_english_post: "This entry is not available in english"
+ no_catalan_post: "This entry is not available in catalan"
intro: >-
This is the page that aggregates the english blog posts. All of the opinions
stated here are solely my own (unless stated otherwise). Last but not least,
diff --git a/_includes/header.html b/_includes/header.html
index 980d8cc..b7296b6 100644
--- a/_includes/header.html
+++ b/_includes/header.html
@@ -5,9 +5,17 @@
</div>
<nav class="site-nav">
{% if site.lang == "ca" %}
- <a href="/en{{ page.url }}" >{% t global.english %}</a>
+ {% if page.layout == "post" and page.english_available == false %}
+ <span class="no-lang" title="{% t blog.no_english_post %}">{% t global.english %}</span>
+ {% else %}
+ <a href="/en{{ page.url }}" >{% t global.english %}</a>
+ {% endif %}
{% elsif site.lang == "en" %}
- <a href="{{ page.url }}" >{% t global.catalan %}</a>
+ {% if page.layout == "post" and page.catalan_available == false %}
+ <span class="no-lang" title="{% t blog.no_catalan_post %}">{% t global.catalan %}</span>
+ {% else %}
+ <a href="{{ page.url }}" >{% t global.catalan %}</a>
+ {% endif %}
{% endif %}
<a title="{% t titles.blog %}" href="{% tl blog %}">{% t titles.blog %}</a>
diff --git a/org/ca/_posts/2018-02-17-llegint-capital.org b/org/ca/_posts/2018-02-17-llegint-capital.org
index 9444a2e..720c8a0 100644
--- a/org/ca/_posts/2018-02-17-llegint-capital.org
+++ b/org/ca/_posts/2018-02-17-llegint-capital.org
@@ -6,6 +6,7 @@ layout: post
title: posts.first
subtitle: Una mirada o quelcom similar
lang: ca
+english_available: false
---
#+END_HTML
# Local variables:
diff --git a/script/build.sh b/script/build.sh
new file mode 100755
index 0000000..7d24c09
--- /dev/null
+++ b/script/build.sh
@@ -0,0 +1,35 @@
+#!/usr/bin/env bash
+# Copyright (C) 2018 Miquel Sabaté Solà <mikisabate@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+set -ex
+
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
+pushd $DIR
+
+# The build source and destination directories. This is done this way so we
+# can re-use this script when deploying.
+: ${BUILD_SOURCE:=.}
+: ${BUILD_DEST:=./_site}
+
+# Clean up previous build.
+rm -rf $BUILD_DEST
+
+# Build && test.
+bundle exec jekyll build -s $BUILD_SOURCE -d $BUILD_DEST
+bundle exec rubocop
+bundle exec rake
+
+echo "Jekyll has built your application in '$BUILD_DEST'"
diff --git a/script/post-receive b/script/post-receive
new file mode 100644
index 0000000..3f4f8ee
--- /dev/null
+++ b/script/post-receive
@@ -0,0 +1,43 @@
+#!/usr/bin/env bash
+# Copyright (C) 2018 Miquel Sabaté Solà <mikisabate@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+#
+# This script is based on the one from the documentation of Jekyll.
+#
+
+NAME=jo
+GIT_REPO=$HOME/$NAME.git
+TARGET_BRANCH=master
+
+# Exported so it's picked by the `script/build.sh` script.
+export BUILD_SOURCE=$HOME/tmp/$NAME
+export BUILD_DEST=/srv/$NAME/www
+
+while read oldrev newrev refname
+do
+ branch=$(git rev-parse --symbolic --abbrev-ref $refname)
+ if [ -n "$branch" ] && [ "$TARGET_BRANCH" == "$branch" ]; then
+ # Re-generate git repository in a temporary directory.
+ rm -Rf $TMP_GIT_CLONE
+ git clone $GIT_REPO $BUILD_SOURCE
+
+ # Build site
+ chmod +x $BUILD_SOURCE/script/build.sh
+ BUNDLE_GEMFILE=$BUILD_SOURCE/Gemfile bundle install
+ BUNDLE_GEMFILE=$BUILD_SOURCE/Gemfile $BUILD_SOURCE/script/build.sh
+ rm -Rf $BUILD_SOURCE
+ fi
+done