Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to new PG server + remove inline JS + remove JS deps from repo #189

Merged
merged 7 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11.1-bullseye
FROM python:3.11.4-bookworm

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

# Install gutenberg (from source)
RUN locale-gen "en_US.UTF-8"
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen "en_US.UTF-8"
COPY requirements.pip /src/
RUN python3 -m pip install -r /src/requirements.pip
COPY LICENSE /src/
COPY pypi-readme.rst /src/
COPY MANIFEST.in /src/
COPY setup.py /src/
COPY get_js_deps.sh /src/
COPY gutenberg2zim /src/
COPY gutenbergtozim /src/gutenbergtozim
WORKDIR /src/
Expand Down
29 changes: 29 additions & 0 deletions get_js_deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh

set -e

###
# download JS dependencies and place them in our templates/assets folder
# then launch our ogv.js script to fix dynamic loading links
###

if ! command -v curl > /dev/null; then
echo "you need curl."
exit 1
fi

# Absolute path this script is in.
SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )"
ASSETS_PATH="${SCRIPT_PATH}/gutenbergtozim/templates"

echo "About to download JS assets to ${ASSETS_PATH}"

echo "getting datatables.min.js"
curl -L -O https://cdn.datatables.net/v/dt/dt-1.13.6/r-2.5.0/datatables.min.js
rm -rf $ASSETS_PATH/datatables/datatables.min.js
mv datatables.min.js $ASSETS_PATH/datatables/datatables.min.js

echo "getting datatables.min.css"
curl -L -O https://cdn.datatables.net/v/dt/dt-1.13.6/r-2.5.0/datatables.min.css
rm -rf $ASSETS_PATH/datatables/datatables.min.css
mv datatables.min.css $ASSETS_PATH/datatables/datatables.min.css
2 changes: 1 addition & 1 deletion gutenbergtozim/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
get_etag_from_url,
)

IMAGE_BASE = "http://dante.pglaf.org/cache/epub/"
IMAGE_BASE = "http://aleph.pglaf.org/cache/epub/"

# for development
# def resource_exists(url):
Expand Down
7 changes: 5 additions & 2 deletions gutenbergtozim/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title {% if show_books %} data-l10n-id="top-title"{% endif %}>{% block title %}Project Gutenberg Library{% endblock %}</title>
<meta name="description" content="Project Gutenberg Ebooks." />
<meta name="show_books" content="{% if show_books %}true{% else %}false{% endif %}" />
<meta name="bookshelf_home" content="{% if bookshelf_home %}true{% else %}false{% endif %}" />
<meta name="bookshelf" content="{% if bookshelf is defined %}{{ bookshelf }}{% endif %}" />
<link rel="shortcut icon" href="favicon.ico" />
<link rel="stylesheet" href="css/pure-min.css" type="text/css" />
<link rel="stylesheet" href="css/grids-responsive-min.css" type="text/css" />
Expand All @@ -17,7 +20,7 @@
<script type="text/javascript" src="jquery/jquery.cookie.js"></script>
<script type="text/javascript" src="jquery/jquery.persist.js"></script>
<script src="jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf8" src="datatables/datatables.js"></script>
<script type="text/javascript" charset="utf8" src="datatables/datatables.min.js"></script>
<script type="application/l10n">{{ l10n_strings }}</script>
<script src="js/l10n.js" type="text/javascript"></script>
<script src="js/tools.js" type="text/javascript"></script>
Expand All @@ -26,7 +29,7 @@
<script src="other_languages.js" type="text/javascript"></script>
</head>

<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 %}">
<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 %}">
<div id="spinner" class="spinner" style="display:none;" >
<img id="img-spinner" src="css/spinner.gif" alt="Loading" />
</div>
Expand Down
2 changes: 1 addition & 1 deletion gutenbergtozim/templates/cover_article.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h2>{{ book.subtitle }}</h2>
{% endif %}
<div class="cover-detail author">
<p class="label" data-l10n-id="author">Author</p>
<p class="label-value"{{ translate_author}}><a href='javascript:goToAuthor("{{ book.author.name() }}");'>{{ book.author.name() }}</a></p>
<p class="label-value author-btn"{{ translate_author}}><a class="author-btn" data-author-name="{{ book.author.name() }}">{{ book.author.name() }}</a></p>
</div>

<div class="cover-detail language">
Expand Down
1 change: 1 addition & 0 deletions gutenbergtozim/templates/datatables/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
Loading