Skip to content

Commit

Permalink
Add working building script
Browse files Browse the repository at this point in the history
  • Loading branch information
yshalsager committed Sep 1, 2019
1 parent 49253c3 commit 6046740
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ steps:
exclude:
- pull_request
- name: Main
image: golang:stretch
image: golang:buster
environment:
GITHUB_TOKEN:
from_secret: GITHUB_TOKEN
commands:
- wget -q https://raw.githubusercontent.com/yshalsager/dorar-history-encyclopedia/master/generate.sh
- chmod +x generate.sh && ./generate.sh
- name: wait_for_debug
image: golang:stretch
image: golang:buster

environment:
# Amount of time to wait for debugging
Expand Down
21 changes: 16 additions & 5 deletions generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
#

# Install requirments
apt update > /dev/null && apt install -y python3 python3-pip pandoc > /dev/null
apt-get update > /dev/null
apt-get install -y python3 python3-pip > /dev/null
wget -q https://github.com/jgm/pandoc/releases/download/2.7.3/pandoc-2.7.3-1-amd64.deb
dpkg -i pandoc-2.7.3-1-amd64.deb
go get -u github.com/aktau/github-release
pip3 install -r requirements.txt > /dev/null

# Download
echo "Downloading latest data"
Expand All @@ -18,12 +22,19 @@ pandoc -s `ls -v out/*.md` -o dorar-history-encyclopedia.md -f gfm -t gfm
echo "Converting markdown to HTML"
pandoc -s `ls -v out/*.md` -o dorar-history-encyclopedia.html -f gfm -t html --metadata title="الموسوعة التاريخية - الدرر السنية" --metadata dir="rtl"
# convert HTML to epub
echo "convert HTML to epub"
echo "Converting HTML to epub"
pandoc -s dorar-history-encyclopedia.html -o dorar-history-encyclopedia.epub -f html -t epub --css=epub.css --metadata-file=epub.yml --toc --toc-depth=1

# Upload to GitHub
date = $(date +%d.%m.%Y)
$GOPATH/bin/github-release release -u yshalsager -r dorar-history-encyclopedia -t $date -n $date
date=$(date +%d.%m.%Y)
$GOPATH/bin/github-release release -u yshalsager -r dorar-history-encyclopedia -t $date -n $date -d $date
for i in dorar-history-encyclopedia.*; do
$GOPATH/bin/github-release upload -u yshalsager -r dorar-history-encyclopedia -t $date -n $i -f $i
done
done

# Add markdown files
git config --global user.email $DRONE_COMMIT_AUTHOR_EMAIL
git config --global user.name $DRONE_COMMIT_AUTHOR_NAME
git add out/*.md
git commit -m "[ci skip] Sync: $date"
git push -q https://$GITHUB_TOKEN@github.com/yshalsager/dorar-history-encyclopedia.git HEAD:master
7 changes: 4 additions & 3 deletions scraper.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python3.7

from bs4 import BeautifulSoup
from requests import get

Expand Down Expand Up @@ -30,9 +32,8 @@ def scraper(last: int):
def get_last_page():
return BeautifulSoup(
get(f'https://dorar.net/history/').content,
'html.parser').find(
'ul', {'class': 'pagination pagination-lg'}
).findAll('a')[-1]['href'].split('=')[1]
'html.parser').find('ul', {'class': 'pagination pagination-lg'}
).findAll('a')[-1]['href'].split('=')[1]


def main():
Expand Down

0 comments on commit 6046740

Please sign in to comment.