Skip to content

Commit 1ea3cc1

Browse files
authored
Merge pull request #189 from openzim/issue_145
Migrate to new PG server + remove inline JS + remove JS deps from repo
2 parents 91e2744 + c2a7850 commit 1ea3cc1

13 files changed

+89
-17463
lines changed

Dockerfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.11.1-bullseye
1+
FROM python:3.11.4-bookworm
22

33
# Install necessary packages
44
RUN apt-get update -y && \
@@ -7,13 +7,14 @@ RUN apt-get update -y && \
77
rm -rf /var/lib/apt/lists/*
88

99
# Install gutenberg (from source)
10-
RUN locale-gen "en_US.UTF-8"
10+
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen "en_US.UTF-8"
1111
COPY requirements.pip /src/
1212
RUN python3 -m pip install -r /src/requirements.pip
1313
COPY LICENSE /src/
1414
COPY pypi-readme.rst /src/
1515
COPY MANIFEST.in /src/
1616
COPY setup.py /src/
17+
COPY get_js_deps.sh /src/
1718
COPY gutenberg2zim /src/
1819
COPY gutenbergtozim /src/gutenbergtozim
1920
WORKDIR /src/

get_js_deps.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
###
6+
# download JS dependencies and place them in our templates/assets folder
7+
# then launch our ogv.js script to fix dynamic loading links
8+
###
9+
10+
if ! command -v curl > /dev/null; then
11+
echo "you need curl."
12+
exit 1
13+
fi
14+
15+
# Absolute path this script is in.
16+
SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )"
17+
ASSETS_PATH="${SCRIPT_PATH}/gutenbergtozim/templates"
18+
19+
echo "About to download JS assets to ${ASSETS_PATH}"
20+
21+
echo "getting datatables.min.js"
22+
curl -L -O https://cdn.datatables.net/v/dt/dt-1.13.6/r-2.5.0/datatables.min.js
23+
rm -rf $ASSETS_PATH/datatables/datatables.min.js
24+
mv datatables.min.js $ASSETS_PATH/datatables/datatables.min.js
25+
26+
echo "getting datatables.min.css"
27+
curl -L -O https://cdn.datatables.net/v/dt/dt-1.13.6/r-2.5.0/datatables.min.css
28+
rm -rf $ASSETS_PATH/datatables/datatables.min.css
29+
mv datatables.min.css $ASSETS_PATH/datatables/datatables.min.css

gutenbergtozim/download.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
get_etag_from_url,
2828
)
2929

30-
IMAGE_BASE = "http://dante.pglaf.org/cache/epub/"
30+
IMAGE_BASE = "http://aleph.pglaf.org/cache/epub/"
3131

3232
# for development
3333
# def resource_exists(url):

gutenbergtozim/templates/base.html

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
55
<title {% if show_books %} data-l10n-id="top-title"{% endif %}>{% block title %}Project Gutenberg Library{% endblock %}</title>
66
<meta name="description" content="Project Gutenberg Ebooks." />
7+
<meta name="show_books" content="{% if show_books %}true{% else %}false{% endif %}" />
8+
<meta name="bookshelf_home" content="{% if bookshelf_home %}true{% else %}false{% endif %}" />
9+
<meta name="bookshelf" content="{% if bookshelf is defined %}{{ bookshelf }}{% endif %}" />
710
<link rel="shortcut icon" href="favicon.ico" />
811
<link rel="stylesheet" href="css/pure-min.css" type="text/css" />
912
<link rel="stylesheet" href="css/grids-responsive-min.css" type="text/css" />
@@ -17,7 +20,7 @@
1720
<script type="text/javascript" src="jquery/jquery.cookie.js"></script>
1821
<script type="text/javascript" src="jquery/jquery.persist.js"></script>
1922
<script src="jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
20-
<script type="text/javascript" charset="utf8" src="datatables/datatables.js"></script>
23+
<script type="text/javascript" charset="utf8" src="datatables/datatables.min.js"></script>
2124
<script type="application/l10n">{{ l10n_strings }}</script>
2225
<script src="js/l10n.js" type="text/javascript"></script>
2326
<script src="js/tools.js" type="text/javascript"></script>
@@ -26,7 +29,7 @@
2629
<script src="other_languages.js" type="text/javascript"></script>
2730
</head>
2831

29-
<body onload="init(); {% if show_books %} showBooks(); {% else %} populateFilters(); {% endif %} {%if bookshelf_home %} showBookshelfSearchResults(''); {%endif%} {%if bookshelf is defined%} showBookshelf(`{{ bookshelf }} `); {%endif%}" class="pure-skin-gutenberg {%if bookshelf_home%}bookshelf_home{%endif%} {%if individual_book_shelf%}individual_book_shelf{%endif%} {% if not show_books %}cover{% else %}home{% endif %}">
32+
<body class="pure-skin-gutenberg {%if bookshelf_home%}bookshelf_home{%endif%} {%if individual_book_shelf%}individual_book_shelf{%endif%} {% if not show_books %}cover{% else %}home{% endif %}">
3033
<div id="spinner" class="spinner" style="display:none;" >
3134
<img id="img-spinner" src="css/spinner.gif" alt="Loading" />
3235
</div>

gutenbergtozim/templates/cover_article.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ <h2>{{ book.subtitle }}</h2>
1717
{% endif %}
1818
<div class="cover-detail author">
1919
<p class="label" data-l10n-id="author">Author</p>
20-
<p class="label-value"{{ translate_author}}><a href='javascript:goToAuthor("{{ book.author.name() }}");'>{{ book.author.name() }}</a></p>
20+
<p class="label-value author-btn"{{ translate_author}}><a class="author-btn" data-author-name="{{ book.author.name() }}">{{ book.author.name() }}</a></p>
2121
</div>
2222

2323
<div class="cover-detail language">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*

0 commit comments

Comments
 (0)