Skip to content

Commit 29386e5

Browse files
committed
working on pdf book version
1 parent a27d37e commit 29386e5

File tree

4 files changed

+219
-5
lines changed

4 files changed

+219
-5
lines changed

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ run:
1010

1111

1212
bookbuild:
13-
pelican -t theme -s book_settings.py -o generated/book content
13+
cp -R content tempcontent
14+
python ./utilities/transform_book.py
15+
pelican -t theme -s book_settings.py -o generated/book tempcontent
1416
cp -R static-html/* generated/book/
1517
cp -R static/* generated/book/
1618
rm -rf generated/book/pages
19+
rm -rf tempcontent
1720

1821

1922
pdf: bookbuild
@@ -23,7 +26,6 @@ pdf: bookbuild
2326
cd generated/book; prince pdf-book.html -o full_stack_python.pdf
2427

2528

26-
2729
update:
2830
python update_s3.py
2931
rm -rf generated/current_site

content/pages/meta/00-change-log.markdown

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ on GitHub.
1717

1818
## 2018
1919
### April
20-
* New [Jupyter Notebook](/jupyter-notebook.html) resources.
20+
* A slew of new resources for the [Jupyter Notebook](/jupyter-notebook.html)
21+
page.
2122
* Reworking [web development](/web-development.html) page with new
2223
descriptions and resources.
2324
* Major updates to [Flask](/flask.html) resources, example code and

env_template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# fill in these values then copy this to .env, invoke as shell script
22
export S3_BUCKET_NAME='' # S3 bucket name
3-
export CURRENT_SITE_DIR='/generated/current_site' # existing site files
4-
export UPDATED_SITE_DIR='/generated/updated_site' # regenerated new site files
3+
export CURRENT_SITE_DIR='./generated/current_site' # existing site files
4+
export UPDATED_SITE_DIR='./generated/updated_site' # regenerated new site files

transform_book.py

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
import argparse
2+
import os
3+
from os.path import isdir, isfile
4+
5+
6+
BASE_DIR = './tempcontent/'
7+
BASE_FSP = "https://www.fullstackpython.com/"
8+
9+
links = {"/introduction.html":
10+
"../01-introduction/02-learning-programming.markdown",
11+
"/learning-programming.html":
12+
"../01-introduction/02-learning-programming.markdown",
13+
"/why-use-python.html":
14+
"../01-introduction/03-why-use-python.markdown",
15+
"/python-2-or-3.html":
16+
"../01-introduction/04-python-2-or-3.markdown",
17+
"/enterprise-python.html":
18+
"../01-introduction/05-enterprise-python.markdown",
19+
"/best-python-resources.html":
20+
"../01-introduction/11-best-python-resources.markdown",
21+
"/best-python-videos.html":
22+
"../01-introduction/12-best-python-videos.markdown",
23+
24+
"/development-environments.html":
25+
"../02-development-environments/01-development-environments.markdown",
26+
"/vim.html":
27+
"../02-development-environments/03-vim.markdown",
28+
"/emacs.html":
29+
"../02-development-environments/04-emacs.markdown",
30+
31+
"/python-programming-language.html":
32+
"../03-programming-language/01-programming-language.markdown",
33+
"/generators.html":
34+
"../03-programming-language/08-generators.markdown",
35+
"/comprehensions.html":
36+
"../03-programming-language/09-comprehensions.markdown",
37+
38+
"/web-development.html":
39+
"../04-web-development/01-web-development.markdown",
40+
"/web-frameworks.html":
41+
"../04-web-development/02-web-frameworks.markdown",
42+
"/django.html":
43+
"../04-web-development/03-django.markdown",
44+
"/flask.html":
45+
"../04-web-development/04-flask.markdown",
46+
"/bottle.html":
47+
"../04-web-development/05-bottle.markdown",
48+
"/pyramid.html":
49+
"../04-web-development/06-pyramid.markdown",
50+
"/morepath.html":
51+
"../04-web-development/07-morepath.markdown",
52+
"/other-web-frameworks.html":
53+
"../04-web-development/09-other-web-frameworks.markdown",
54+
"/web-design.html":
55+
"../04-web-development/10-web-design.markdown",
56+
"/cascading-style-sheets.html":
57+
"../04-web-development/11-css.markdown",
58+
"/javascript.html":
59+
"../04-web-development/12-javascript.markdown",
60+
"/websockets.html":
61+
"../04-web-development/13-websockets.markdown",
62+
"/template-engines.html":
63+
"../04-web-development/14-template-engines.markdown",
64+
"/web-application-security.html":
65+
"../04-web-development/15-web-app-security.markdown",
66+
"/static-site-generator.html":
67+
"../04-web-development/16-static-site-generator.markdown",
68+
"/jinja2.html":
69+
"../04-web-development/17-jinja2.markdown",
70+
71+
"/data.html":
72+
"../05-data/01-data.markdown",
73+
"/databases.html":
74+
"../05-data/02-databases.markdown",
75+
"/no-sql-datastore.html":
76+
"../05-data/03-nosql.markdown",
77+
"/object-relational-mappers-orms.html":
78+
"../05-data/04-object-relational-mappers.markdown",
79+
"/postgresql.html":
80+
"../05-data/05-postgresql.markdown",
81+
"/mysql.html":
82+
"../05-data/06-mysql.markdown",
83+
"/sqlite.html":
84+
"../05-data/07-sqlite.markdown",
85+
86+
"/application-programming-interfaces.html":
87+
"../06-web-apis/01-application-programming-interfaces.markdown",
88+
"/api-integration.html":
89+
"../06-web-apis/02-api-integration.markdown",
90+
"/api-creation.html":
91+
"../06-web-apis/03-api-creation.markdown",
92+
93+
"/deployment.html":
94+
"../07-web-app-deployment/01-deployment.markdown",
95+
"/servers.html":
96+
"../07-web-app-deployment/02-servers.markdown",
97+
"/platform-as-a-service.html":
98+
"../07-web-app-deployment/04-platform-as-a-service.markdown",
99+
"/operating-systems.html":
100+
"../07-web-app-deployment/05-operating-systems.markdown",
101+
"/web-servers.html":
102+
"../07-web-app-deployment/06-web-servers.markdown",
103+
"/wsgi-servers.html":
104+
"../07-web-app-deployment/07-wsgi-servers.markdown",
105+
"/source-control.html":
106+
"../07-web-app-deployment/08-source-control.markdown",
107+
"/application-dependencies.html":
108+
"../07-web-app-deployment/09-app-dependencies.markdown",
109+
"/static-content.html":
110+
"../07-web-app-deployment/10-static-content.markdown",
111+
"/task-queues.html":
112+
"../07-web-app-deployment/11-task-queues.markdown",
113+
"/configuration-management.html":
114+
"../07-web-app-deployment/12-configuration-management.markdown",
115+
"/continuous-integration.html":
116+
"../07-web-app-deployment/13-continuous-integration.markdown",
117+
"/logging.html":
118+
"../07-web-app-deployment/14-logging.markdown",
119+
"/monitoring.html":
120+
"../07-web-app-deployment/15-monitoring.markdown",
121+
"/web-analytics.html":
122+
"../07-web-app-deployment/16-web-analytics.markdown",
123+
"/docker.html":
124+
"../07-web-app-deployment/17-docker.markdown",
125+
"/caching.html":
126+
"../07-web-app-deployment/18-caching.markdown",
127+
"/microservices.html":
128+
"../07-web-app-deployment/19-microservices.markdown",
129+
"/devops.html":
130+
"../07-web-app-deployment/20-devops.markdown",
131+
"/nginx.html":
132+
"../07-web-app-deployment/21-nginx.markdown",
133+
"/apache-http-server.html":
134+
"../07-web-app-deployment/22-apache-http-server.markdown",
135+
"/caddy.html":
136+
"../07-web-app-deployment/23-caddy.markdown",
137+
"/green-unicorn-gunicorn.html":
138+
"../07-web-app-deployment/24-gunicorn.markdown",
139+
140+
141+
"/testing.html":
142+
"../08-testing/01-testing.markdown",
143+
"/unit-testing.html":
144+
"../08-testing/02-unit-testing.markdown",
145+
"/integration-testing.html":
146+
"../08-testing/03-integration-testing.markdown",
147+
"/code-metrics.html":
148+
"../08-testing/05-code-metrics.markdown",
149+
"/debugging.html":
150+
"../08-testing/08-debugging.markdown",
151+
152+
"/what-full-stack-means.html":
153+
"../13-meta/01-what-full-stack-means.markdown",
154+
"/change-log.html":
155+
"../13-meta/02-change-log.markdown",
156+
"/future-directions.html":
157+
"../13-meta/03-future-directions.markdown",
158+
"/about-author.html":
159+
"../13-meta/04-about-author.markdown",
160+
161+
"/email.html":
162+
BASE_FSP + "email.html",
163+
"<a href=\"/full-stack-python-map.pdf\" target=\"_blank\" style=\"border: none;\"><img src=\"/img/full-stack-python-map.png\" width=\"100%\" alt=\"Full Stack Python site map.\" class=\"technical-diagram\" /></a>":
164+
"<img src=\"/img/full-stack-python-map.png\" alt=\"Full Stack Python deployment map.\" />",
165+
166+
"/blog.html":
167+
BASE_FSP + "blog.html",
168+
"/blog/python-3-bottle-gunicorn-ubuntu-1604-xenial-xerus.html":
169+
BASE_FSP + "blog/python-3-bottle-gunicorn-ubuntu-1604-xenial-xerus.html",
170+
"/blog/install-redis-use-python-3-ubuntu-1604.html":
171+
BASE_FSP + "blog/install-redis-use-python-3-ubuntu-1604.html",
172+
"/blog/postgresql-python-3-psycopg2-ubuntu-1604.html":
173+
BASE_FSP + "blog/postgresql-python-3-psycopg2-ubuntu-1604.html",
174+
"/blog/python-3-flask-green-unicorn-ubuntu-1604-xenial-xerus.html":
175+
BASE_FSP + "blog/python-3-flask-green-unicorn-ubuntu-1604-xenial-xerus.html",
176+
"/blog/python-3-django-gunicorn-ubuntu-1604-xenial-xerus.html":
177+
BASE_FSP + "blog/python-3-django-gunicorn-ubuntu-1604-xenial-xerus.html",
178+
}
179+
180+
181+
def transform(output_format='pdf'):
182+
dirs = os.listdir(BASE_DIR)
183+
print os.listdir(BASE_DIR)
184+
for d in dirs:
185+
if isdir(BASE_DIR + d):
186+
# modify all markdown files in directory
187+
files = os.listdir(BASE_DIR + d)
188+
for f in files:
189+
with open(BASE_DIR + d + '/' + f, 'r') as read_f:
190+
all_lines = read_f.readlines()
191+
192+
with open(BASE_DIR + d + '/' + f, 'w') as write_f:
193+
for l in all_lines[8:]:
194+
for k, v in links.iteritems():
195+
l = l.replace(k, v)
196+
if "<div class=\"well see-also\">" in l:
197+
write_f.write("")
198+
else:
199+
write_f.write(l)
200+
print 'prepared file ' + str(d) + '/' + str(f)
201+
202+
203+
if __name__ == '__main__':
204+
parser = argparse.ArgumentParser()
205+
parser.add_argument("o")
206+
args = parser.parse_args()
207+
208+
if args.o == 'pdf':
209+
transform('pdf')
210+
elif args.o == 'epub':
211+
transform('epub')

0 commit comments

Comments
 (0)