2019-02-08 21:11:44 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
# This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)
|
|
|
|
# Copyright (C) 2018-2019 OzzieIsaacs, cervinko, jkrehm, bodybybuddha, ok11,
|
|
|
|
# andy29485, idalin, Kyosfonica, wuqi, Kennyl, lemmsh,
|
|
|
|
# falgh1, grunjol, csitko, ytils, xybydy, trasba, vrabe,
|
|
|
|
# ruben-herold, marblepebble, JackED42, SiphonSquirrel,
|
|
|
|
# apetresc, nanu-c, mutschler
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
import sys
|
2019-12-15 14:33:38 +02:00
|
|
|
import platform
|
2019-07-14 19:38:07 +02:00
|
|
|
import sqlite3
|
2024-11-18 19:00:19 +02:00
|
|
|
from importlib.metadata import metadata
|
2019-07-14 19:38:07 +02:00
|
|
|
from collections import OrderedDict
|
2019-02-08 21:11:44 +02:00
|
|
|
|
2022-01-31 20:19:25 +02:00
|
|
|
import flask
|
2019-06-06 17:10:22 +02:00
|
|
|
from flask_babel import gettext as _
|
|
|
|
|
2022-02-12 13:12:30 +02:00
|
|
|
from . import db, calibre_db, converter, uploader, constants, dep_check
|
2020-12-12 12:23:17 +02:00
|
|
|
from .render_template import render_title_template
|
2024-07-14 16:24:07 +02:00
|
|
|
from .usermanagement import user_login_required
|
2021-11-06 18:17:00 +02:00
|
|
|
|
2019-08-06 19:53:24 +02:00
|
|
|
|
2019-07-14 19:38:07 +02:00
|
|
|
about = flask.Blueprint('about', __name__)
|
|
|
|
|
2022-05-01 12:36:35 +02:00
|
|
|
modules = dict()
|
|
|
|
req = dep_check.load_dependencies(False)
|
|
|
|
opt = dep_check.load_dependencies(True)
|
2021-11-06 18:17:00 +02:00
|
|
|
for i in (req + opt):
|
2022-05-01 12:36:35 +02:00
|
|
|
modules[i[1]] = i[0]
|
2024-11-18 19:00:19 +02:00
|
|
|
modules['Jinja2'] = metadata("jinja2")["Version"]
|
2024-09-16 17:21:39 +02:00
|
|
|
if sys.version_info < (3, 12):
|
2024-08-05 20:27:21 +02:00
|
|
|
modules['pySqlite'] = sqlite3.version
|
2022-05-01 12:36:35 +02:00
|
|
|
modules['SQLite'] = sqlite3.sqlite_version
|
|
|
|
sorted_modules = OrderedDict((sorted(modules.items(), key=lambda x: x[0].casefold())))
|
2021-11-06 18:17:00 +02:00
|
|
|
|
2022-02-12 12:20:09 +02:00
|
|
|
|
2022-05-01 12:36:35 +02:00
|
|
|
def collect_stats():
|
|
|
|
if constants.NIGHTLY_VERSION[0] == "$Format:%H$":
|
2024-09-07 20:07:45 +02:00
|
|
|
calibre_web_version = constants.STABLE_VERSION.replace("b", " Beta")
|
2022-05-01 12:36:35 +02:00
|
|
|
else:
|
2024-09-07 20:07:45 +02:00
|
|
|
calibre_web_version = (constants.STABLE_VERSION.replace("b", " Beta") + ' - '
|
2022-05-01 12:36:35 +02:00
|
|
|
+ constants.NIGHTLY_VERSION[0].replace('%', '%%') + ' - '
|
|
|
|
+ constants.NIGHTLY_VERSION[1].replace('%', '%%'))
|
2019-02-08 21:11:44 +02:00
|
|
|
|
2022-05-01 12:36:35 +02:00
|
|
|
if getattr(sys, 'frozen', False):
|
|
|
|
calibre_web_version += " - Exe-Version"
|
|
|
|
elif constants.HOME_CONFIG:
|
|
|
|
calibre_web_version += " - pyPi"
|
2022-01-31 20:19:25 +02:00
|
|
|
|
2022-05-01 12:36:35 +02:00
|
|
|
_VERSIONS = {'Calibre Web': calibre_web_version}
|
|
|
|
_VERSIONS.update(OrderedDict(
|
|
|
|
Python=sys.version,
|
|
|
|
Platform='{0[0]} {0[2]} {0[3]} {0[4]} {0[5]}'.format(platform.uname()),
|
|
|
|
))
|
|
|
|
_VERSIONS.update(uploader.get_magick_version())
|
|
|
|
_VERSIONS['Unrar'] = converter.get_unrar_version()
|
|
|
|
_VERSIONS['Ebook converter'] = converter.get_calibre_version()
|
|
|
|
_VERSIONS['Kepubify'] = converter.get_kepubify_version()
|
|
|
|
_VERSIONS.update(sorted_modules)
|
2020-11-15 15:19:25 +02:00
|
|
|
return _VERSIONS
|
|
|
|
|
2022-01-31 20:19:25 +02:00
|
|
|
|
2019-02-08 21:11:44 +02:00
|
|
|
@about.route("/stats")
|
2024-07-14 16:24:07 +02:00
|
|
|
@user_login_required
|
2019-02-08 21:11:44 +02:00
|
|
|
def stats():
|
2020-05-21 18:16:11 +02:00
|
|
|
counter = calibre_db.session.query(db.Books).count()
|
|
|
|
authors = calibre_db.session.query(db.Authors).count()
|
2022-05-01 12:36:35 +02:00
|
|
|
categories = calibre_db.session.query(db.Tags).count()
|
2020-05-21 18:16:11 +02:00
|
|
|
series = calibre_db.session.query(db.Series).count()
|
2020-11-15 15:19:25 +02:00
|
|
|
return render_title_template('stats.html', bookcounter=counter, authorcounter=authors, versions=collect_stats(),
|
2023-01-21 16:19:59 +02:00
|
|
|
categorycounter=categories, seriecounter=series, title=_("Statistics"), page="stat")
|