Permalink
Browse files

Fix Issue #1 and #2

- update_examples.py自动检测图片与脚本之间的更新关系
- 生成缩略图,以加快首页加载速度
- 忽略生成的PS文件
  • Loading branch information...
1 parent 3c7d6ef commit b1d438b25333c0818b9c8c2ac4d89f0dc60a62a0 @seisman seisman committed Mar 27, 2016
Showing with 63 additions and 42 deletions.
  1. +2 −0 .gitignore
  2. +2 −0 _config.yml
  3. +1 −4 _includes/anim02.sh
  4. +1 −1 _includes/anim03.sh
  5. +0 −4 _includes/anim04.sh
  6. BIN anim01/thumbnail.anim01.gif
  7. +1 −4 anim02/anim02.sh
  8. BIN anim02/thumbnail.anim02.gif
  9. +1 −1 anim03/anim03.sh
  10. BIN anim03/thumbnail.anim03.gif
  11. +0 −4 anim04/anim04.sh
  12. BIN anim04/thumbnail.anim04.gif
  13. BIN ex001/thumbnail.ex001.png
  14. BIN ex002/thumbnail.ex002.png
  15. BIN ex003/thumbnail.ex003.png
  16. BIN ex004/thumbnail.ex004.png
  17. BIN ex005/thumbnail.ex005.png
  18. BIN ex006/thumbnail.ex006.png
  19. BIN ex007/thumbnail.ex007.png
  20. BIN ex008/thumbnail.ex008.png
  21. BIN ex009/thumbnail.ex009.png
  22. BIN ex010/thumbnail.ex010.png
  23. BIN ex011/thumbnail.ex011.png
  24. BIN ex012/thumbnail.ex012.png
  25. BIN ex013/thumbnail.ex013.png
  26. BIN ex014/thumbnail.ex014.png
  27. BIN ex015/thumbnail.ex015.png
  28. BIN ex016/thumbnail.ex016.png
  29. BIN ex017/thumbnail.ex017.png
  30. BIN ex018/thumbnail.ex018.png
  31. BIN ex019/thumbnail.ex019.png
  32. BIN ex020/thumbnail.ex020.png
  33. BIN ex021/thumbnail.ex021.png
  34. BIN ex022/thumbnail.ex022.png
  35. BIN ex023/thumbnail.ex023.png
  36. BIN ex024/thumbnail.ex024.png
  37. BIN ex025/thumbnail.ex025.png
  38. BIN ex026/thumbnail.ex026.png
  39. BIN ex027/thumbnail.ex027.png
  40. BIN ex028/thumbnail.ex028.png
  41. BIN ex029/thumbnail.ex029.png
  42. BIN ex030/thumbnail.ex030.png
  43. BIN ex031/thumbnail.ex031.png
  44. BIN ex032/thumbnail.ex032.png
  45. BIN ex033/thumbnail.ex033.png
  46. BIN ex034/thumbnail.ex034.png
  47. BIN ex035/thumbnail.ex035.png
  48. BIN ex036/thumbnail.ex036.png
  49. BIN ex037/thumbnail.ex037.png
  50. BIN ex038/thumbnail.ex038.png
  51. BIN ex039/thumbnail.ex039.png
  52. BIN ex040/thumbnail.ex040.png
  53. BIN ex041/thumbnail.ex041.png
  54. BIN ex042/thumbnail.ex042.png
  55. BIN ex043/thumbnail.ex043.png
  56. BIN ex044/thumbnail.ex044.png
  57. BIN ex045/thumbnail.ex045.png
  58. BIN ex046/thumbnail.ex046.png
  59. BIN ex047/thumbnail.ex047.png
  60. +1 −1 index.html
  61. +54 −23 update_examples.py
