Merge pull request #7 from apoclyps/docker-support

[ISSUE-3] Adding docker support
This commit is contained in:
2019-07-25 22:06:52 +01:00
committed by GitHub
25 changed files with 1230 additions and 440 deletions

10
.dockerignore Normal file
View File

@@ -0,0 +1,10 @@
# Dockerignore whitelist
*
!Pipfile
!Pipfile.lock
!cbreader
!comic
!comic_auth
!manage.py
!pytest

1
.env.example Normal file
View File

@@ -0,0 +1 @@
COMIC_BOOK_VOLUME

173
.github/LICENSE.md vendored Normal file
View File

@@ -0,0 +1,173 @@
## creative commons
# Attribution-ShareAlike 4.0 International
Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible.
### Using Creative Commons Public Licenses
Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses.
* __Considerations for licensors:__ Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. [More considerations for licensors](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensors).
* __Considerations for the public:__ By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensors permission is not necessary for any reasonfor example, because of any applicable exception or limitation to copyrightthen that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. [More considerations for the public](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensees).
## Creative Commons Attribution-ShareAlike 4.0 International Public License
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
### Section 1 Definitions.
a. __Adapted Material__ means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
b. __Adapter's License__ means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
c. __BY-SA Compatible License__ means a license listed at [creativecommons.org/compatiblelicenses](http://creativecommons.org/compatiblelicenses), approved by Creative Commons as essentially the equivalent of this Public License.
d. __Copyright and Similar Rights__ means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
e. __Effective Technological Measures__ means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
f. __Exceptions and Limitations__ means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
g. __License Elements__ means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution and ShareAlike.
h. __Licensed Material__ means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
i. __Licensed Rights__ means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
j. __Licensor__ means the individual(s) or entity(ies) granting rights under this Public License.
k. __Share__ means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
l. __Sui Generis Database Rights__ means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
m. __You__ means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
### Section 2 Scope.
a. ___License grant.___
1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
A. reproduce and Share the Licensed Material, in whole or in part; and
B. produce, reproduce, and Share Adapted Material.
2. __Exceptions and Limitations.__ For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
3. __Term.__ The term of this Public License is specified in Section 6(a).
4. __Media and formats; technical modifications allowed.__ The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
5. __Downstream recipients.__
A. __Offer from the Licensor Licensed Material.__ Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
B. __Additional offer from the Licensor Adapted Material.__ Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapters License You apply.
C. __No downstream restrictions.__ You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
6. __No endorsement.__ Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
b. ___Other rights.___
1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
2. Patent and trademark rights are not licensed under this Public License.
3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties.
### Section 3 License Conditions.
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
a. ___Attribution.___
1. If You Share the Licensed Material (including in modified form), You must:
A. retain the following if it is supplied by the Licensor with the Licensed Material:
i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
ii. a copyright notice;
iii. a notice that refers to this Public License;
iv. a notice that refers to the disclaimer of warranties;
v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
b. ___ShareAlike.___
In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply.
1. The Adapters License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-SA Compatible License.
2. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material.
3. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply.
### Section 4 Sui Generis Database Rights.
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database;
b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and
c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
### Section 5 Disclaimer of Warranties and Limitation of Liability.
a. __Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.__
b. __To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.__
c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
### Section 6 Term and Termination.
a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
2. upon express reinstatement by the Licensor.
For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
### Section 7 Other Terms and Conditions.
a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
### Section 8 Interpretation.
a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
> Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” The text of the Creative Commons public licenses is dedicated to the public domain under the [CC0 Public Domain Dedication](https://creativecommons.org/publicdomain/zero/1.0/legalcode). Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at [creativecommons.org/policies](http://creativecommons.org/policies), Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses.
>
> Creative Commons may be contacted at creativecommons.org.

89
.gitignore vendored Normal file
View File

@@ -0,0 +1,89 @@
# Created by https://www.gitignore.io
### OSX ###
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml
# Translations
*.mo
*.pot
# Sphinx documentation
docs/_build/
# PyBuilder
target/
### Django ###
*.log
*.pot
*.pyc
__pycache__/
local_settings.py
.env
db.sqlite3

View File

@@ -1,16 +1,28 @@
FROM python:3-alpine FROM python:3-alpine
ENV PYTHONUNBUFFERED 1 ENV PYTHONUNBUFFERED 1
RUN apk update RUN apk update
RUN apk add --no-cache tini bash unrar dcron postgresql-dev RUN apk add --no-cache tini bash unrar dcron postgresql-dev gcc python3-dev musl-dev
RUN mkdir /src
WORKDIR /src
ADD Pipfile /src
ADD Pipfile.lock /src
RUN apk add --no-cache --virtual .build-deps mariadb-dev build-base \ RUN apk add --no-cache --virtual .build-deps mariadb-dev build-base \
&& pip install pipenv \ && pip install pipenv \
&& pipenv install --system \
&& apk add --virtual .runtime-deps mariadb-connector-c-dev mariadb-connector-c \ && apk add --virtual .runtime-deps mariadb-connector-c-dev mariadb-connector-c \
&& apk del .build-deps && apk del .build-deps
ADD . /src/
RUN mkdir /src
WORKDIR /src
ADD Pipfile /src
ADD Pipfile.lock /src
RUN pipenv install --deploy --dev --ignore-pipfile --system
COPY . /src/
RUN cat /src/cbreader/crontab >> /etc/crontabs/root RUN cat /src/cbreader/crontab >> /etc/crontabs/root
EXPOSE 8000 EXPOSE 8000

View File

@@ -4,14 +4,20 @@ url = "https://pypi.org/simple"
verify_ssl = true verify_ssl = true
[dev-packages] [dev-packages]
pdbpp = "*"
pytest-django = "*"
pytest-black = "*"
pytest-flake8 = "*"
[packages] [packages]
ujson = "*" ujson = "*"
django-silk = "*" django-silk = "*"
django-recaptcha2 = "*" django-recaptcha2 = "*"
dj-database-url = "*"
Django = "*" Django = "*"
gunicorn = "*" gunicorn = "*"
flake8 = "*" flake8 = "*"
psycopg2-binary = "*"
[requires] [requires]
python_version = "3.7" python_version = "3.7"

392
Pipfile.lock generated
View File

@@ -1,7 +1,7 @@
{ {
"_meta": { "_meta": {
"hash": { "hash": {
"sha256": "0b9fcb0ea9277c2f815fc7163a8bce830eb5786509560305a36ce938bb4842aa" "sha256": "6ac08e443037cce0633c9272ad59f12fc7924be76f4cc10222825dc09d16b661"
}, },
"pipfile-spec": 6, "pipfile-spec": 6,
"requires": { "requires": {
@@ -18,16 +18,16 @@
"default": { "default": {
"autopep8": { "autopep8": {
"hashes": [ "hashes": [
"sha256:33d2b5325b7e1afb4240814fe982eea3a92ebea712869bfd08b3c0393404248c" "sha256:4d8eec30cc81bc5617dbf1218201d770dc35629363547f17577c61683ccfb3ee"
], ],
"version": "==1.4.3" "version": "==1.4.4"
}, },
"certifi": { "certifi": {
"hashes": [ "hashes": [
"sha256:47f9c83ef4c0c621eaef743f133f09fa8a74a9b75f037e8624f83bd1b6626cb7", "sha256:046832c04d4e752f37383b628bc601a7ea7211496b4638f6514d0e5b9acc4939",
"sha256:993f830721089fef441cdfeb4b2c8c9df86f0c63239f06bd025a76a7daddb033" "sha256:945e3ba63a0b9f577b1395204e13c3a231f9bc0223888be653286534e5873695"
], ],
"version": "==2018.11.29" "version": "==2019.6.16"
}, },
"chardet": { "chardet": {
"hashes": [ "hashes": [
@@ -36,13 +36,21 @@
], ],
"version": "==3.0.4" "version": "==3.0.4"
}, },
"django": { "dj-database-url": {
"hashes": [ "hashes": [
"sha256:275bec66fd2588dd517ada59b8bfb23d4a9abc5a362349139ddda3c7ff6f5ade", "sha256:4aeaeb1f573c74835b0686a2b46b85990571159ffc21aa57ecd4d1e1cb334163",
"sha256:939652e9d34d7d53d74d5d8ef82a19e5f8bb2de75618f7e5360691b6e9667963" "sha256:851785365761ebe4994a921b433062309eb882fedd318e1b0fcecc607ed02da9"
], ],
"index": "pypi", "index": "pypi",
"version": "==2.1.7" "version": "==0.5.0"
},
"django": {
"hashes": [
"sha256:4d23f61b26892bac785f07401bc38cbf8fa4cec993f400e9cd9ddf28fd51c0ea",
"sha256:6e974d4b57e3b29e4882b244d40171d6a75202ab8d2402b8e8adbd182e25cf0c"
],
"index": "pypi",
"version": "==2.2.3"
}, },
"django-recaptcha2": { "django-recaptcha2": {
"hashes": [ "hashes": [
@@ -54,11 +62,11 @@
}, },
"django-silk": { "django-silk": {
"hashes": [ "hashes": [
"sha256:ab6b7151a54eaa14d4fc77a58fd75e7c0c8bd60d29c87e55575845a304b0c0eb", "sha256:646f422318e880004424623fbbf854bfa45c86df11beedd9752815b5a68f47fb",
"sha256:bce0e35d2a6ec3688a0c062c6964695beef4a452be48085f2c1e25f685652d9d" "sha256:8dd5b78531360bd8c3d571384f9f4f82ef03e1764e30dd4621c5638f5c973a1d"
], ],
"index": "pypi", "index": "pypi",
"version": "==3.0.1" "version": "==3.0.2"
}, },
"entrypoints": { "entrypoints": {
"hashes": [ "hashes": [
@@ -69,17 +77,17 @@
}, },
"flake8": { "flake8": {
"hashes": [ "hashes": [
"sha256:c3ba1e130c813191db95c431a18cb4d20a468e98af7a77e2181b68574481ad36", "sha256:19241c1cbc971b9962473e4438a2ca19749a7dd002dd1a946eaba171b4114548",
"sha256:fd9ddf503110bf3d8b1d270e8c673aab29ccb3dd6abf29bae1f54e5116ab4a91" "sha256:8e9dfa3cecb2400b3738a42c54c3043e821682b9c840b0448c0503f781130696"
], ],
"index": "pypi", "index": "pypi",
"version": "==3.7.5" "version": "==3.7.8"
}, },
"gprof2dot": { "gprof2dot": {
"hashes": [ "hashes": [
"sha256:48c1e168c28b8a8eb23bf30fda78fe2ef218269a41505341ec27c27083e47cf4" "sha256:cebc7aa2782fd813ead415ea1fae3409524343485eadc7fb60ef5bd1e810309e"
], ],
"version": "==2016.10.13" "version": "==2017.9.19"
}, },
"gunicorn": { "gunicorn": {
"hashes": [ "hashes": [
@@ -98,43 +106,43 @@
}, },
"jinja2": { "jinja2": {
"hashes": [ "hashes": [
"sha256:74c935a1b8bb9a3947c50a54766a969d4846290e1e788ea44c1392163723c3bd", "sha256:065c4f02ebe7f7cf559e49ee5a95fb800a9e4528727aec6f24402a5374c65013",
"sha256:f84be1bb0040caca4cea721fcbbbbd61f9be9464ca236387158b0feea01914a4" "sha256:14dd6caf1527abb21f08f86c784eac40853ba93edb79552aa1e4b8aef1b61c7b"
], ],
"version": "==2.10" "version": "==2.10.1"
}, },
"markupsafe": { "markupsafe": {
"hashes": [ "hashes": [
"sha256:048ef924c1623740e70204aa7143ec592504045ae4429b59c30054cb31e3c432", "sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473",
"sha256:130f844e7f5bdd8e9f3f42e7102ef1d49b2e6fdf0d7526df3f87281a532d8c8b", "sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161",
"sha256:19f637c2ac5ae9da8bfd98cef74d64b7e1bb8a63038a3505cd182c3fac5eb4d9", "sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235",
"sha256:1b8a7a87ad1b92bd887568ce54b23565f3fd7018c4180136e1cf412b405a47af", "sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5",
"sha256:1c25694ca680b6919de53a4bb3bdd0602beafc63ff001fea2f2fc16ec3a11834", "sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff",
"sha256:1f19ef5d3908110e1e891deefb5586aae1b49a7440db952454b4e281b41620cd", "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b",
"sha256:1fa6058938190ebe8290e5cae6c351e14e7bb44505c4a7624555ce57fbbeba0d", "sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1",
"sha256:31cbb1359e8c25f9f48e156e59e2eaad51cd5242c05ed18a8de6dbe85184e4b7", "sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e",
"sha256:3e835d8841ae7863f64e40e19477f7eb398674da6a47f09871673742531e6f4b", "sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183",
"sha256:4e97332c9ce444b0c2c38dd22ddc61c743eb208d916e4265a2a3b575bdccb1d3", "sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66",
"sha256:525396ee324ee2da82919f2ee9c9e73b012f23e7640131dd1b53a90206a0f09c", "sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1",
"sha256:52b07fbc32032c21ad4ab060fec137b76eb804c4b9a1c7c7dc562549306afad2", "sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1",
"sha256:52ccb45e77a1085ec5461cde794e1aa037df79f473cbc69b974e73940655c8d7", "sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e",
"sha256:5c3fbebd7de20ce93103cb3183b47671f2885307df4a17a0ad56a1dd51273d36", "sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b",
"sha256:5e5851969aea17660e55f6a3be00037a25b96a9b44d2083651812c99d53b14d1", "sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905",
"sha256:5edfa27b2d3eefa2210fb2f5d539fbed81722b49f083b2c6566455eb7422fd7e", "sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735",
"sha256:7d263e5770efddf465a9e31b78362d84d015cc894ca2c131901a4445eaa61ee1", "sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d",
"sha256:83381342bfc22b3c8c06f2dd93a505413888694302de25add756254beee8449c", "sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e",
"sha256:857eebb2c1dc60e4219ec8e98dfa19553dae33608237e107db9c6078b1167856", "sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d",
"sha256:98e439297f78fca3a6169fd330fbe88d78b3bb72f967ad9961bcac0d7fdd1550", "sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c",
"sha256:bf54103892a83c64db58125b3f2a43df6d2cb2d28889f14c78519394feb41492", "sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21",
"sha256:d9ac82be533394d341b41d78aca7ed0e0f4ba5a2231602e2f05aa87f25c51672", "sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2",
"sha256:e982fe07ede9fada6ff6705af70514a52beb1b2c3d25d4e873e82114cf3c5401", "sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5",
"sha256:edce2ea7f3dfc981c4ddc97add8a61381d9642dc3273737e756517cc03e84dd6", "sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b",
"sha256:efdc45ef1afc238db84cb4963aa689c0408912a0239b0721cb172b4016eb31d6", "sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6",
"sha256:f137c02498f8b935892d5c0172560d7ab54bc45039de8805075e19079c639a9c", "sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f",
"sha256:f82e347a72f955b7017a39708a3667f106e6ad4d10b25f237396a7115d8ed5fd", "sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f",
"sha256:fb7c206e01ad85ce57feeaaa0bf784b97fa3cad0d4a5737bc5295785f5c613a1" "sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7"
], ],
"version": "==1.1.0" "version": "==1.1.1"
}, },
"mccabe": { "mccabe": {
"hashes": [ "hashes": [
@@ -143,6 +151,40 @@
], ],
"version": "==0.6.1" "version": "==0.6.1"
}, },
"psycopg2-binary": {
"hashes": [
"sha256:080c72714784989474f97be9ab0ddf7b2ad2984527e77f2909fcd04d4df53809",
"sha256:110457be80b63ff4915febb06faa7be002b93a76e5ba19bf3f27636a2ef58598",
"sha256:171352a03b22fc099f15103959b52ee77d9a27e028895d7e5fde127aa8e3bac5",
"sha256:19d013e7b0817087517a4b3cab39c084d78898369e5c46258aab7be4f233d6a1",
"sha256:249b6b21ae4eb0f7b8423b330aa80fab5f821b9ffc3f7561a5e2fd6bb142cf5d",
"sha256:2ac0731d2d84b05c7bb39e85b7e123c3a0acd4cda631d8d542802c88deb9e87e",
"sha256:2b6d561193f0dc3f50acfb22dd52ea8c8dfbc64bcafe3938b5f209cc17cb6f00",
"sha256:2bd23e242e954214944481124755cbefe7c2cf563b1a54cd8d196d502f2578bf",
"sha256:3e1239242ca60b3725e65ab2f13765fc199b03af9eaf1b5572f0e97bdcee5b43",
"sha256:3eb70bb697abbe86b1d2b1316370c02ba320bfd1e9e35cf3b9566a855ea8e4e5",
"sha256:51a2fc7e94b98bd1bb5d4570936f24fc2b0541b63eccadf8fdea266db8ad2f70",
"sha256:52f1bdafdc764b7447e393ed39bb263eccb12bfda25a4ac06d82e3a9056251f6",
"sha256:5b3581319a3951f1e866f4f6c5e42023db0fae0284273b82e97dfd32c51985cd",
"sha256:63c1b66e3b2a3a336288e4bcec499e0dc310cd1dceaed1c46fa7419764c68877",
"sha256:8123a99f24ecee469e5c1339427bcdb2a33920a18bb5c0d58b7c13f3b0298ba3",
"sha256:85e699fcabe7f817c0f0a412d4e7c6627e00c412b418da7666ff353f38e30f67",
"sha256:8dbff4557bbef963697583366400822387cccf794ccb001f1f2307ed21854c68",
"sha256:908d21d08d6b81f1b7e056bbf40b2f77f8c499ab29e64ec5113052819ef1c89b",
"sha256:af39d0237b17d0a5a5f638e9dffb34013ce2b1d41441fd30283e42b22d16858a",
"sha256:af51bb9f055a3f4af0187149a8f60c9d516cf7d5565b3dac53358796a8fb2a5b",
"sha256:b2ecac57eb49e461e86c092761e6b8e1fd9654dbaaddf71a076dcc869f7014e2",
"sha256:cd37cc170678a4609becb26b53a2bc1edea65177be70c48dd7b39a1149cabd6e",
"sha256:d17e3054b17e1a6cb8c1140f76310f6ede811e75b7a9d461922d2c72973f583e",
"sha256:d305313c5a9695f40c46294d4315ed3a07c7d2b55e48a9010dad7db7a66c8b7f",
"sha256:dd0ef0eb1f7dd18a3f4187226e226a7284bda6af5671937a221766e6ef1ee88f",
"sha256:e1adff53b56db9905db48a972fb89370ad5736e0450b96f91bcf99cadd96cfd7",
"sha256:f0d43828003c82dbc9269de87aa449e9896077a71954fbbb10a614c017e65737",
"sha256:f78e8b487de4d92640105c1389e5b90be3496b1d75c90a666edd8737cc2dbab7"
],
"index": "pypi",
"version": "==2.8.3"
},
"pycodestyle": { "pycodestyle": {
"hashes": [ "hashes": [
"sha256:95a2219d12372f05704562a14ec30bc76b05a5b297b21a5dfe3f6fac3491ae56", "sha256:95a2219d12372f05704562a14ec30bc76b05a5b297b21a5dfe3f6fac3491ae56",
@@ -152,17 +194,17 @@
}, },
"pyflakes": { "pyflakes": {
"hashes": [ "hashes": [
"sha256:5e8c00e30c464c99e0b501dc160b13a14af7f27d4dffb529c556e30a159e231d", "sha256:17dbeb2e3f4d772725c777fabc446d5634d1038f234e77343108ce445ea69ce0",
"sha256:f277f9ca3e55de669fba45b7393a1449009cff5a37d1af10ebb76c52765269cd" "sha256:d976835886f8c5b31d47970ed689944a0262b5f3afa00a5a7b4dc81e5449f8a2"
], ],
"version": "==2.1.0" "version": "==2.1.1"
}, },
"pygments": { "pygments": {
"hashes": [ "hashes": [
"sha256:5ffada19f6203563680669ee7f53b64dabbeb100eb51b61996085e99c03b284a", "sha256:71e430bc85c88a430f000ac1d9b331d2407f681d6f6aec95e8bcfbc3df5b0127",
"sha256:e8218dd399a61674745138520d0d4cf2621d7e032439341bc3f647bff125818d" "sha256:881c4c157e45f30af185c1ffe8d549d48ac9127433f2c380c24b84572ad66297"
], ],
"version": "==2.3.1" "version": "==2.4.2"
}, },
"python-dateutil": { "python-dateutil": {
"hashes": [ "hashes": [
@@ -173,17 +215,17 @@
}, },
"pytz": { "pytz": {
"hashes": [ "hashes": [
"sha256:32b0891edff07e28efe91284ed9c31e123d84bea3fd98e1f72be2508f43ef8d9", "sha256:303879e36b721603cc54604edcac9d20401bdbe31e1e4fdee5b9f98d5d31dfda",
"sha256:d5f05e487007e29e03409f9398d074e158d920d36eb82eaf66fb1136b0c5374c" "sha256:d747dd3d23d77ef44c6a3526e274af6efeb0a6f1afd5a69ba4d5be4098c8e141"
], ],
"version": "==2018.9" "version": "==2019.1"
}, },
"requests": { "requests": {
"hashes": [ "hashes": [
"sha256:502a824f31acdacb3a35b6690b5fbf0bc41d63a24a45c4004352b0242707598e", "sha256:11e007a8a2aa0323f5a921e9e6a2d7e4e67d9877e85773fba9ba6419025cbeb4",
"sha256:7bf2a778576d825600030a110f3c0e3e8edc51dfaafe1c146e39a2027784957b" "sha256:9cf5292fcd0f598c671cfc1e0d7d1a7f13bb8085e9a590f48c010551dc6c4b31"
], ],
"version": "==2.21.0" "version": "==2.22.0"
}, },
"six": { "six": {
"hashes": [ "hashes": [
@@ -194,10 +236,10 @@
}, },
"sqlparse": { "sqlparse": {
"hashes": [ "hashes": [
"sha256:ce028444cfab83be538752a2ffdb56bc417b7784ff35bb9a3062413717807dec", "sha256:40afe6b8d4b1117e7dff5504d7a8ce07d9a1b15aeeade8a2d10f130a834f8177",
"sha256:d9cf190f51cbb26da0412247dfe4fb5f4098edb73db84e02f9fc21fdca31fed4" "sha256:7c3dca29c022744e95b547e867cee89f4fce4373f3549ccd8797d8eb52cdb873"
], ],
"version": "==0.2.4" "version": "==0.3.0"
}, },
"ujson": { "ujson": {
"hashes": [ "hashes": [
@@ -208,11 +250,223 @@
}, },
"urllib3": { "urllib3": {
"hashes": [ "hashes": [
"sha256:61bf29cada3fc2fbefad4fdf059ea4bd1b4a86d2b6d15e1c7c0b582b9752fe39", "sha256:b246607a25ac80bedac05c6f282e3cdaf3afb65420fd024ac94435cabe6e18d1",
"sha256:de9529817c93f27c8ccbfead6985011db27bd0ddfcdb2d86f3f663385c6a9c22" "sha256:dbe59173209418ae49d485b87d1681aefa36252ee85884c31346debd19463232"
], ],
"version": "==1.24.1" "version": "==1.25.3"
} }
}, },
"develop": {} "develop": {
"appdirs": {
"hashes": [
"sha256:9e5896d1372858f8dd3344faf4e5014d21849c756c8d5701f78f8a103b372d92",
"sha256:d8b24664561d0d34ddfaec54636d502d7cea6e29c3eaf68f3df6180863e2166e"
],
"version": "==1.4.3"
},
"atomicwrites": {
"hashes": [
"sha256:03472c30eb2c5d1ba9227e4c2ca66ab8287fbfbbda3888aa93dc2e28fc6811b4",
"sha256:75a9445bac02d8d058d5e1fe689654ba5a6556a1dfd8ce6ec55a0ed79866cfa6"
],
"version": "==1.3.0"
},
"attrs": {
"hashes": [
"sha256:69c0dbf2ed392de1cb5ec704444b08a5ef81680a61cb899dc08127123af36a79",
"sha256:f0b870f674851ecbfbbbd364d6b5cbdff9dcedbc7f3f5e18a6891057f21fe399"
],
"version": "==19.1.0"
},
"black": {
"hashes": [
"sha256:09a9dcb7c46ed496a9850b76e4e825d6049ecd38b611f1224857a79bd985a8cf",
"sha256:68950ffd4d9169716bcb8719a56c07a2f4485354fec061cdd5910aa07369731c"
],
"version": "==19.3b0"
},
"click": {
"hashes": [
"sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13",
"sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7"
],
"version": "==7.0"
},
"colorama": {
"hashes": [
"sha256:05eed71e2e327246ad6b38c540c4a3117230b19679b875190486ddd2d721422d",
"sha256:f8ac84de7840f5b9c4e3347b3c1eaa50f7e49c2b07596221daec5edaabbd7c48"
],
"markers": "sys_platform == 'win32'",
"version": "==0.4.1"
},
"entrypoints": {
"hashes": [
"sha256:589f874b313739ad35be6e0cd7efde2a4e9b6fea91edcc34e58ecbb8dbe56d19",
"sha256:c70dd71abe5a8c85e55e12c19bd91ccfeec11a6e99044204511f9ed547d48451"
],
"version": "==0.3"
},
"fancycompleter": {
"hashes": [
"sha256:d2522f1f3512371f295379c4c0d1962de06762eb586c199620a2a5d423539b12"
],
"version": "==0.8"
},
"flake8": {
"hashes": [
"sha256:19241c1cbc971b9962473e4438a2ca19749a7dd002dd1a946eaba171b4114548",
"sha256:8e9dfa3cecb2400b3738a42c54c3043e821682b9c840b0448c0503f781130696"
],
"index": "pypi",
"version": "==3.7.8"
},
"importlib-metadata": {
"hashes": [
"sha256:6dfd58dfe281e8d240937776065dd3624ad5469c835248219bd16cf2e12dbeb7",
"sha256:cb6ee23b46173539939964df59d3d72c3e0c1b5d54b84f1d8a7e912fe43612db"
],
"version": "==0.18"
},
"mccabe": {
"hashes": [
"sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42",
"sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"
],
"version": "==0.6.1"
},
"more-itertools": {
"hashes": [
"sha256:409cd48d4db7052af495b09dec721011634af3753ae1ef92d2b32f73a745f832",
"sha256:92b8c4b06dac4f0611c0729b2f2ede52b2e1bac1ab48f089c7ddc12e26bb60c4"
],
"version": "==7.2.0"
},
"packaging": {
"hashes": [
"sha256:0c98a5d0be38ed775798ece1b9727178c4469d9c3b4ada66e8e6b7849f8732af",
"sha256:9e1cbf8c12b1f1ce0bb5344b8d7ecf66a6f8a6e91bcb0c84593ed6d3ab5c4ab3"
],
"version": "==19.0"
},
"pdbpp": {
"hashes": [
"sha256:ee7eab02ecf32d92bd66b45eedb9bda152fa13f7be0dceb7050413a52cbbc4dd"
],
"index": "pypi",
"version": "==0.10.0"
},
"pluggy": {
"hashes": [
"sha256:0825a152ac059776623854c1543d65a4ad408eb3d33ee114dff91e57ec6ae6fc",
"sha256:b9817417e95936bf75d85d3f8767f7df6cdde751fc40aed3bb3074cbcb77757c"
],
"version": "==0.12.0"
},
"py": {
"hashes": [
"sha256:64f65755aee5b381cea27766a3a147c3f15b9b6b9ac88676de66ba2ae36793fa",
"sha256:dc639b046a6e2cff5bbe40194ad65936d6ba360b52b3c3fe1d08a82dd50b5e53"
],
"version": "==1.8.0"
},
"pycodestyle": {
"hashes": [
"sha256:95a2219d12372f05704562a14ec30bc76b05a5b297b21a5dfe3f6fac3491ae56",
"sha256:e40a936c9a450ad81df37f549d676d127b1b66000a6c500caa2b085bc0ca976c"
],
"version": "==2.5.0"
},
"pyflakes": {
"hashes": [
"sha256:17dbeb2e3f4d772725c777fabc446d5634d1038f234e77343108ce445ea69ce0",
"sha256:d976835886f8c5b31d47970ed689944a0262b5f3afa00a5a7b4dc81e5449f8a2"
],
"version": "==2.1.1"
},
"pygments": {
"hashes": [
"sha256:71e430bc85c88a430f000ac1d9b331d2407f681d6f6aec95e8bcfbc3df5b0127",
"sha256:881c4c157e45f30af185c1ffe8d549d48ac9127433f2c380c24b84572ad66297"
],
"version": "==2.4.2"
},
"pyparsing": {
"hashes": [
"sha256:1873c03321fc118f4e9746baf201ff990ceb915f433f23b395f5580d1840cb2a",
"sha256:9b6323ef4ab914af344ba97510e966d64ba91055d6b9afa6b30799340e89cc03"
],
"version": "==2.4.0"
},
"pyreadline": {
"hashes": [
"sha256:4530592fc2e85b25b1a9f79664433da09237c1a270e4d78ea5aa3a2c7229e2d1"
],
"version": "==2.1"
},
"pytest": {
"hashes": [
"sha256:6ef6d06de77ce2961156013e9dff62f1b2688aa04d0dc244299fe7d67e09370d",
"sha256:a736fed91c12681a7b34617c8fcefe39ea04599ca72c608751c31d89579a3f77"
],
"version": "==5.0.1"
},
"pytest-black": {
"hashes": [
"sha256:75bbeccfe23442a190164c0bf202d7498df25451fa4177b781cee20183e7fc0d"
],
"index": "pypi",
"version": "==0.3.7"
},
"pytest-django": {
"hashes": [
"sha256:264fb4c506db5d48a6364c311a0b00b7b48a52715bad8839b2d8bee9b99ed6bb",
"sha256:4adfe5fb3ed47f0ba55506dd3daf688b1f74d5e69148c10ad2dd2f79f40c0d62"
],
"index": "pypi",
"version": "==3.5.1"
},
"pytest-flake8": {
"hashes": [
"sha256:4d225c13e787471502ff94409dcf6f7927049b2ec251c63b764a4b17447b60c0",
"sha256:d7e2b6b274a255b7ae35e9224c85294b471a83b76ecb6bd53c337ae977a499af"
],
"index": "pypi",
"version": "==1.0.4"
},
"six": {
"hashes": [
"sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c",
"sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73"
],
"version": "==1.12.0"
},
"toml": {
"hashes": [
"sha256:229f81c57791a41d65e399fc06bf0848bab550a9dfd5ed66df18ce5f05e73d5c",
"sha256:235682dd292d5899d361a811df37e04a8828a5b1da3115886b73cf81ebc9100e"
],
"version": "==0.10.0"
},
"wcwidth": {
"hashes": [
"sha256:3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e",
"sha256:f4ebe71925af7b40a864553f761ed559b43544f8f71746c2d756c7fe788ade7c"
],
"version": "==0.1.7"
},
"wmctrl": {
"hashes": [
"sha256:d806f65ac1554366b6e31d29d7be2e8893996c0acbb2824bbf2b1f49cf628a13"
],
"version": "==0.3"
},
"zipp": {
"hashes": [
"sha256:4970c3758f4e89a7857a973b1e2a5d75bcdc47794442f2e2dd4fe8e0466e809a",
"sha256:8a5712cfd3bb4248015eb3b0b3c54a5f6ee3f2425963ef2a0125b8bc40aafaec"
],
"version": "==0.5.2"
}
}
} }

View File

@@ -1,8 +1,17 @@
# cbwebreader # CBWebReader
Web Based CBR and CBZ file reader.
This is for if you have a collection of comics on a media server and want to read them remotely.
# Requirments CBWebReader is web-based CBR and CBZ file reader implemented in Django. The application allows a user to host their collection of digital comics (CBR & CBZ formats) as a remotely accessible collect.
![CBWebReader Screenshot](assets/cbwebreader.jpg)
## Core technologies
The following technologies will aid development by ensuring a consistent development environment for all developers:
- [docker](https://www.docker.com/get-started)
- [docker-compose](https://docs.docker.com/compose/gettingstarted/)
The following frameworks and tool's are used within the application:
- [Django 2.0](https://www.djangoproject.com/) - [Django 2.0](https://www.djangoproject.com/)
- [python 3.5+](https://www.python.org/) - [python 3.5+](https://www.python.org/)
@@ -10,14 +19,51 @@ This is for if you have a collection of comics on a media server and want to rea
- [Unrar by winrar](http://rarlabs.com) - [Unrar by winrar](http://rarlabs.com)
- [django-recaptcha by praekelt](https://github.com/praekelt/django-recaptcha) - [django-recaptcha by praekelt](https://github.com/praekelt/django-recaptcha)
# Installation ## Getting started
Pull from git and use like any django project.
Also has a task manage.py scan_comics. The CBWebReader is a Django project and follows the standard conventions for a Django application. To get started, clone the project into your workspace:
Use this after getting setup and it will speed up your browsing.
to keep your comics always up to date you should set this up as a scheduled task to run
as often as you wish, that way the recent comics page will work best.
```bash
git clone https://github.com/ajurna/cbwebreader
```
# License Configure the environment using the `.env` file or setting each variable within your environment:
https://creativecommons.org/licenses/by-sa/4.0/
```bash
cp .env.example .env
```
Alternatively, set the path to your `COMIC_BOOK_VOLUME` like so:
```bash
export COMIC_BOOK_VOLUME=some_path_to_comics_directory
```
Build and run the project using docker-compose:
```bash
docker-compose build
docker-compose up
```
## Running Tests
To run the entire test suite for CBWebReader, execute the following command:
```bash
docker-compose run app pytest -vvv
```
## Syncing comic books
Once the application has been configured and runs for the first time, an initial import of comics will be made available to browse and view. However, future additions will need to be synced before they will be available. A sync can be performed by running the following command:
```bash
docker-compose run app python manage.py scan_comics
```
It is recommended that you configure a scheduled task to run the sync as frequently as you wish to ensure your collection is up-to-date.
## License
This is a [human-readable summary](https://creativecommons.org/licenses/by-sa/4.0/) of (and not a substitute for) the [Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) License](".github/license").

BIN
assets/cbwebreader.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

View File

@@ -13,6 +13,8 @@ https://docs.djangoproject.com/en/1.8/ref/settings/
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os import os
import dj_database_url
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@@ -76,12 +78,17 @@ WSGI_APPLICATION = 'cbreader.wsgi.application'
# Database # Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases # https://docs.djangoproject.com/en/1.8/ref/settings/#databases
DATABASES = { DATABASE_URL = os.getenv("DATABASE_URL")
'default': {
'ENGINE': 'django.db.backends.sqlite3', if DATABASE_URL:
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), DATABASES = {"default": dj_database_url.config(conn_max_age=500)}
else:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
} }
}
# Internationalization # Internationalization
@@ -107,7 +114,7 @@ LOGIN_REDIRECT_URL = '/comic/'
LOGIN_URL = '/login/' LOGIN_URL = '/login/'
UNRAR_TOOL = 'C:/Program Files/WinRAR/unrar' UNRAR_TOOL = os.getenv("UNRAR_TOOL", None)
CBREADER_USE_RECAPTCHA = False CBREADER_USE_RECAPTCHA = False
RECAPTCHA_PRIVATE_KEY = '' RECAPTCHA_PRIVATE_KEY = ''

123
cbreader/settings/test.py Normal file
View File

@@ -0,0 +1,123 @@
"""
Django settings for cbreader project.
Generated by 'django-admin startproject' using Django 1.8.2.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
import dj_database_url
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '=3tf-@u1t7x4%$yr++59+8tspl4ao&r3&!bb6l(t&$#6@bfkwg'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.environ.get('DJANGO_DEBUG', True)
ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS", "localhost").split(",")
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'snowpenguin.django.recaptcha2',
'comic',
'comic_auth',
)
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'cbreader.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'cbreader.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
DATABASE_URL = os.getenv("TEST_DATABASE_URL")
if DATABASE_URL:
DATABASES = {"default": dj_database_url.config(conn_max_age=500)}
else:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/
LANGUAGE_CODE = 'en-ie'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/
STATIC_URL = '/static/'
LOGIN_REDIRECT_URL = '/comic/'
LOGIN_URL = '/login/'
UNRAR_TOOL = os.getenv("UNRAR_TOOL", None)
CBREADER_USE_RECAPTCHA = False
RECAPTCHA_PRIVATE_KEY = ''
RECAPTCHA_PUBLIC_KEY = ''
COMIC_DIR = "/media/comics"

View File

@@ -11,6 +11,6 @@ import os
from django.core.wsgi import get_wsgi_application from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cbreader.settings") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cbreader.settings.base")
application = get_wsgi_application() application = get_wsgi_application()

View File

@@ -29,4 +29,4 @@ class RecentComics(Feed):
# item_link is only needed if NewsItem has no get_absolute_url method. # item_link is only needed if NewsItem has no get_absolute_url method.
def item_link(self, item: ComicBook) -> str: def item_link(self, item: ComicBook) -> str:
return '/comic/read/{0}/0/'.format(urlsafe_base64_encode(item.selector.bytes).decode()) return '/comic/read/{0}/0/'.format(urlsafe_base64_encode(item.selector.bytes))

View File

@@ -80,7 +80,7 @@ class ComicBook(models.Model):
@property @property
def selector_string(self): def selector_string(self):
return urlsafe_base64_encode(self.selector.bytes).decode() return urlsafe_base64_encode(self.selector.bytes)
def get_image(self, page): def get_image(self, page):
base_dir = Setting.objects.get(name='BASE_DIR').value base_dir = Setting.objects.get(name='BASE_DIR').value
@@ -124,7 +124,7 @@ class ComicBook(models.Model):
def nav(self, page, user): def nav(self, page, user):
out = self.Navigation( out = self.Navigation(
cur_index=page, cur_index=page,
cur_path=urlsafe_base64_encode(self.selector.bytes).decode() cur_path=urlsafe_base64_encode(self.selector.bytes)
) )
if page == 0: if page == 0:
out.prev_path, out.prev_index = self.nav_get_prev_comic(user) out.prev_path, out.prev_index = self.nav_get_prev_comic(user)
@@ -153,7 +153,7 @@ class ComicBook(models.Model):
comic_index = dir_list.index(self.file_name) comic_index = dir_list.index(self.file_name)
if comic_index == 0: if comic_index == 0:
if self.directory: if self.directory:
comic_path = urlsafe_base64_encode(self.directory.selector.bytes).decode() comic_path = urlsafe_base64_encode(self.directory.selector.bytes)
else: else:
comic_path = '' comic_path = ''
index = -1 index = -1
@@ -175,10 +175,10 @@ class ComicBook(models.Model):
book = ComicBook.process_comic_book(prev_comic) book = ComicBook.process_comic_book(prev_comic)
cs, _ = ComicStatus.objects.get_or_create(comic=book, user=user) cs, _ = ComicStatus.objects.get_or_create(comic=book, user=user)
index = cs.last_read_page index = cs.last_read_page
comic_path = urlsafe_base64_encode(book.selector.bytes).decode() comic_path = urlsafe_base64_encode(book.selector.bytes)
else: else:
if self.directory: if self.directory:
comic_path = urlsafe_base64_encode(self.directory.selector.bytes).decode() comic_path = urlsafe_base64_encode(self.directory.selector.bytes)
else: else:
comic_path = '' comic_path = ''
index = -1 index = -1
@@ -208,12 +208,12 @@ class ComicBook(models.Model):
book = ComicBook.process_comic_book(next_comic) book = ComicBook.process_comic_book(next_comic)
if type(book) is str: if type(book) is str:
raise IndexError raise IndexError
comic_path = urlsafe_base64_encode(book.selector.bytes).decode() comic_path = urlsafe_base64_encode(book.selector.bytes)
cs, _ = ComicStatus.objects.get_or_create(comic=book, user=user) cs, _ = ComicStatus.objects.get_or_create(comic=book, user=user)
index = cs.last_read_page index = cs.last_read_page
except IndexError: except IndexError:
if self.directory: if self.directory:
comic_path = urlsafe_base64_encode(self.directory.selector.bytes).decode() comic_path = urlsafe_base64_encode(self.directory.selector.bytes)
else: else:
comic_path = '' comic_path = ''
index = -1 index = -1

View File

@@ -1,328 +0,0 @@
import json
import os
from os import path
from django.contrib.auth.models import User
from django.test import TestCase, Client
from django.utils.http import urlsafe_base64_encode
from comic.models import ComicBook, ComicPage, Setting, ComicStatus, Directory
from comic.util import generate_directory
# Create your tests here.
class ComicBookTests(TestCase):
def setUp(self):
Setting.objects.create(name='BASE_DIR', value=path.join(os.getcwd(), 'comic', 'test'))
User.objects.create_user('test', 'test@test.com', 'test')
user = User.objects.first()
ComicBook.process_comic_book('test1.rar')
book = ComicBook.process_comic_book('test2.rar')
status = ComicStatus(user=user,
comic=book,
last_read_page=2,
unread=False)
status.save()
ComicBook.process_comic_book('test4.rar')
def test_comic_processing(self):
book = ComicBook.objects.get(file_name='test1.rar')
self.assertEqual(book.file_name, 'test1.rar')
page0 = ComicPage.objects.get(Comic=book, index=0)
self.assertEqual(page0.page_file_name, 'img1.jpg')
self.assertEqual(page0.content_type, 'image/jpeg')
page1 = ComicPage.objects.get(Comic=book, index=1)
self.assertEqual(page1.page_file_name, 'img2.png')
self.assertEqual(page1.content_type, 'image/png')
page2 = ComicPage.objects.get(Comic=book, index=2)
self.assertEqual(page2.page_file_name, 'img3.gif')
self.assertEqual(page2.content_type, 'image/gif')
page3 = ComicPage.objects.get(Comic=book, index=3)
self.assertEqual(page3.page_file_name, 'img4.bmp')
self.assertEqual(page3.content_type, 'image/bmp')
self.assertEqual(ComicPage.objects.filter(Comic=book).count(), 4)
def test_page_count(self):
book = ComicBook.objects.get(file_name='test1.rar')
self.assertEqual(book.page_count, 4)
def test_is_last_page(self):
book = ComicBook.objects.get(file_name='test1.rar')
self.assertEqual(book.is_last_page(3), True)
self.assertEqual(book.is_last_page(2), False)
def test_get_image(self):
book = ComicBook.objects.get(file_name='test1.rar')
img, content_type = book.get_image(0)
self.assertEqual(content_type, 'image/jpeg')
self.assertEqual(img.read(), b'img1.jpg')
def test_nav_first_page_with_folder_above(self):
book = ComicBook.objects.get(file_name='test1.rar')
user = User.objects.get(username='test')
nav = book.nav(0, user)
self.assertEqual(nav.next_index, 1)
self.assertEqual(nav.next_path.encode(), urlsafe_base64_encode(book.selector.bytes))
self.assertEqual(nav.prev_index, -1)
self.assertEqual(nav.prev_path, '')
self.assertEqual(nav.cur_index, 0)
self.assertEqual(nav.cur_path.encode(), urlsafe_base64_encode(book.selector.bytes))
self.assertEqual(nav.q_prev_to_directory, True)
self.assertEqual(nav.q_next_to_directory, False)
def test_nav_first_page_with_comic_above(self):
prev_book = ComicBook.objects.get(file_name='test1.rar')
book = ComicBook.objects.get(file_name='test2.rar',
directory__isnull=True)
user = User.objects.get(username='test')
nav = book.nav(0, user)
self.assertEqual(nav.next_index, 1)
self.assertEqual(nav.next_path.encode(), urlsafe_base64_encode(book.selector.bytes))
self.assertEqual(nav.prev_index, 0)
self.assertEqual(nav.prev_path.encode(), urlsafe_base64_encode(prev_book.selector.bytes))
self.assertEqual(nav.cur_index, 0)
self.assertEqual(nav.cur_path.encode(), urlsafe_base64_encode(book.selector.bytes))
self.assertEqual(nav.q_prev_to_directory, False)
self.assertEqual(nav.q_next_to_directory, False)
def test_nav_last_page_with_comic_below(self):
user = User.objects.get(username='test')
book = ComicBook.objects.get(file_name='test1.rar',
directory__isnull=True)
next_book = ComicBook.objects.get(file_name='test2.rar',
directory__isnull=True)
nav = book.nav(3, user)
self.assertEqual(nav.next_index, 2)
self.assertEqual(nav.next_path.encode(), urlsafe_base64_encode(next_book.selector.bytes))
self.assertEqual(nav.prev_index, 2)
self.assertEqual(nav.prev_path.encode(), urlsafe_base64_encode(book.selector.bytes))
self.assertEqual(nav.cur_index, 3)
self.assertEqual(nav.cur_path.encode(), urlsafe_base64_encode(book.selector.bytes))
self.assertEqual(nav.q_prev_to_directory, False)
self.assertEqual(nav.q_next_to_directory, False)
def test_nav_last_page_with_nothing_below(self):
user = User.objects.get(username='test')
book = ComicBook.objects.get(file_name='test4.rar')
nav = book.nav(3, user)
self.assertEqual(nav.next_index, -1)
self.assertEqual(nav.next_path, '')
self.assertEqual(nav.prev_index, 2)
self.assertEqual(nav.prev_path.encode(), urlsafe_base64_encode(book.selector.bytes))
self.assertEqual(nav.cur_index, 3)
self.assertEqual(nav.cur_path.encode(), urlsafe_base64_encode(book.selector.bytes))
self.assertEqual(nav.q_prev_to_directory, False)
self.assertEqual(nav.q_next_to_directory, True)
def test_nav_in_comic(self):
user = User.objects.get(username='test')
book = ComicBook.objects.get(file_name='test1.rar',
directory__isnull=True)
nav = book.nav(1, user)
self.assertEqual(nav.next_index, 2)
self.assertEqual(nav.next_path.encode(), urlsafe_base64_encode(book.selector.bytes))
self.assertEqual(nav.prev_index, 0)
self.assertEqual(nav.prev_path.encode(), urlsafe_base64_encode(book.selector.bytes))
self.assertEqual(nav.cur_index, 1)
self.assertEqual(nav.cur_path.encode(), urlsafe_base64_encode(book.selector.bytes))
self.assertEqual(nav.q_prev_to_directory, False)
self.assertEqual(nav.q_next_to_directory, False)
def test_generate_directory(self):
user = User.objects.get(username='test')
folders = generate_directory(user)
dir1 = folders[0]
self.assertEqual(dir1.name, 'test_folder')
self.assertEqual(dir1.type, 'directory')
self.assertEqual(dir1.icon, 'glyphicon-folder-open')
d = Directory.objects.get(name='test_folder',
parent__isnull=True)
location = '/comic/{0}/'.format(urlsafe_base64_encode(d.selector.bytes).decode())
self.assertEqual(dir1.location, location)
self.assertEqual(dir1.label, '<center><span class="label label-default">Empty</span></center>')
dir2 = folders[1]
self.assertEqual(dir2.name, 'test1.rar')
self.assertEqual(dir2.type, 'book')
self.assertEqual(dir2.icon, 'glyphicon-book')
c = ComicBook.objects.get(file_name='test1.rar',
directory__isnull=True)
location = '/comic/read/{0}/{1}/'.format(urlsafe_base64_encode(c.selector.bytes).decode(),
'0')
self.assertEqual(dir2.location, location)
self.assertEqual(dir2.label, '<center><span class="label label-default">Unread</span></center>')
dir3 = folders[2]
self.assertEqual(dir3.name, 'test2.rar')
self.assertEqual(dir3.type, 'book')
self.assertEqual(dir3.icon, 'glyphicon-book')
c = ComicBook.objects.get(file_name='test2.rar',
directory__isnull=True)
location = '/comic/read/{0}/{1}/'.format(urlsafe_base64_encode(c.selector.bytes).decode(),
'2')
self.assertEqual(dir3.location, location)
self.assertEqual(dir3.label, '<center><span class="label label-primary">3/4</span></center>')
dir4 = folders[3]
self.assertEqual(dir4.name, 'test3.rar')
self.assertEqual(dir4.type, 'book')
self.assertEqual(dir3.icon, 'glyphicon-book')
c = ComicBook.objects.get(file_name='test3.rar',
directory__isnull=True)
location = '/comic/read/{0}/{1}/'.format(urlsafe_base64_encode(c.selector.bytes).decode(),
'0')
self.assertEqual(dir4.location, location)
self.assertEqual(dir4.label, '<center><span class="label label-default">Unread</span></center>')
def test_pages(self):
book = ComicBook.objects.get(file_name='test1.rar')
pages = book.pages
self.assertEqual(pages[0].page_file_name, 'img1.jpg')
self.assertEqual(pages[0].index, 0)
self.assertEqual(pages[1].page_file_name, 'img2.png')
self.assertEqual(pages[1].index, 1)
self.assertEqual(pages[2].page_file_name, 'img3.gif')
self.assertEqual(pages[2].index, 2)
self.assertEqual(pages[3].page_file_name, 'img4.bmp')
self.assertEqual(pages[3].index, 3)
def test_page_name(self):
book = ComicBook.objects.get(file_name='test1.rar')
self.assertEqual(book.page_name(0), 'img1.jpg')
def test_comic_list(self):
c = Client()
response = c.get('/comic/')
self.assertEqual(response.status_code, 302)
c.login(username='test', password='test')
response = c.get('/comic/')
self.assertEqual(response.status_code, 200)
user = User.objects.first()
generate_directory(user)
directory = Directory.objects.first()
response = c.get(f'/comic/{urlsafe_base64_encode(directory.selector.bytes).decode()}/')
self.assertEqual(response.status_code, 200)
def test_comic_list_json(self):
c = Client()
response = c.post('/comic/list_json/')
self.assertEqual(response.status_code, 302)
c.login(username='test', password='test')
response = c.post('/comic/list_json/')
self.assertEqual(response.status_code, 200)
directory = Directory.objects.first()
response = c.post(f'/comic/list_json/{urlsafe_base64_encode(directory.selector.bytes).decode()}/')
self.assertEqual(response.status_code, 200)
def test_recent_comics(self):
c = Client()
response = c.get('/comic/recent/')
self.assertEqual(response.status_code, 302)
c.login(username='test', password='test')
response = c.get('/comic/recent/')
self.assertEqual(response.status_code, 200)
def test_recent_comics_json(self):
c = Client()
response = c.post('/comic/recent/json/')
self.assertEqual(response.status_code, 302)
c.login(username='test', password='test')
generate_directory(User.objects.first())
ComicStatus.objects.all().delete()
req_data = {
'start': '0',
'length': '10',
'search[value]': '',
'order[0][dir]': 'desc'
}
response = c.post('/comic/recent/json/', req_data)
self.assertEqual(response.status_code, 200)
req_data['search[value]'] = 'test1.rar'
response = c.post('/comic/recent/json/', req_data)
self.assertEqual(response.status_code, 200)
self.maxDiff = None
book = ComicBook.objects.get(file_name='test1.rar')
self.assertDictEqual(json.loads(response.content),
{'data': [{'date': book.date_added.strftime('%d/%m/%y-%H:%M'),
'icon': '<span class="glyphicon glyphicon-book"></span>',
'label': '<center><span class="label '
'label-default">Unread</span></center>',
'name': 'test1.rar',
'selector': urlsafe_base64_encode(book.selector.bytes).decode(),
'type': 'book',
'url': f'/comic/read/'
f'{urlsafe_base64_encode(book.selector.bytes).decode()}/0/'}],
'recordsFiltered': 1,
'recordsTotal': 4})
req_data['search[value]'] = ''
req_data['order[0][dir]'] = 3
response = c.post('/comic/recent/json/', req_data)
self.assertListEqual([x['name'] for x in json.loads(response.content)['data']],
['test1.rar', 'test2.rar', 'test4.rar', 'test3.rar'])
req_data['order[0][dir]'] = 2
response = c.post('/comic/recent/json/', req_data)
self.assertListEqual([x['name'] for x in json.loads(response.content)['data']],
['test1.rar', 'test2.rar', 'test4.rar', 'test3.rar'])
def test_comic_edit(self):
c = Client()
book: ComicBook = ComicBook.objects.first()
user = User.objects.get(username='test')
response = c.get('/comic/edit/')
self.assertEqual(response.status_code, 302)
c.login(username='test', password='test')
response = c.get('/comic/edit/')
self.assertEqual(response.status_code, 405)
req_data = {"comic_list_length": 10, "func": "unread", "selected": book.selector_string}
response = c.post('/comic/edit/', req_data)
self.assertEqual(response.status_code, 200)
status = ComicStatus.objects.get(comic=book, user=user)
self.assertEqual(status.last_read_page, 0)
self.assertTrue(status.unread)
self.assertFalse(status.finished)
req_data['func'] = 'read'
response = c.post('/comic/edit/', req_data)
self.assertEqual(response.status_code, 200)
status.refresh_from_db()
self.assertEqual(status.last_read_page, 3)
self.assertFalse(status.unread)
self.assertTrue(status.finished)
req_data['func'] = 'choose'
response = c.post('/comic/edit/', req_data)
self.assertEqual(response.status_code, 200)
status.refresh_from_db()
self.assertEqual(status.last_read_page, 3)
self.assertFalse(status.unread)
self.assertTrue(status.finished)
del req_data['selected']
response = c.post('/comic/edit/', req_data)
self.assertEqual(response.status_code, 200)
def test_account_page(self):
c = Client()
user = User.objects.get(username='test')
self.assertEqual(user.username, 'test')
response = c.get('/comic/account/')
self.assertEqual(response.status_code, 302)
c.login(username='test', password='test')
response = c.get('/comic/account/')
self.assertEqual(response.status_code, 200)

348
comic/tests/test_models.py Normal file
View File

@@ -0,0 +1,348 @@
import json
import os
from os import path
from django.contrib.auth.models import User
from django.test import TestCase, Client
from django.utils.http import urlsafe_base64_encode
from comic.models import ComicBook, ComicPage, Setting, ComicStatus, Directory
from comic.util import generate_directory
class ComicBookTests(TestCase):
def setUp(self):
Setting.objects.create(
name="BASE_DIR", value=path.join(os.getcwd(), "comic", "test")
)
User.objects.create_user("test", "test@test.com", "test")
user = User.objects.first()
ComicBook.process_comic_book("test1.rar")
book = ComicBook.process_comic_book("test2.rar")
status = ComicStatus(user=user, comic=book, last_read_page=2, unread=False)
status.save()
ComicBook.process_comic_book("test4.rar")
def test_comic_processing(self):
book = ComicBook.objects.get(file_name="test1.rar")
self.assertEqual(book.file_name, "test1.rar")
page0 = ComicPage.objects.get(Comic=book, index=0)
self.assertEqual(page0.page_file_name, "img1.jpg")
self.assertEqual(page0.content_type, "image/jpeg")
page1 = ComicPage.objects.get(Comic=book, index=1)
self.assertEqual(page1.page_file_name, "img2.png")
self.assertEqual(page1.content_type, "image/png")
page2 = ComicPage.objects.get(Comic=book, index=2)
self.assertEqual(page2.page_file_name, "img3.gif")
self.assertEqual(page2.content_type, "image/gif")
page3 = ComicPage.objects.get(Comic=book, index=3)
self.assertEqual(page3.page_file_name, "img4.bmp")
self.assertEqual(page3.content_type, "image/bmp")
self.assertEqual(ComicPage.objects.filter(Comic=book).count(), 4)
def test_page_count(self):
book = ComicBook.objects.get(file_name="test1.rar")
self.assertEqual(book.page_count, 4)
def test_is_last_page(self):
book = ComicBook.objects.get(file_name="test1.rar")
self.assertEqual(book.is_last_page(3), True)
self.assertEqual(book.is_last_page(2), False)
def test_get_image(self):
book = ComicBook.objects.get(file_name="test1.rar")
img, content_type = book.get_image(0)
self.assertEqual(content_type, "image/jpeg")
self.assertEqual(img.read(), b"img1.jpg")
def test_nav_first_page_with_folder_above(self):
book = ComicBook.objects.get(file_name="test1.rar")
user = User.objects.get(username="test")
nav = book.nav(0, user)
self.assertEqual(nav.next_index, 1)
self.assertEqual(nav.next_path, urlsafe_base64_encode(book.selector.bytes))
self.assertEqual(nav.prev_index, -1)
self.assertEqual(nav.prev_path, "")
self.assertEqual(nav.cur_index, 0)
self.assertEqual(nav.cur_path, urlsafe_base64_encode(book.selector.bytes))
self.assertEqual(nav.q_prev_to_directory, True)
self.assertEqual(nav.q_next_to_directory, False)
def test_nav_first_page_with_comic_above(self):
prev_book = ComicBook.objects.get(file_name="test1.rar")
book = ComicBook.objects.get(file_name="test2.rar", directory__isnull=True)
user = User.objects.get(username="test")
nav = book.nav(0, user)
self.assertEqual(nav.next_index, 1)
self.assertEqual(nav.next_path, urlsafe_base64_encode(book.selector.bytes))
self.assertEqual(nav.prev_index, 0)
self.assertEqual(nav.prev_path, urlsafe_base64_encode(prev_book.selector.bytes))
self.assertEqual(nav.cur_index, 0)
self.assertEqual(nav.cur_path, urlsafe_base64_encode(book.selector.bytes))
self.assertEqual(nav.q_prev_to_directory, False)
self.assertEqual(nav.q_next_to_directory, False)
def test_nav_last_page_with_comic_below(self):
user = User.objects.get(username="test")
book = ComicBook.objects.get(file_name="test1.rar", directory__isnull=True)
next_book = ComicBook.objects.get(file_name="test2.rar", directory__isnull=True)
nav = book.nav(3, user)
self.assertEqual(nav.next_index, 2)
self.assertEqual(nav.next_path, urlsafe_base64_encode(next_book.selector.bytes))
self.assertEqual(nav.prev_index, 2)
self.assertEqual(nav.prev_path, urlsafe_base64_encode(book.selector.bytes))
self.assertEqual(nav.cur_index, 3)
self.assertEqual(nav.cur_path, urlsafe_base64_encode(book.selector.bytes))
self.assertEqual(nav.q_prev_to_directory, False)
self.assertEqual(nav.q_next_to_directory, False)
def test_nav_last_page_with_nothing_below(self):
user = User.objects.get(username="test")
book = ComicBook.objects.get(file_name="test4.rar")
nav = book.nav(3, user)
self.assertEqual(nav.next_index, -1)
self.assertEqual(nav.next_path, "")
self.assertEqual(nav.prev_index, 2)
self.assertEqual(nav.prev_path, urlsafe_base64_encode(book.selector.bytes))
self.assertEqual(nav.cur_index, 3)
self.assertEqual(nav.cur_path, urlsafe_base64_encode(book.selector.bytes))
self.assertEqual(nav.q_prev_to_directory, False)
self.assertEqual(nav.q_next_to_directory, True)
def test_nav_in_comic(self):
user = User.objects.get(username="test")
book = ComicBook.objects.get(file_name="test1.rar", directory__isnull=True)
nav = book.nav(1, user)
self.assertEqual(nav.next_index, 2)
self.assertEqual(nav.next_path, urlsafe_base64_encode(book.selector.bytes))
self.assertEqual(nav.prev_index, 0)
self.assertEqual(nav.prev_path, urlsafe_base64_encode(book.selector.bytes))
self.assertEqual(nav.cur_index, 1)
self.assertEqual(nav.cur_path, urlsafe_base64_encode(book.selector.bytes))
self.assertEqual(nav.q_prev_to_directory, False)
self.assertEqual(nav.q_next_to_directory, False)
def test_generate_directory(self):
user = User.objects.get(username="test")
folders = generate_directory(user)
dir1 = folders[0]
self.assertEqual(dir1.name, "test_folder")
self.assertEqual(dir1.type, "directory")
self.assertEqual(dir1.icon, "glyphicon-folder-open")
d = Directory.objects.get(name="test_folder", parent__isnull=True)
location = "/comic/{0}/".format(urlsafe_base64_encode(d.selector.bytes))
self.assertEqual(dir1.location, location)
self.assertEqual(
dir1.label,
'<center><span class="label label-default">Empty</span></center>',
)
dir2 = folders[1]
self.assertEqual(dir2.name, "test1.rar")
self.assertEqual(dir2.type, "book")
self.assertEqual(dir2.icon, "glyphicon-book")
c = ComicBook.objects.get(file_name="test1.rar", directory__isnull=True)
location = "/comic/read/{0}/{1}/".format(
urlsafe_base64_encode(c.selector.bytes), "0"
)
self.assertEqual(dir2.location, location)
self.assertEqual(
dir2.label,
'<center><span class="label label-default">Unread</span></center>',
)
dir3 = folders[2]
self.assertEqual(dir3.name, "test2.rar")
self.assertEqual(dir3.type, "book")
self.assertEqual(dir3.icon, "glyphicon-book")
c = ComicBook.objects.get(file_name="test2.rar", directory__isnull=True)
location = "/comic/read/{0}/{1}/".format(
urlsafe_base64_encode(c.selector.bytes), "2"
)
self.assertEqual(dir3.location, location)
self.assertEqual(
dir3.label, '<center><span class="label label-primary">3/4</span></center>'
)
dir4 = folders[3]
self.assertEqual(dir4.name, "test3.rar")
self.assertEqual(dir4.type, "book")
self.assertEqual(dir3.icon, "glyphicon-book")
c = ComicBook.objects.get(file_name="test3.rar", directory__isnull=True)
location = "/comic/read/{0}/{1}/".format(
urlsafe_base64_encode(c.selector.bytes), "0"
)
self.assertEqual(dir4.location, location)
self.assertEqual(
dir4.label,
'<center><span class="label label-default">Unread</span></center>',
)
def test_pages(self):
book = ComicBook.objects.get(file_name="test1.rar")
pages = book.pages
self.assertEqual(pages[0].page_file_name, "img1.jpg")
self.assertEqual(pages[0].index, 0)
self.assertEqual(pages[1].page_file_name, "img2.png")
self.assertEqual(pages[1].index, 1)
self.assertEqual(pages[2].page_file_name, "img3.gif")
self.assertEqual(pages[2].index, 2)
self.assertEqual(pages[3].page_file_name, "img4.bmp")
self.assertEqual(pages[3].index, 3)
def test_page_name(self):
book = ComicBook.objects.get(file_name="test1.rar")
self.assertEqual(book.page_name(0), "img1.jpg")
def test_comic_list(self):
c = Client()
response = c.get("/comic/")
self.assertEqual(response.status_code, 302)
c.login(username="test", password="test")
response = c.get("/comic/")
self.assertEqual(response.status_code, 200)
user = User.objects.first()
generate_directory(user)
directory = Directory.objects.first()
response = c.get(f"/comic/{urlsafe_base64_encode(directory.selector.bytes)}/")
self.assertEqual(response.status_code, 200)
def test_comic_list_json(self):
c = Client()
response = c.post("/comic/list_json/")
self.assertEqual(response.status_code, 302)
c.login(username="test", password="test")
response = c.post("/comic/list_json/")
self.assertEqual(response.status_code, 200)
directory = Directory.objects.first()
response = c.post(
f"/comic/list_json/{urlsafe_base64_encode(directory.selector.bytes)}/"
)
self.assertEqual(response.status_code, 200)
def test_recent_comics(self):
c = Client()
response = c.get("/comic/recent/")
self.assertEqual(response.status_code, 302)
c.login(username="test", password="test")
response = c.get("/comic/recent/")
self.assertEqual(response.status_code, 200)
def test_recent_comics_json(self):
c = Client()
response = c.post("/comic/recent/json/")
self.assertEqual(response.status_code, 302)
c.login(username="test", password="test")
generate_directory(User.objects.first())
ComicStatus.objects.all().delete()
req_data = {
"start": "0",
"length": "10",
"search[value]": "",
"order[0][dir]": "desc",
}
response = c.post("/comic/recent/json/", req_data)
self.assertEqual(response.status_code, 200)
req_data["search[value]"] = "test1.rar"
response = c.post("/comic/recent/json/", req_data)
self.assertEqual(response.status_code, 200)
self.maxDiff = None
book = ComicBook.objects.get(file_name="test1.rar")
self.assertDictEqual(
json.loads(response.content),
{
"data": [
{
"date": book.date_added.strftime("%d/%m/%y-%H:%M"),
"icon": '<span class="glyphicon glyphicon-book"></span>',
"label": '<center><span class="label '
'label-default">Unread</span></center>',
"name": "test1.rar",
"selector": urlsafe_base64_encode(book.selector.bytes),
"type": "book",
"url": f"/comic/read/"
f"{urlsafe_base64_encode(book.selector.bytes)}/0/",
}
],
"recordsFiltered": 1,
"recordsTotal": 4,
},
)
req_data["search[value]"] = ""
req_data["order[0][dir]"] = 3
response = c.post("/comic/recent/json/", req_data)
self.assertListEqual(
[x["name"] for x in json.loads(response.content)["data"]],
["test1.rar", "test2.rar", "test4.rar", "test3.rar"],
)
req_data["order[0][dir]"] = 2
response = c.post("/comic/recent/json/", req_data)
self.assertListEqual(
[x["name"] for x in json.loads(response.content)["data"]],
["test1.rar", "test2.rar", "test4.rar", "test3.rar"],
)
def test_comic_edit(self):
c = Client()
book: ComicBook = ComicBook.objects.first()
user = User.objects.get(username="test")
response = c.get("/comic/edit/")
self.assertEqual(response.status_code, 302)
c.login(username="test", password="test")
response = c.get("/comic/edit/")
self.assertEqual(response.status_code, 405)
req_data = {
"comic_list_length": 10,
"func": "unread",
"selected": book.selector_string,
}
response = c.post("/comic/edit/", req_data)
self.assertEqual(response.status_code, 200)
status = ComicStatus.objects.get(comic=book, user=user)
self.assertEqual(status.last_read_page, 0)
self.assertTrue(status.unread)
self.assertFalse(status.finished)
req_data["func"] = "read"
response = c.post("/comic/edit/", req_data)
self.assertEqual(response.status_code, 200)
status.refresh_from_db()
self.assertEqual(status.last_read_page, 3)
self.assertFalse(status.unread)
self.assertTrue(status.finished)
req_data["func"] = "choose"
response = c.post("/comic/edit/", req_data)
self.assertEqual(response.status_code, 200)
status.refresh_from_db()
self.assertEqual(status.last_read_page, 3)
self.assertFalse(status.unread)
self.assertTrue(status.finished)
del req_data["selected"]
response = c.post("/comic/edit/", req_data)
self.assertEqual(response.status_code, 200)
def test_account_page(self):
c = Client()
user = User.objects.get(username="test")
self.assertEqual(user.username, "test")
response = c.get("/comic/account/")
self.assertEqual(response.status_code, 302)
c.login(username="test", password="test")
response = c.get("/comic/account/")
self.assertEqual(response.status_code, 200)

View File

@@ -56,12 +56,12 @@ def generate_breadcrumbs_from_path(directory=False, book=False):
for item in folders[::-1]: for item in folders[::-1]:
bc = Breadcrumb() bc = Breadcrumb()
bc.name = item.name bc.name = item.name
bc.url = '/comic/' + urlsafe_base64_encode(item.selector.bytes).decode() bc.url = '/comic/' + urlsafe_base64_encode(item.selector.bytes)
output.append(bc) output.append(bc)
if book: if book:
bc = Breadcrumb() bc = Breadcrumb()
bc.name = book.file_name bc.name = book.file_name
bc.url = '/read/' + urlsafe_base64_encode(book.selector.bytes).decode() bc.url = '/read/' + urlsafe_base64_encode(book.selector.bytes)
output.append(bc) output.append(bc)
return output return output
@@ -92,7 +92,7 @@ class DirFile:
def populate_directory(self, directory, user): def populate_directory(self, directory, user):
self.name = directory.name self.name = directory.name
self.icon = 'glyphicon-folder-open' self.icon = 'glyphicon-folder-open'
self.selector = urlsafe_base64_encode(directory.selector.bytes).decode() self.selector = urlsafe_base64_encode(directory.selector.bytes)
self.location = '/comic/{0}/'.format(self.selector) self.location = '/comic/{0}/'.format(self.selector)
self.label = generate_dir_status(user, directory) self.label = generate_dir_status(user, directory)
self.type = 'directory' self.type = 'directory'
@@ -111,7 +111,7 @@ class DirFile:
status, created = ComicStatus.objects.get_or_create(comic=comic, user=user) status, created = ComicStatus.objects.get_or_create(comic=comic, user=user)
if created: if created:
status.save() status.save()
self.selector = urlsafe_base64_encode(comic.selector.bytes).decode() self.selector = urlsafe_base64_encode(comic.selector.bytes)
self.location = '/comic/read/{0}/{1}/'.format(self.selector, self.location = '/comic/read/{0}/{1}/'.format(self.selector,
status.last_read_page) status.last_read_page)
self.label = generate_label(comic, status) self.label = generate_label(comic, status)

View File

@@ -94,7 +94,7 @@ def recent_comics(request):
'breadcrumbs': generate_breadcrumbs_from_menu([('Recent', '/comic/recent/')]), 'breadcrumbs': generate_breadcrumbs_from_menu([('Recent', '/comic/recent/')]),
'menu': Menu(request.user, 'Recent'), 'menu': Menu(request.user, 'Recent'),
'title': 'Recent Comics', 'title': 'Recent Comics',
'feed_id': urlsafe_base64_encode(feed_id.feed_id.bytes).decode(), 'feed_id': urlsafe_base64_encode(feed_id.feed_id.bytes),
}) })
@@ -128,13 +128,13 @@ def recent_comics_json(request):
if created: if created:
status.save() status.save()
response_data['data'].append({ response_data['data'].append({
'selector': urlsafe_base64_encode(book.selector.bytes).decode(), 'selector': urlsafe_base64_encode(book.selector.bytes),
'icon': icon, 'icon': icon,
'type': 'book', 'type': 'book',
'name': book.file_name, 'name': book.file_name,
'date': book.date_added.strftime('%d/%m/%y-%H:%M'), 'date': book.date_added.strftime('%d/%m/%y-%H:%M'),
'label': generate_label(book, status), 'label': generate_label(book, status),
'url': '/comic/read/{0}/{1}/'.format(urlsafe_base64_encode(book.selector.bytes).decode(), 'url': '/comic/read/{0}/{1}/'.format(urlsafe_base64_encode(book.selector.bytes),
status.last_read_page) status.last_read_page)
}) })
return HttpResponse( return HttpResponse(

3
database/.dockerignore Normal file
View File

@@ -0,0 +1,3 @@
*
!docker-entrypoint-initdb.d

8
database/Dockerfile Normal file
View File

@@ -0,0 +1,8 @@
FROM postgres:11.4-alpine
COPY . .
ENTRYPOINT ["docker-entrypoint.sh"]
EXPOSE 5432
CMD ["postgres"]

View File

@@ -0,0 +1,2 @@
CREATE DATABASE cbwebreader;
CREATE DATABASE cbwebreader_test;

33
docker-compose.yml Normal file
View File

@@ -0,0 +1,33 @@
version: '3.7'
services:
app:
build: .
environment:
- DATABASE_URL=postgres://admin:password@database:5432/cbwebreader
- TEST_DATABASE_URL=postgres://admin:password@database:5432/cbwebreader_test
- DJANGO_SETTINGS_MODULE=cbreader.settings.base
links:
- database
depends_on:
- database
ports:
- "8000:8000"
volumes:
- ./cbreader:/src/cbreader
- ./comic:/src/comic
- ./comic_auth:/src/comic_auth
- ${COMIC_BOOK_VOLUME}:/data
command: python manage.py runserver 0.0.0.0:8000
database:
image: postgres:11.4-alpine
ports:
- 5432:5432
volumes:
- /var/lib/postgresql/data
environment:
- POSTGRES_USER=admin
- POSTGRES_PASSWORD=password
- POSTGRES_DB=cbwebreader

View File

@@ -3,7 +3,7 @@ import os
import sys import sys
if __name__ == "__main__": if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cbreader.settings") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cbreader.settings.base")
from django.core.management import execute_from_command_line from django.core.management import execute_from_command_line

3
pytest Normal file
View File

@@ -0,0 +1,3 @@
[pytest]
pep8maxlinelength = 119
python_files = tests.py test_*.py *_tests.py