Skip to content
This repository was archived by the owner on Nov 28, 2022. It is now read-only.

Commit bd885e6

Browse files
authored
Add last update date on docs page. (#343)
Signed-off-by: tiaoyuw <tiaoyuw@ca.ibm.com>
1 parent 47edccf commit bd885e6

File tree

7 files changed

+158
-3
lines changed

7 files changed

+158
-3
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
/.DS_Store
22
/.settings
33
/.project
4+
/_tmp
5+
/_jekyllHome
6+
/vendor
7+
/docs/.jekyll-cache

build.sh

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,49 @@ RED='\033[0;31m'
44
NC='\033[0m' # No Color
55
GREEN='\033[0;32m'
66

7+
# Fix the timestamp
8+
# https://stackoverflow.com/questions/21735435/git-clone-changes-file-modification-time
9+
# https://gist.github.com/HackingGate/9e8169c7645b074b2f40c959ca20d738
710

11+
echo "Fixing file timestamp..."
12+
13+
OS=${OS:-`uname`}
14+
15+
if [ "$OS" = 'Darwin' ]; then
16+
get_touch_time() {
17+
date -r ${unixtime} +'%Y%m%d%H%M.%S'
18+
}
19+
else
20+
# default Linux
21+
get_touch_time() {
22+
date -d @${unixtime} +'%Y%m%d%H%M.%S'
23+
}
24+
fi
25+
26+
git ls-tree -r --name-only HEAD | while read filename; do
27+
unixtime=$(git log -1 --format="%at" -- "${filename}")
28+
touchtime=$(get_touch_time)
29+
touch -t ${touchtime} "${filename}"
30+
done
31+
32+
mkdir -p _tmp
33+
mkdir -p _jekyllHome
834
# Compile the files
935
docker run --rm -it \
1036
--volume="$PWD/docs:/srv/jekyll" \
37+
--volume="$PWD/_tmp:/tmp" \
38+
--volume="$PWD/_jekyllHome:/home/jekyll" \
1139
--volume="$PWD/vendor/bundle:/usr/local/bundle" \
1240
-p 4321:4321 jekyll/jekyll:3.8.5 \
13-
jekyll build
41+
/bin/bash -c "bundle install && jekyll build"
42+
1443

1544
# Launch the site in apache
1645

1746
docker run -dit --name my-apache-app -p 8765:80 -v "$PWD/docs/_site":/usr/local/apache2/htdocs/codewind/ httpd:2.4
1847

1948
# Check link
20-
docker run --network="host" --rm -it -u $(id -u):$(id -g) linkchecker/linkchecker --verbose http://localhost:8765/codewind/
49+
docker run --network="host" --rm -it -u $(id -u):$(id -g) linkchecker/linkchecker http://localhost:8765/codewind/
2150
rc=$?
2251

2352
# Shut down apache

docs/Gemfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
source 'https://rubygems.org'
2+
3+
gem 'jekyll'
4+
gem 'minima'
5+
6+
group :jekyll_plugins do
7+
gem "jekyll-last-modified-at"
8+
end

docs/Gemfile.lock

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
addressable (2.7.0)
5+
public_suffix (>= 2.0.2, < 5.0)
6+
colorator (1.1.0)
7+
concurrent-ruby (1.1.5)
8+
em-websocket (0.5.1)
9+
eventmachine (>= 0.12.9)
10+
http_parser.rb (~> 0.6.0)
11+
eventmachine (1.2.7)
12+
ffi (1.12.2)
13+
forwardable-extended (2.6.0)
14+
http_parser.rb (0.6.0)
15+
i18n (1.8.2)
16+
concurrent-ruby (~> 1.0)
17+
jekyll (4.0.0)
18+
addressable (~> 2.4)
19+
colorator (~> 1.0)
20+
em-websocket (~> 0.5)
21+
i18n (>= 0.9.5, < 2)
22+
jekyll-sass-converter (~> 2.0)
23+
jekyll-watch (~> 2.0)
24+
kramdown (~> 2.1)
25+
kramdown-parser-gfm (~> 1.0)
26+
liquid (~> 4.0)
27+
mercenary (~> 0.3.3)
28+
pathutil (~> 0.9)
29+
rouge (~> 3.0)
30+
safe_yaml (~> 1.0)
31+
terminal-table (~> 1.8)
32+
jekyll-feed (0.13.0)
33+
jekyll (>= 3.7, < 5.0)
34+
jekyll-last-modified-at (1.2.1)
35+
jekyll (>= 3.7, < 5.0)
36+
posix-spawn (~> 0.3.9)
37+
jekyll-sass-converter (2.0.1)
38+
sassc (> 2.0.1, < 3.0)
39+
jekyll-seo-tag (2.6.1)
40+
jekyll (>= 3.3, < 5.0)
41+
jekyll-watch (2.2.1)
42+
listen (~> 3.0)
43+
kramdown (2.1.0)
44+
kramdown-parser-gfm (1.1.0)
45+
kramdown (~> 2.0)
46+
liquid (4.0.3)
47+
listen (3.2.1)
48+
rb-fsevent (~> 0.10, >= 0.10.3)
49+
rb-inotify (~> 0.9, >= 0.9.10)
50+
mercenary (0.3.6)
51+
minima (2.5.1)
52+
jekyll (>= 3.5, < 5.0)
53+
jekyll-feed (~> 0.9)
54+
jekyll-seo-tag (~> 2.1)
55+
pathutil (0.16.2)
56+
forwardable-extended (~> 2.6)
57+
posix-spawn (0.3.13)
58+
public_suffix (4.0.3)
59+
rb-fsevent (0.10.3)
60+
rb-inotify (0.10.1)
61+
ffi (~> 1.0)
62+
rouge (3.15.0)
63+
safe_yaml (1.0.5)
64+
sassc (2.2.1)
65+
ffi (~> 1.9)
66+
terminal-table (1.8.0)
67+
unicode-display_width (~> 1.1, >= 1.1.1)
68+
unicode-display_width (1.6.1)
69+
70+
PLATFORMS
71+
ruby
72+
73+
DEPENDENCIES
74+
jekyll
75+
jekyll-last-modified-at
76+
minima
77+
78+
BUNDLED WITH
79+
2.0.2

docs/_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ markdown: kramdown
1212
theme: minima
1313
plugins:
1414
- jekyll-feed
15+
- jekyll-last-modified-at
1516
exclude: [node_modules]
1617
collections:
1718
documentations:

docs/_layouts/docs.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@
112112
<div role="main">{{ content }}</div>
113113
</div>
114114

115+
{% if page.permalink != "gettingstarted" %}
116+
<div class="py-5 px-5 text-right">
117+
Last update: {{ page.last_modified_at| date: '%b %d, %Y'}}
118+
</div>
119+
{% endif %}
120+
115121
</div>
116122

117123
</div>

serve.sh

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,34 @@
11
#!/bin/sh
2+
# Fix the timestamp
3+
# https://stackoverflow.com/questions/21735435/git-clone-changes-file-modification-time
4+
# https://gist.github.com/HackingGate/9e8169c7645b074b2f40c959ca20d738
5+
6+
echo "Fixing file timestamp..."
7+
8+
OS=${OS:-`uname`}
9+
10+
if [ "$OS" = 'Darwin' ]; then
11+
get_touch_time() {
12+
date -r ${unixtime} +'%Y%m%d%H%M.%S'
13+
}
14+
else
15+
# default Linux
16+
get_touch_time() {
17+
date -d @${unixtime} +'%Y%m%d%H%M.%S'
18+
}
19+
fi
20+
21+
git ls-tree -r --name-only HEAD | while read filename; do
22+
unixtime=$(git log -1 --format="%at" -- "${filename}")
23+
touchtime=$(get_touch_time)
24+
touch -t ${touchtime} "${filename}"
25+
done
26+
mkdir -p _tmp
27+
mkdir -p _jekyllHome
228
docker run --rm -it \
329
--volume="$PWD/docs:/srv/jekyll" \
30+
--volume="$PWD/_tmp:/tmp" \
31+
--volume="$PWD/_jekyllHome:/home/jekyll" \
432
--volume="$PWD/vendor/bundle:/usr/local/bundle" \
533
-p 4321:4321 jekyll/jekyll:3.8.5 \
6-
jekyll serve --port 4321 --host 0.0.0.0
34+
/bin/bash -c "bundle install && jekyll serve --trace --port 4321 --host 0.0.0.0"

0 commit comments

Comments
 (0)