Commit Graph

472 Commits

Author SHA1 Message Date
Kfir Hadas 87dd95f1e0 Refactor into an app factory [2 of 2] (#322)
* Replace all `from nyaa import app` imports with `app = flask.current_app` (or `from flask import current_app as app` where possible)
* Add a separate config object for top-level and class statements as `nyaa.extensions.config`
Required because those codes don't have app context at the time of evaluation/execution.
* Remove `routes.py` file and register all blueprints in `nyaa/__init__.py`
* Refactor `nyaa/__init__.py` into an app factory
* Update tools
* Update tests (temporary, will be replaced)
2017-08-01 21:02:08 +03:00
Kfir Hadas 0181d6cb33 Prepare for app factory [1 of 2] (#315)
* Move db, assets, debug toolbar and fix_paginate into nyaa.extensions
* Change all `from nyaa import db` imports to `from nyaa.extensions import db`
* Move `nyaa.torrents.create_magnet_from_es_info` context processor into template-utils blueprint
* Fix tools (wrap in `with app.app_context():` where needed)
2017-07-30 20:35:16 +03:00
TheAMM 1dae331156 Completely handle qBittorrent webseeds
Fixes #319

Zero webseeds: empty bytestring
One webseed: bytestring
More than one: a list of bytestrings (as the spec asks for!)
2017-07-30 11:49:13 +03:00
TheAMM 987103b213 Handle qButtorrent empty url-list/webseeds
url-list is supposed to be omitted in case of no webseeds,
but qB will instead use an empty bytestring '' as the value.
This commit makes the validation more lenient regarding url-list.
2017-07-30 11:36:38 +03:00
Anna-Maria Meriniemi 1bc36c5a17 [Schema change] Add webseed support (BEP-19) (#317)
Store webseeds in Trackers table with is_webseed flag
Adjusts torrent creation accordingly
2017-07-30 00:00:39 +03:00
Kfir Hadas 8a4793ffb0 Update Travis (#316)
* Update Travis to Trusty Q2 (they fixed the issue it had before, it works now)
* Fix charset in database creation on Travis to use `utf8mb4_unicode_ci`.
2017-07-29 03:24:05 +03:00
Kfir Hadas b992467dad Apply isort & flake8 (#312)
* Update isort settings
* Apply import sorting (isort) on all files in nyaa/
* Fixed Flake8 errors in nyaa/ (see PR for list)
* Add isort to lint.sh and requirements.txt
2017-07-28 20:01:19 +03:00
Kfir Hadas 99c052c85f Tiny code reformat 2017-07-27 23:29:25 +03:00
Kfir Hadas 42725d4a3c Hotfix Gravatar 2017-07-27 23:17:06 +03:00
Kfir Hadas ab6193d01d Update Gravatar (#313)
* Update help.html with a section about user avatars

* Update Gravatar implementation to use the rating feature
2017-07-27 16:03:13 -04:00
Kfir Hadas 2424639bf9 Refactor routes.py 2017-07-27 14:14:00 +03:00
Kfir Hadas c539795fdc Move the remaining template_global into 'template-utils' blueprint 2017-07-27 14:14:00 +03:00
Kfir Hadas 93f94023d1 Move delete_comment and submit_report into blueprint 2017-07-27 14:14:00 +03:00
Kfir Hadas ef56e54521 Move torrent magnet and torrent download into 'torrents' blueprint 2017-07-27 14:14:00 +03:00
Kfir Hadas 9fef343c1b Move torrent edit and upload into 'torrents' blueprint
Move supporting functions and variables into other files
* nyaa.views.torrents:
  - _create_upload_category_choices
* nyaa.backend:
  - get_category_id_map
2017-07-27 14:14:00 +03:00
Kfir Hadas 9acdd14e81 Move /view/<int:torrent_id> route into 'torrents' blueprint
and update templates.
2017-07-27 14:14:00 +03:00
Kfir Hadas 42535bbdab Move 404 handler into 'main' blueprint 2017-07-27 14:14:00 +03:00
Kfir Hadas 4aac17ff23 Move 'before_request' into 'main' blueprint
Update comment in api_handler with new before_request location
2017-07-27 14:14:00 +03:00
Kfir Hadas eccb0ebdff Move '/' and '/rss' routes into 'main' blueprint
and update templates.
2017-07-27 14:14:00 +03:00
Kfir Hadas f3b923ccca Move template filters and globals into blueprint (#301)
* Move 8 of 9 template filters and globals into a blueprint

* Rename nyaa.filters -> nyaa.template_utils

* Fix import sorting
2017-07-27 14:14:00 +03:00
Kfir Hadas 50529920bd Move /user/activate/<payload> route into users
Move supporting functions as well:
  - get_serializer
  - get_activation_link
2017-07-27 14:14:00 +03:00
Kfir Hadas 0887dde6fc Move /user/<user_name> route into a blueprint
Move supporting functions and variables into other files
* nyaa.utils:
  - cached_function
  - chain_get
* nyaa.search:
  - DEFAULT_MAX_SEARCH_RESULT
  - DEFAULT_PER_PAGE
  - SERACH_PAGINATE_DISPLAY_MSG
  - _generate_query_string
2017-07-27 14:14:00 +03:00
Kfir Hadas 3913d8cea2 Move admin routes into blueprint
and update templates

Routes:
* /reports
* /adminlog
2017-07-27 14:14:00 +03:00
Kfir Hadas f316353176 Move account routes into blueprint (#292)
and update templates,
and remove unused imports

Routes:
* /login
* /logout
* /register
* /profile
2017-07-27 14:14:00 +03:00
Kfir Hadas 911fbc317f Move static routes into a blueprint
and update templates

Routes:
* /help
* /rules
* /xmlns/nyaa
* /about (commented out)
2017-07-27 14:14:00 +03:00
Kfir Hadas 7e16616a5d Remove unused imports 2017-07-27 14:14:00 +03:00
Kfir Hadas de8bd047d5 Apply isort on routes.py 2017-07-27 14:14:00 +03:00
Kfir Hadas e7d304a10b Add basic config for isort 2017-07-27 14:14:00 +03:00
Kfir Hadas 1fa3e6ae46 Add .gitattributes (#310)
This makes life much easier when working on Windows.
And makes sure all of the codes are committed with LF as EOL char.
2017-07-26 18:57:46 +03:00
Arylide dc627bf398 Revert "upload page: use alerts, add alert about rules (#304)"
This reverts commit c5ce99c3f3.
2017-07-24 20:03:58 -07:00
queue c4e7745502 Merge pull request #308 from nyaadevs/bencode-problems
bencode: fix nontermination on empty or malformed input
2017-07-24 21:02:37 -06:00
queue b1d187613a bencode: fix nontermination on empty or malformed input
read(1) returns b'' on EOF, which wasn't checked for in a couple cases,
which could cause empty/truncated input to enter one of the `while True`
loops without hope of exit. programming is hard.
2017-07-24 20:53:48 -06:00
Nicolas F c5ce99c3f3 upload page: use alerts, add alert about rules (#304)
This changes the tracker announce URL message to be one of those
bootstrap alert bubbles, and adds an additional warning which tells
people to read the rules and not upload off-topic crap.
2017-07-24 16:46:39 +03:00
Arylide 6988daf803 HTML Changes 2017-07-22 20:31:50 -07:00
TheAMM a50d39ccaa Improve RSS feed title (show term, torrent/magnet) 2017-07-22 21:54:28 +03:00
TheAMM c31749c1d5 Add link for site-revision vs Github master comparison in footer
Quality of Life. What new features?
2017-07-22 21:41:48 +03:00
TheAMM 6b71cf101e Add simple info in RSS <description>
Allows puny humans to gather some information from the RSS feed
Fixes #299
(... and nobody will know!)
2017-07-22 21:37:53 +03:00
Kfir Hadas fe4ac73ca2 Update torrent download route headers (#298)
- Change disposition from inline to attachment
- Add Content-Length header (by updating `_get_cached_torrent_file`)
2017-07-20 11:00:20 +03:00
Arylide 2e8e548067 Revert "Autofocus on search input box"
This reverts commit c9389cb888.
2017-07-17 17:02:19 -07:00
mreweilk b51045503d Fix banned display on selection box 2017-07-16 14:19:20 -04:00
mreweilk c9389cb888 Autofocus on search input box 2017-07-11 23:28:30 -04:00
Matt Kliewer 708e0da5a1 Add logging to report view and add option to disable (ban) a user for superadmins 2017-07-09 18:07:31 -05:00
Alex Ingram 570ee1225a Fix broken comment CSS 2017-07-08 20:03:14 -05:00
zapzapzap1 1ae577acdb Add links to torrent clients' download pages (#259)
* Add links to torrent client's download pages

* Fuck uTorrent

* Goodbye, uTorrent
2017-07-08 00:10:33 -05:00
Kfir Hadas c466e76471 Fix RFC822 filters + More tests (#257)
* Make rfc822 filters compatible with Windows systems.

.strftime() is relative to the system it's being run on.
UNIX has '%s' for seconds since the EPOCH, Windows doesn't (ValueError).
Solution: use .timestamp() to achieve the same result on both platforms.
This also allows us to drop the float() around it, since it returns a float.

* Start testing filters

* Add placeholders for more tests

* Make 'tests' folder a Python package

Now you can run tests with just `pytest tests`

* Update readme and travis config

* Test timesince()

* Update and organize .gitignore

Deleted: (nothing)
Added: Coverage files, .idea\

* Test filter_truthy, category_name

* Tests for backend.py

* Tests for bencode.py

* Move (empty) test_models.py to tests package

* Tests for utils.py

* Fixes for flattenDict

* Change name to `flatten_dict`
* `newkey` was assigned but never used

* Add a helper class for testing

* Show coverage on Travis

(only Travis for now...)

* Remove IDE

* Use correct assert functions

* Update README.md
2017-07-07 16:14:37 -05:00
Matt Kliewer 45e3834f2a Change portion of welcome message 2017-07-05 13:15:58 -04:00
mreweilk 580471dca9 Merge pull request #284 from sharkykh/fix-torrent-deletion-log
Fix torrent deletion log
2017-07-05 12:10:03 -05:00
Kfir Hadas 3b55af85f0 Fix torrent deletion log
* Fix `url referenced before assignment.`
* Fix every action logged as delete/undelete
2017-07-05 13:48:34 +03:00
Kfir Hadas 9849a2bc14 Fix Travis (#285)
Reverts Trusty build environment version, because 2017Q2 breaks stuff.
2017-07-05 13:41:03 +03:00
mreweilk dd8cb4757e Admin Log 2.0 (#283)
* Admin log added

* Add admin log to top bar

* Fixed some admin log bugs

* Remove comment_id column because comments die when they are killed

* Fix tabs in admin log template

* Fixed sort of admin logs to be created_time desc

* Fix navbar wrapping to a new line

when 992px <= width <= 1200px

* Put reports and admin log in "Admin" dropdown

Applied ./lint.sh fixes

Fixed long lines

* Updated log to be text instead of id based to account for future deletions

* Small fix in log message formatting
2017-07-04 23:13:59 -05:00