View
@@ -7,3 +7,5 @@ img/Thumbs.db
node_modules
.sass-cache
.ruby-version
+ex*/*.ps
+anim*/*.ps
View
@@ -14,3 +14,5 @@ sass:
exclude:
- README.md
- update_examples.py
+ - ex*/*.ps
+ - anim*/*.ps
View
@@ -33,10 +33,6 @@ while [ ${frame} -lt ${n_frames} ]; do
gmt psxy -Rus.nc -J -O -K -Sc0.8i -Gwhite -Wthin >> $$.ps <<< "256.25 35.6"
gmt psxy -Rus.nc -J -O -Sv0.1i+e -Gred -Wthick >> $$.ps <<< "256.25 35.6 ${dir} 0.37"
[[ ${frame} -eq 0 ]] && cp $$.ps ${ps}
- if [ $# -eq 0 ]; then
- gmt_cleanup .gmt
- gmt_abort "${0}: First frame plotted to ${name}.ps"
- fi
# RIP to TIFF at specified dpi
gmt psconvert -E${dpi} -Tt $$.ps
mv -f $$.tif $$/${file}.tif
@@ -48,3 +44,4 @@ convert -delay 10 -loop 0 $$/${name_}*.tif ${name}.gif
# 4. Clean up temporary files
gmt_cleanup .gmt
+rm gmt.*
View
@@ -45,5 +45,5 @@ while [ ${az} -lt 360 ]; do
frame=`gmt_set_framenext ${frame}`
done
convert -delay 10 -loop 0 +dither $$/${name_}*.tif ${name}.gif
-# 4. Clean up temporary files
gmt_cleanup .gmt
+rm gmt.*
View
@@ -41,10 +41,6 @@ function make_frame () {
${REGION} -O -K -W1p $$.path.d >> ${file}_$$.ps
gmt pstext -R0/${px}/0/${py} -Jx1i -F+f14p,Helvetica-Bold+jTL -O >> ${file}_$$.ps <<< "0 4.6 ${ID}"
[[ ${frame} -eq 0 ]] && cp ${file}_$$.ps ${ps}
- if [ $# -eq 0 ]; then
- gmt_cleanup .gmt
- gmt_abort "${0}: First frame plotted to ${name}.ps"
- fi
gmt psconvert ${file}_$$.ps -Tt -E${dpi}
mv ${file}_$$.tif $$/${file}.tif
rm -f ${file}_$$.ps
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -33,10 +33,6 @@ while [ ${frame} -lt ${n_frames} ]; do
gmt psxy -Rus.nc -J -O -K -Sc0.8i -Gwhite -Wthin >> $$.ps <<< "256.25 35.6"
gmt psxy -Rus.nc -J -O -Sv0.1i+e -Gred -Wthick >> $$.ps <<< "256.25 35.6 ${dir} 0.37"
[[ ${frame} -eq 0 ]] && cp $$.ps ${ps}
- if [ $# -eq 0 ]; then
- gmt_cleanup .gmt
- gmt_abort "${0}: First frame plotted to ${name}.ps"
- fi
# RIP to TIFF at specified dpi
gmt psconvert -E${dpi} -Tt $$.ps
mv -f $$.tif $$/${file}.tif
@@ -48,3 +44,4 @@ convert -delay 10 -loop 0 $$/${name_}*.tif ${name}.gif
# 4. Clean up temporary files
gmt_cleanup .gmt
+rm gmt.*
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -45,5 +45,5 @@ while [ ${az} -lt 360 ]; do
frame=`gmt_set_framenext ${frame}`
done
convert -delay 10 -loop 0 +dither $$/${name_}*.tif ${name}.gif
-# 4. Clean up temporary files
gmt_cleanup .gmt
+rm gmt.*
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -41,10 +41,6 @@ function make_frame () {
${REGION} -O -K -W1p $$.path.d >> ${file}_$$.ps
gmt pstext -R0/${px}/0/${py} -Jx1i -F+f14p,Helvetica-Bold+jTL -O >> ${file}_$$.ps <<< "0 4.6 ${ID}"
[[ ${frame} -eq 0 ]] && cp ${file}_$$.ps ${ps}
- if [ $# -eq 0 ]; then
- gmt_cleanup .gmt
- gmt_abort "${0}: First frame plotted to ${name}.ps"
- fi
gmt psconvert ${file}_$$.ps -Tt -E${dpi}
mv ${file}_$$.tif $$/${file}.tif
rm -f ${file}_$$.ps
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
View
@@ -12,7 +12,7 @@
{% for post in site.posts %}
<li>
<figure>
- <img src="{{ post.id }}/{{ post.figure }}" alt="img"/>
+ <img src="{{ post.id }}/thumbnail.{{ post.figure }}" alt="img"/>
<figcaption>
<h3><a href="{{ post.url }}">{{ post.title}}</a></h3>
<p>{{ post.description }}</p>
View
@@ -1,31 +1,62 @@
#!/usr/bin/env python
# -*- coding: utf8 -*-
+#
+# Update all examples
+#
-import os
-import glob
+from os import chdir, system, unlink
+from os.path import getmtime, exists
+from glob import glob
+from shutil import copyfile
-flag = 0
-for dir in glob.glob("ex*"):
+# exnnn
+for dir in glob("ex*"):
print(dir)
- os.chdir(dir)
- script = dir + ".sh"
- ps = dir + ".ps"
+ chdir(dir)
+
+ # bash script
+ script = glob(dir + ".sh")[0]
+ cmd = "bash " + script
+ # perl script
+ if not script:
+ script = glob(dir + ".pl")[0]
+ cmd = "perl " + script
+ # python script
+ if not script:
+ script = glob(dir + ".py")[0]
+ cmd = "python " + script
+
+ # PNG
png = dir + ".png"
- pdf = dir + ".pdf"
- if not (os.path.exists(png) and os.path.exists(pdf)):
- flag = 1
- else:
- script_time = os.path.getmtime(script)
- png_time = os.path.getmtime(png)
- pdf_time = os.path.getmtime(pdf)
- if (script_time>png_time or script_time>pdf_time):
- flag = 1
+ if (not exists(png) or getmtime(script) > getmtime(png)):
+ system(cmd)
+ ps = dir + ".ps"
+ system("gmt psconvert -A -P -E50 -Tg -Fthumbnail." + dir + ".png " + ps)
+ system("gmt psconvert -A -P -Tg " + ps)
+ copyfile(script, "../_includes/" + script)
+ chdir("..")
+
+# animxx
+for dir in glob("anim*"):
+ print(dir)
+ chdir(dir)
- if flag == 1:
- os.system("bash " + script)
- os.system("gmt psconvert -A -P -Tg " + ps)
- os.system("gmt psconvert -A -P -Tf " + ps)
- for file in glob.glob("*.ps"):
- os.unlink(file)
+ # bash script
+ script = glob(dir + ".sh")[0]
+ cmd = "bash " + script + " 1 "
+ # perl script
+ if not script:
+ script = glob(dir + ".pl")[0]
+ cmd = "perl " + script
+ # python script
+ if not script:
+ script = glob(dir + ".py")[0]
+ cmd = "python " + script
- os.chdir("..")
+ # PNG
+ gif = dir + ".gif"
+ if (not exists(gif) or getmtime(script) > getmtime(gif)):
+ system(cmd)
+ copyfile(gif, "thumbnail." + gif)
+ copyfile(script, "../_includes/" + script)
+ chdir("..")

0 comments on commit b1d438b

Please sign in to comment.