mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2024-12-22 02:49:59 +00:00
[templates, config] Add SITE_FLAVOR for selecting nyaa/sukebei, update templates
By default TABLE_PREFIX is derived from flavor. Added back Date column, adjusted column widths
This commit is contained in:
parent
1eaaf08e8a
commit
517d3e8e32
|
@ -20,8 +20,8 @@ CSRF_SESSION_KEY = '***'
|
|||
SECRET_KEY = '***'
|
||||
|
||||
# Prefix for running multiple sites, user table will not be prefixed.
|
||||
# For sukebei, change 'nyaa_' to 'sukebei_'
|
||||
TABLE_PREFIX = 'nyaa_'
|
||||
SITE_FLAVOR = 'nyaa' # 'nyaa' or 'sukebei'
|
||||
TABLE_PREFIX = SITE_FLAVOR + '_'
|
||||
|
||||
# for recaptcha and email verification:
|
||||
# keys for localhost. Change as appropriate when actual domain is registered.
|
||||
|
|
|
@ -7,7 +7,7 @@ db.create_all()
|
|||
|
||||
# Insert categories
|
||||
|
||||
if app.config['TABLE_PREFIX'] == 'nyaa_':
|
||||
if app.config['SITE_FLAVOR'] == 'nyaa':
|
||||
CATEGORIES = [
|
||||
('Anime', ['Anime Music Video', 'English-translated', 'Non-English-translated', 'Raw']),
|
||||
('Audio', ['Lossless', 'Lossy']),
|
||||
|
@ -16,7 +16,7 @@ if app.config['TABLE_PREFIX'] == 'nyaa_':
|
|||
('Pictures', ['Graphics', 'Photos']),
|
||||
('Software', ['Applications', 'Games']),
|
||||
]
|
||||
elif app.config['TABLE_PREFIX'] == 'sukebei_':
|
||||
elif app.config['SITE_FLAVOR'] == 'sukebei':
|
||||
CATEGORIES = [
|
||||
('Art', ['Anime', 'Doujinshi', 'Games', 'Manga', 'Pictures']),
|
||||
('Real Life', ['Photobooks / Pictures', 'Videos']),
|
||||
|
|
|
@ -33,9 +33,10 @@ class TorrentFlags(IntEnum):
|
|||
COMPLETE = 16
|
||||
DELETED = 32
|
||||
|
||||
DB_TABLE_PREFIX = app.config['TABLE_PREFIX']
|
||||
|
||||
class Torrent(db.Model):
|
||||
__tablename__ = app.config['TABLE_PREFIX'] + 'torrents'
|
||||
__tablename__ = DB_TABLE_PREFIX + 'torrents'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
info_hash = db.Column(BinaryType(length=20), unique=True, nullable=False, index=True)
|
||||
|
@ -56,17 +57,17 @@ class Torrent(db.Model):
|
|||
default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False)
|
||||
|
||||
main_category_id = db.Column(db.Integer, db.ForeignKey(
|
||||
app.config['TABLE_PREFIX'] + 'main_categories.id'), nullable=False)
|
||||
DB_TABLE_PREFIX + 'main_categories.id'), nullable=False)
|
||||
sub_category_id = db.Column(db.Integer, nullable=False)
|
||||
redirect = db.Column(db.Integer, db.ForeignKey(
|
||||
app.config['TABLE_PREFIX'] + 'torrents.id'), nullable=True)
|
||||
DB_TABLE_PREFIX + 'torrents.id'), nullable=True)
|
||||
|
||||
__table_args__ = (
|
||||
Index('uploader_flag_idx', 'uploader_id', 'flags'),
|
||||
ForeignKeyConstraint(
|
||||
['main_category_id', 'sub_category_id'],
|
||||
[app.config['TABLE_PREFIX'] + 'sub_categories.main_category_id',
|
||||
app.config['TABLE_PREFIX'] + 'sub_categories.id']
|
||||
[DB_TABLE_PREFIX + 'sub_categories.main_category_id',
|
||||
DB_TABLE_PREFIX + 'sub_categories.id']
|
||||
), {}
|
||||
)
|
||||
|
||||
|
@ -150,32 +151,32 @@ class TorrentNameSearch(FullText, Torrent):
|
|||
|
||||
|
||||
class TorrentFilelist(db.Model):
|
||||
__tablename__ = app.config['TABLE_PREFIX'] + 'torrents_filelist'
|
||||
__tablename__ = DB_TABLE_PREFIX + 'torrents_filelist'
|
||||
__table_args__ = {'mysql_row_format': 'COMPRESSED'}
|
||||
|
||||
torrent_id = db.Column(db.Integer, db.ForeignKey(
|
||||
app.config['TABLE_PREFIX'] + 'torrents.id', ondelete="CASCADE"), primary_key=True)
|
||||
DB_TABLE_PREFIX + 'torrents.id', ondelete="CASCADE"), primary_key=True)
|
||||
filelist_blob = db.Column(MediumBlobType, nullable=True)
|
||||
|
||||
torrent = db.relationship('Torrent', uselist=False, back_populates='filelist')
|
||||
|
||||
|
||||
class TorrentInfo(db.Model):
|
||||
__tablename__ = app.config['TABLE_PREFIX'] + 'torrents_info'
|
||||
__tablename__ = DB_TABLE_PREFIX + 'torrents_info'
|
||||
__table_args__ = {'mysql_row_format': 'COMPRESSED'}
|
||||
|
||||
torrent_id = db.Column(db.Integer, db.ForeignKey(
|
||||
app.config['TABLE_PREFIX'] + 'torrents.id', ondelete="CASCADE"), primary_key=True)
|
||||
DB_TABLE_PREFIX + 'torrents.id', ondelete="CASCADE"), primary_key=True)
|
||||
info_dict = db.Column(MediumBlobType, nullable=True)
|
||||
|
||||
torrent = db.relationship('Torrent', uselist=False, back_populates='info')
|
||||
|
||||
|
||||
class Statistic(db.Model):
|
||||
__tablename__ = app.config['TABLE_PREFIX'] + 'statistics'
|
||||
__tablename__ = DB_TABLE_PREFIX + 'statistics'
|
||||
|
||||
torrent_id = db.Column(db.Integer, db.ForeignKey(
|
||||
app.config['TABLE_PREFIX'] + 'torrents.id', ondelete="CASCADE"), primary_key=True)
|
||||
DB_TABLE_PREFIX + 'torrents.id', ondelete="CASCADE"), primary_key=True)
|
||||
|
||||
seed_count = db.Column(db.Integer, default=0, nullable=False, index=True)
|
||||
leech_count = db.Column(db.Integer, default=0, nullable=False, index=True)
|
||||
|
@ -198,9 +199,9 @@ class Trackers(db.Model):
|
|||
|
||||
|
||||
class TorrentTrackers(db.Model):
|
||||
__tablename__ = app.config['TABLE_PREFIX'] + 'torrent_trackers'
|
||||
__tablename__ = DB_TABLE_PREFIX + 'torrent_trackers'
|
||||
|
||||
torrent_id = db.Column(db.Integer, db.ForeignKey(app.config['TABLE_PREFIX'] + 'torrents.id', ondelete="CASCADE"), primary_key=True)
|
||||
torrent_id = db.Column(db.Integer, db.ForeignKey(DB_TABLE_PREFIX + 'torrents.id', ondelete="CASCADE"), primary_key=True)
|
||||
tracker_id = db.Column(db.Integer, db.ForeignKey('trackers.id', ondelete="CASCADE"), primary_key=True)
|
||||
order = db.Column(db.Integer, nullable=False, index=True)
|
||||
|
||||
|
@ -212,7 +213,7 @@ class TorrentTrackers(db.Model):
|
|||
|
||||
|
||||
class MainCategory(db.Model):
|
||||
__tablename__ = app.config['TABLE_PREFIX'] + 'main_categories'
|
||||
__tablename__ = DB_TABLE_PREFIX + 'main_categories'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
name = db.Column(db.String(length=64), nullable=False)
|
||||
|
@ -233,11 +234,11 @@ class MainCategory(db.Model):
|
|||
|
||||
|
||||
class SubCategory(db.Model):
|
||||
__tablename__ = app.config['TABLE_PREFIX'] + 'sub_categories'
|
||||
__tablename__ = DB_TABLE_PREFIX + 'sub_categories'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
main_category_id = db.Column(db.Integer, db.ForeignKey(
|
||||
app.config['TABLE_PREFIX'] + 'main_categories.id'), primary_key=True)
|
||||
DB_TABLE_PREFIX + 'main_categories.id'), primary_key=True)
|
||||
name = db.Column(db.String(length=64), nullable=False)
|
||||
|
||||
main_category = db.relationship('MainCategory', uselist=False, back_populates='sub_categories')
|
||||
|
|
|
@ -68,9 +68,9 @@
|
|||
</ul>
|
||||
</li>
|
||||
<li><a href="{% if rss_filter %}{{ url_for('home', page='rss', **rss_filter) }}{% else %}{{ url_for('home', page='rss') }}{% endif %}">RSS</a></li>
|
||||
{% if config.TABLE_PREFIX == 'nyaa_' %}
|
||||
{% if config.SITE_FLAVOR == 'nyaa' %}
|
||||
<li><a href="https://sukebei.nyaa.si/">R-18</a></li>
|
||||
{% elif config.TABLE_PREFIX == 'sukebei_' %}
|
||||
{% elif config.SITE_FLAVOR == 'sukebei' %}
|
||||
<li><a href="https://nyaa.si/">SFW</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
@ -153,115 +153,53 @@
|
|||
</select>
|
||||
</div>
|
||||
<div class="input-group-btn" id="navFilter">
|
||||
{% if config.TABLE_PREFIX == 'nyaa_' %}
|
||||
<select class="selectpicker show-tick" title="Category" data-width="170px" name="c">
|
||||
<option value="0_0" title="Show all" {% if search is defined and search["category"] == "0_0" %}selected{% else %}selected{% endif %}>
|
||||
Show all
|
||||
</option>
|
||||
<option value="1_0" title="Anime" {% if search is defined and search["category"] == "1_0" %}selected{% endif %}>
|
||||
Anime
|
||||
</option>
|
||||
<option value="1_1" title="Anime - AMV" {% if search is defined and search["category"] == "1_1" %}selected{% endif %}>
|
||||
- Anime Music Video
|
||||
</option>
|
||||
<option value="1_2" title="Anime - English" {% if search is defined and search["category"] == "1_2" %}selected{% endif %}>
|
||||
- English-translated
|
||||
</option>
|
||||
<option value="1_3" title="Anime - Non-English" {% if search is defined and search["category"] == "1_3" %}selected{% endif %}>
|
||||
- Non-English-translated
|
||||
</option>
|
||||
<option value="1_4" title="Anime - Raw" {% if search is defined and search["category"] == "1_4" %}selected{% endif %}>
|
||||
- Raw
|
||||
</option>
|
||||
<option value="2_0" title="Audio" {% if search is defined and search["category"] == "2_0" %}selected{% endif %}>
|
||||
Audio
|
||||
</option>
|
||||
<option value="2_1" title="Audio - Lossless" {% if search is defined and search["category"] == "2_1" %}selected{% endif %}>
|
||||
- Lossless
|
||||
</option>
|
||||
<option value="2_2" title="Audio - Lossy" {% if search is defined and search["category"] == "2_2" %}selected{% endif %}>
|
||||
- Lossy
|
||||
</option>
|
||||
<option value="3_0" title="Literature" {% if search is defined and search["category"] == "3_0" %}selected{% endif %}>
|
||||
Literature
|
||||
</option>
|
||||
<option value="3_1" title="Literature - English" {% if search is defined and search["category"] == "3_1" %}selected{% endif %}>
|
||||
- English-translated
|
||||
</option>
|
||||
<option value="3_2" title="Literature - Non-English" {% if search is defined and search["category"] == "3_2" %}selected{% endif %}>
|
||||
- Non-English-translated
|
||||
</option>
|
||||
<option value="3_3" title="Literature - Raw" {% if search is defined and search["category"] == "3_3" %}selected{% endif %}>
|
||||
- Raw
|
||||
</option>
|
||||
<option value="4_0" title="Live Action" {% if search is defined and search["category"] == "4_0" %}selected{% endif %}>
|
||||
Live Action
|
||||
</option>
|
||||
<option value="4_1" title="Live Action - English" {% if search is defined and search["category"] == "4_1" %}selected{% endif %}>
|
||||
- English-translated
|
||||
</option>
|
||||
<option value="4_2" title="Live Action - Idol/PV" {% if search is defined and search["category"] == "4_2" %}selected{% endif %}>
|
||||
- Idol/Promotional Video
|
||||
</option>
|
||||
<option value="4_3" title="Live Action - Non-English" {% if search is defined and search["category"] == "4_3" %}selected{% endif %}>
|
||||
- Non-English-translated
|
||||
</option>
|
||||
<option value="4_4" title="Live Action - Raw" {% if search is defined and search["category"] == "4_4" %}selected{% endif %}>
|
||||
- Raw
|
||||
</option>
|
||||
<option value="5_0" title="Pictures" {% if search is defined and search["category"] == "5_0" %}selected{% endif %}>
|
||||
Pictures
|
||||
</option>
|
||||
<option value="5_1" title="Pictures - Graphics" {% if search is defined and search["category"] == "5_1" %}selected{% endif %}>
|
||||
- Graphics
|
||||
</option>
|
||||
<option value="5_2" title="Pictures - Photos" {% if search is defined and search["category"] == "5_2" %}selected{% endif %}>
|
||||
- Photos
|
||||
</option>
|
||||
<option value="6_0" title="Software" {% if search is defined and search["category"] == "6_0" %}selected{% endif %}>
|
||||
Software
|
||||
</option>
|
||||
<option value="6_1" title="Software - Apps" {% if search is defined and search["category"] == "6_1" %}selected{% endif %}>
|
||||
- Applications
|
||||
</option>
|
||||
<option value="6_2" title="Software - Games" {% if search is defined and search["category"] == "6_2" %}selected{% endif %}>
|
||||
- Games
|
||||
</option>
|
||||
</select>
|
||||
{% elif config.TABLE_PREFIX == 'sukebei_' %}
|
||||
<select class="selectpicker show-tick" title="Category" data-width="170px" name="c">
|
||||
<option value="0_0" title="Show all" {% if search is defined and search["category"] == "0_0" %}selected{% else %}selected{% endif %}>
|
||||
Show all
|
||||
</option>
|
||||
<option value="1_0" title="Art" {% if search is defined and search["category"] == "1_0" %}selected{% endif %}>
|
||||
Art
|
||||
</option>
|
||||
<option value="1_1" title="Art - Anime" {% if search is defined and search["category"] == "1_1" %}selected{% endif %}>
|
||||
- Anime
|
||||
</option>
|
||||
<option value="1_2" title="Art - Doujinshi" {% if search is defined and search["category"] == "1_2" %}selected{% endif %}>
|
||||
- Doujinshi
|
||||
</option>
|
||||
<option value="1_3" title="Art - Games" {% if search is defined and search["category"] == "1_3" %}selected{% endif %}>
|
||||
- Games
|
||||
</option>
|
||||
<option value="1_4" title="Art - Manga" {% if search is defined and search["category"] == "1_4" %}selected{% endif %}>
|
||||
- Manga
|
||||
</option>
|
||||
<option value="1_5" title="Art - Pictures" {% if search is defined and search["category"] == "1_5" %}selected{% endif %}>
|
||||
- Pictures
|
||||
</option>
|
||||
<option value="2_0" title="Real Life" {% if search is defined and search["category"] == "2_0" %}selected{% endif %}>
|
||||
Real Life
|
||||
</option>
|
||||
<option value="2_1" title="Real Life - Pictures" {% if search is defined and search["category"] == "2_1" %}selected{% endif %}>
|
||||
- Photobooks and Pictures
|
||||
</option>
|
||||
<option value="2_2" title="Real Life - Videos" {% if search is defined and search["category"] == "2_2" %}selected{% endif %}>
|
||||
- Videos
|
||||
</option>
|
||||
</select>
|
||||
{% set nyaa_cats = [('1_0', 'Anime', 'Anime'),
|
||||
('1_1', '- Anime Music Video', 'Anime - AMV'),
|
||||
('1_2', '- English-translated', 'Anime - English'),
|
||||
('1_3', '- Non-English-translated', 'Anime - Non-English'),
|
||||
('1_4', '- Raw', 'Anime - Raw'),
|
||||
('2_0', 'Audio', 'Audio'),
|
||||
('2_1', '- Lossless', 'Audio - Lossless'),
|
||||
('2_2', '- Lossy', 'Audio - Lossy'),
|
||||
('3_0', 'Literature', 'Literature'),
|
||||
('3_1', '- English-translated', 'Literature - English'),
|
||||
('3_2', '- Non-English-translated', 'Literature - Non-English'),
|
||||
('3_3', '- Raw', 'Literature - Raw'),
|
||||
('4_0', 'Live Action', 'Live Action'),
|
||||
('4_1', '- English-translated', 'Live Action - English'),
|
||||
('4_2', '- Idol/Promotional Video', 'Live Action - Idol/PV'),
|
||||
('4_3', '- Non-English-translated', 'Live Action - Non-English'),
|
||||
('4_4', '- Raw', 'Live Action - Raw'),
|
||||
('5_0', 'Pictures', 'Pictures'),
|
||||
('5_1', '- Graphics', 'Pictures - Graphics'),
|
||||
('5_2', '- Photos', 'Pictures - Photos'),
|
||||
('6_0', 'Software', 'Software'),
|
||||
('6_1', '- Applications', 'Software - Apps'),
|
||||
('6_2', '- Games', 'Software - Games')] %}
|
||||
{% set suke_cats = [('1_0', 'Art', 'Art'),
|
||||
('1_1', '- Anime', 'Art - Anime'),
|
||||
('1_2', '- Doujinshi', 'Art - Doujinshi'),
|
||||
('1_3', '- Games', 'Art - Games'),
|
||||
('1_4', '- Manga', 'Art - Manga'),
|
||||
('1_5', '- Pictures', 'Art - Pictures'),
|
||||
('2_0', 'Real Life', 'Real Life'),
|
||||
('2_1', '- Photobooks and Pictures', 'Real Life - Pictures'),
|
||||
('2_2', '- Videos', 'Real Life - Videos')] %}
|
||||
{% if config.SITE_FLAVOR == 'nyaa' %}
|
||||
{% set used_cats = nyaa_cats %}
|
||||
{% elif config.SITE_FLAVOR == 'sukebei' %}
|
||||
{% set used_cats = suke_cats %}
|
||||
{% endif %}
|
||||
<select class="selectpicker show-tick" title="Category" data-width="170px" name="c">
|
||||
<option value="0_0" title="Show all" {% if search is defined and search["category"] == "0_0" %}selected{% else %}selected{% endif %}>
|
||||
Show all
|
||||
</option>
|
||||
{% for cat_id, cat_name, cat_title in used_cats %}
|
||||
<option value="{{ cat_id }}" title="{{ cat_title }}" {% if search is defined and search.category == cat_id %}selected{% endif %}>
|
||||
{{ cat_name }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="input-group-btn">
|
||||
<button class="btn btn-primary" type="submit">
|
||||
|
|
|
@ -25,16 +25,19 @@
|
|||
{% call render_column_header("width:100px;", center_text=True, sort_key="size") %}
|
||||
<div>Size</div>
|
||||
{% endcall %}
|
||||
{% call render_column_header("width:140px;", center_text=True, sort_key="id", header_title="In UTC") %}
|
||||
<div>Date</div>
|
||||
{% endcall %}
|
||||
|
||||
{% if config.ENABLE_SHOW_STATS %}
|
||||
{% call render_column_header("width:65px;", center_text=True, sort_key="seeders", header_title="Seeds") %}
|
||||
{% call render_column_header("width:50px;", center_text=True, sort_key="seeders", header_title="Seeds") %}
|
||||
<i class="fa fa-arrow-up" aria-hidden="true"></i>
|
||||
{% endcall %}
|
||||
{% call render_column_header("width:65px;", center_text=True, sort_key="leechers", header_title="Leeches") %}
|
||||
{% call render_column_header("width:50px;", center_text=True, sort_key="leechers", header_title="Leeches") %}
|
||||
<i class="fa fa-arrow-down" aria-hidden="true"></i>
|
||||
|
||||
{% endcall %}
|
||||
{% call render_column_header("width:65px;", center_text=True, sort_key="downloads", header_title="Completed downloads") %}
|
||||
{% call render_column_header("width:50px;", center_text=True, sort_key="downloads", header_title="Completed downloads") %}
|
||||
<i class="fa fa-check" aria-hidden="true"></i>
|
||||
{% endcall %}
|
||||
|
||||
|
@ -44,23 +47,17 @@
|
|||
<tbody>
|
||||
{% for torrent in torrent_query.items %}
|
||||
<tr class="{% if torrent.deleted %}deleted{% elif torrent.hidden %}warning{% elif torrent.remake %}danger{% elif torrent.trusted %}success{% else %}default{% endif %}">
|
||||
{% if config.TABLE_PREFIX == 'nyaa_' %}
|
||||
{% set cat_id = (torrent.main_category.id|string) + '_' + (torrent.sub_category.id|string) %}
|
||||
{% set icon_dir = config.SITE_FLAVOR %}
|
||||
<td style="padding:0 4px;">
|
||||
<a href="/?c={{ torrent.main_category.id }}_{{ torrent.sub_category.id }}">
|
||||
<img src="/static/img/icons/nyaa/{{ torrent.main_category.id }}_{{ torrent.sub_category.id }}.png">
|
||||
</a>
|
||||
</td>
|
||||
{% elif config.TABLE_PREFIX == 'sukebei_' %}
|
||||
<td style="padding:0 4px;">
|
||||
<a href="/?c={{ torrent.main_category.id }}_{{ torrent.sub_category.id }}">
|
||||
<img src="/static/img/icons/sukebei/{{ torrent.main_category.id }}_{{ torrent.sub_category.id }}.png">
|
||||
</a>
|
||||
</td>
|
||||
{% endif %}
|
||||
<a href="/?c={{ cat_id }}">
|
||||
<img src="/static/img/icons/{{ icon_dir }}/{{ cat_id }}.png">
|
||||
</a>
|
||||
</td>
|
||||
<td><a href="/view/{{ torrent.id }}">{{ torrent.display_name | escape }}</a></td>
|
||||
<td style="white-space: nowrap;text-align: center;">{% if torrent.has_torrent %}<a href="/view/{{ torrent.id }}/torrent"><i class="fa fa-fw fa-download"></i></a> {% endif %}<a href="{{ torrent.magnet_uri }}"><i class="fa fa-fw fa-magnet"></i></a></td>
|
||||
<td>{{ torrent.filesize | filesizeformat(True) }}</td>
|
||||
{# <td>{{ torrent.created_time.strftime('%Y-%m-%d %H:%M') }}</td> #}
|
||||
<td>{{ torrent.created_time.strftime('%Y-%m-%d %H:%M') }}</td>
|
||||
{% if config.ENABLE_SHOW_STATS %}
|
||||
<td class="text-center" style="color: green;">{{ torrent.stats.seed_count }}</td>
|
||||
<td class="text-center" style="color: red;">{{ torrent.stats.leech_count }}</td>
|
||||
|
|
Loading…
Reference in a new issue