build.sh 2.1 KB
Newer Older
1 2
#!/bin/bash

3
# Removes the _site/.
4 5 6
echo "------------------------------------------------------------------------"
echo "Remove '_site/' directory.\n"
rm -rf _site/
7 8 9
# Rscript -e "library(rmarkdown); clean_site()"

# The root file.
10
# echo $PWD
11 12
THEROOT=$PWD
cd $THEROOT
13
echo "Root directory: $THEROOT."
14

15 16 17
echo "------------------------------------------------------------------------"
echo "Render Rnw files inside this directory."
echo "Files that will be rendered:\n"
18 19
# List of Rmd files.
RMDFILES=$(find . -name \*.Rmd -print)
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
echo "$RMDFILES" | tr " " "\n"

# # Runs rmarkdown::render() in each Rmd file down in the tree.
# for RMD in $RMDFILES; do
#     DIRNAME=`dirname "$RMD"`
#     RMDNAME=`basename "$RMD"`
#     echo $DIRNAME
#     cd $DIRNAME
#     if [ "$DIRNAME" = './slides' -o "$DIRNAME" = './tutorials' ]; then
#         echo "------------------------------------------------------------------------"
#         echo "Rendering $RMD in the $DIRNAME directory.\n"
#         Rscript -e "library(rmarkdown); render(\"$RMDNAME\")"
#     fi
#     cd $THEROOT
# done
35 36

# Renders the site.
37 38
echo "------------------------------------------------------------------------"
echo "Rendering the site.\n"
39 40 41 42 43
Rscript -e "library(rmarkdown); render_site()"

firefox _site/index.html

# Remove the Rmd files.
44 45
echo "------------------------------------------------------------------------"
echo "Removing source files (*.Rmd).\n"
46 47 48
rm -r --verbose _site/slides/*.Rmd
rm -r --verbose _site/tutorials/*.Rmd

49

50
# Tree of the directories.
51 52
echo "------------------------------------------------------------------------"
echo "Directory tree.\n"
53
tree -h -F _site/ -L 1
54 55 56
# tree -h -F _site/slides
# tree -h -F _site/scripts
# tree -h -F _site/tutorials
57 58

# Upload.
59 60
echo "------------------------------------------------------------------------"
echo "Uploading files to server.\n"
61 62 63 64
rsync -avzp \
      ./_site/ \
      --progress \
      --rsh="ssh -p$PATAXOP" "$PATAXO:~/public_html/ensino/ML/"
65 66

# Vist the homepage.
67 68
echo "------------------------------------------------------------------------"
echo "Visiting the webpage.\n"
69
firefox http://leg.ufpr.br/~walmes/ensino/ML/