-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add existing server scripts * Update thumbnail script to update any time the PDF is newer than the thumbnail
- Loading branch information
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Requires $PREVIEW_DIR to be set. | ||
#!/bin/bash | ||
|
||
# Builds thumbnails for files. There are two use cases: | ||
# 1. If no arguments are supplied, will do so for all Anthology files. | ||
# | ||
# Example: | ||
# | ||
# build_thumbnails.sh | ||
# | ||
# 2. If two arguments are supplied, will read the first file and write | ||
# to the second. | ||
# | ||
# Example: | ||
# | ||
# build_thumbnails ~/anthology-files/pdf/W/W19/W19-5605.pdf \ | ||
# ~/anthology-files/thumb/W/W19/W19-5606-thumb.pdf | ||
# | ||
# The first use case recurses to the second. | ||
|
||
# The base directory of Anthology object files (contains pdf/ and thumb/) | ||
ANTHOLOGYFILES=$HOME/anthology-files | ||
|
||
# Where to write thumbnails | ||
THUMBDIR=${ANTHOLOGYFILES}/thumb | ||
|
||
# Thumbnail dimensions | ||
DIM=600 | ||
|
||
if [[ -z $2 ]]; then | ||
[[ ! -e $THUMBDIR ]] && mkdir -p $THUMBDIR | ||
|
||
inputdir=${1:-$ANTHOLOGYFILES/pdf/} | ||
echo "Looking for PDFs in $inputdir..." | ||
for pdf in $(find $inputdir -type f -name '*.pdf'); do | ||
outfile=$THUMBDIR/$(basename $pdf .pdf).jpg | ||
# update if outfile doesn't exist or has an older timestamp | ||
if [[ ! -e $outfile || $pdf -nt $outfile ]]; then | ||
echo "$pdf -> $outfile" | ||
bash $0 $pdf $outfile | ||
fi | ||
done | ||
else | ||
pdffile=$1 | ||
outfile=$2 | ||
|
||
cmd="convert $pdffile[0] -background white -flatten -resize x${DIM}^ -gravity North -crop ${DIM}x${DIM}+0+10 -colorspace Gray $outfile" | ||
# echo $cmd | ||
$cmd | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
# Removes previews of branches that have been deleted on Github. | ||
|
||
export PREVIEW_DIR="/var/www/preview.aclanthology.org" | ||
|
||
set -u | ||
|
||
if [[ -d $PREVIEW_DIR ]]; then | ||
cd $PREVIEW_DIR | ||
for branch in *; do | ||
if ! curl -s -o /dev/null -f https://github.com/acl-org/acl-anthology/tree/$branch; then | ||
echo "* Removing Anthology preview $branch" | ||
rm -rf "./$branch" | ||
fi | ||
done | ||
fi |