Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Graphe des révisions

190 commits

Auteur SHA1 Message Date
akuma06
1316062c9a Refactored user forms struct + tests 2017-07-01 19:44:36 +02:00
akuma06
b142ee75a4 The validator work
Tests are passed
2017-07-01 02:59:39 +02:00
akuma06
946f02d0fc Use of validator pkg now
Use of validator pkg replacing modelHelper.

ValidateForm adds translated errors in messages context. To know if we have errors, we have to call messages.HasErrors() after the validation check.

New translation strings for some field check. I didn't add every tag as an error since it seems we won't use them (isbn, ...). This would overload the translation files that are already big.
2017-07-01 01:25:11 +02:00
PantsuDev
ba1f48b08c Fix typo'd variable 2017-06-29 21:20:52 +10:00
PantsuDev
e139f5e4db Fix most compiler errors 2017-06-29 21:15:23 +10:00
akuma06
210bf84d13 Forgot to commitsave these files 2017-06-29 01:06:30 +02:00
akuma06
2646bc2db8 This is a prelimenary work
Showing how we can remove services, preventing cyclic imports and lessing the number of imports.
Now db is in models. Db and models are highly tightened, according to go standards, you should put them in the same package.
In models, there are folders separating the different methods used to modify the models. For example, if you want to create a user, you have to use /models (for the user struct) and /models/user (for creating a user.
However, if you want to delete a torrent, you just have to import /models and do torrent.Delete(definitely bool).

By the way packages in models are the plural name of a model. For example, you have torrent.go for a torrent model and its package torrents for db stuff related functions (Find, Create, Some helpers)
2017-06-29 00:44:07 +02:00
akuma06
5991a21818 First batch of changes for the refactor (#1078)
* First batch of changes for the refactor

Added the support of gin in routes and other services/utils
Begining implementation of JetHTML

* Remove os folder

* Move scrapers to own repo

* Second batch of changes

All .jet.html are the working templates.
You can now test this PR, the index Page and upload works. If you want to complete the other html templates, you're welcome

* Move captcha to util

* Move uploadService to utils

* Use govalidator instead of regex

* Third batch of changes

All the front end should as previously.
I also fixed some minor things unrelated to the refactor (mostly style issues on static pages)
Now errors can be accessed by importing the "errors" helpers and using the `yield errors(name="xxx")` command in templates.
Same for infos.
Templates are now more hierarchized with a base template "base.jet.html" which is extended depending on the context in "index_site" or "index_admin" layouts. Those layouts are extended than in every pages.
Other helpers are captcha to render a captcha `yield captcha(captchaid="xxx")`
And also csrf, with the command `yield csrf_field()`
To translate, you don't have anymore to do `call $.T "xxx"`, you just have to do `T("xxx")`.

Pages for the website part are in folders in the folder "templates/site". Pages for the admin part are in "templates/admin". Layouts are separated in "templates/layouts". Helpers and menu are in "templates/layouts/helpers" and "templates/layouts/menu". Error pages should be put in "templates/errors"

* Added test on templates

When adding a new template, you have to tell to template_test.go, the context of the new template (if it doesn't use the common context)

* Panel admin works

Now the templating part should work. The PR can now be fully tested.

I think we should push the templating PR  and do the routes/controllers/removal of services in another branch. So we know that this one is functional

* Updated dependencies

* Fixed test for modelhelper

* Fix testing for commentlist

* Fix travis :')

* Just renamed router and removed network

* Applying same SEO fix

* Update form_validator.go

* Added back regexp package
2017-06-28 21:42:38 +10:00
PantsuDev
496e1d4ba4 Start refactor 2017-06-25 23:27:05 +10:00
yiiT
b59b5c092b Add /feed/magnet which displays the magnet instead of the torrent link (#1069)
* Add /feed/magnet which displays the magnet instead of the torrent link
2017-06-24 19:45:56 -05:00
PantsuDev
cb13bcded9 Change max to limit 2017-06-22 11:21:30 +10:00
akuma06
eaf4e23266 Fix hidden on User Profile (#1039)
When a user had hidden torrents, they were still listed on his user page even if it's not the actual user who is viewing it.
That's why I added a new function for searching which filter out hidden torrents.
Now when a user go to his own page (or a moderator), he can see all his torrents.
However if another person visit the page, only non hidden torrents will be listed.
I added the hidden parameter in ES database, it permits also to use the search instead of SQL when listing torrents on the user page. Less load time, go with the idea that we should use ES everywhere when needed.
2017-06-21 11:58:54 +10:00
PantsuDev
757b276ffa Hopefully fix torznab api 2017-06-20 17:10:47 +10:00
akuma06
2e53fa2603 Added tests on some package + simplified a little modelHelper (#1026)
Test on:
* Categories
* Util
* modelHelper

Added hum_name on PasswordConfirm
Removed Zlib <= No code is using it anymore
modelHelper now show translated errors
New Translation strings
2017-06-20 10:06:07 +10:00
akuma06
9307087024 Refine form linked up & edited buildversion to commit hash (#1025)
Added the use of the new search form made by @kipukun
Buildversion are now commit hash. Please read the readme for new build
command (or just build using package.sh).
2017-06-20 10:06:01 +10:00
akuma06
13a15b3b2c Removing reparsing of pagenum in ES 2017-06-18 01:39:11 +02:00
akuma06
fb64d13e29 Should fix no result found by ES 2017-06-18 01:23:12 +02:00
akuma06
b4add6054a Fix for cat=5070 2017-06-18 01:19:46 +02:00
akuma06
ad3a44e2f8 Torznab fix (#1019)
* Torznab fix

Added multiple category search
Fixed issues in #1017
Now category from searchParam & torrentParam are arrays of category
New Struct Categories

* Fix travis error due to database code
2017-06-18 08:30:12 +10:00
akuma06
5e65b20c89 Added two new functions for @kipukun
GetCategory categoryID  keepParent (eg: GetCategory "3" true <= for all
anime)
Modified
GetCategories to (keepParent, keepChild) (eg: GetCategories true true <=
for every catagories)
2017-06-17 04:24:30 +02:00
akuma06
cbcbeef256 Forgot subcat have attr not tags 2017-06-15 21:55:55 +02:00
akuma06
fb2c69a612 Torznab caps compatible 2017-06-15 21:54:06 +02:00
akuma06
c1270e549a EZTV and Torznab support
EZTV is fully supported afaik and can be accessed to /feed/eztv
Torznab is supported on display, miss t=caps route and can be accessed
to /feed/torznab
2017-06-15 15:43:18 +02:00
Rin Ikeda
50b4b2387e Small typo fix 2017-06-14 14:27:05 +03:00
akuma06
0662b3fb41 Audio captcha (#995)
* Megacheck friendly

applied megacheck and fixed some unwanted behaviour (markdown)

* Forgot this file

* Captcha Audio

Should make #993 happen

* Fix style issue in  comments

* Added margin auto and width on input

* Moved width on captcha div instead

* fixing width issue with audio tag

* Captcha final style fix
2017-06-14 20:10:03 +10:00
akuma06
63fbbaa491 gosimple friendly 2017-06-14 09:20:42 +02:00
akuma06
05e3391cf9 Should fix #991 2017-06-14 09:00:50 +02:00
Ramon Dantas
dac4b5baf5 Add MinSize and MaxSize search parameters (#990)
Also removed some duplicate code from the search code, using the
methods in common/search.go.
2017-06-13 21:31:11 +10:00
Ramon Dantas
d8e17478f8 Country flags (language) for torrents. (#970)
* Add flags for torrents

Add a new field, .Language, to the Torrent model, and a new package,
torrentLanguages, which maps languages to flags. Added also a flag icon pack
from googlei18n/region-flags, with (mostly) public domain flags from Wikipedia.

* Optimize flags

* Use FlagSprites CSS instead of .png files

* Only use flags for languages we support

* Add test for CSS flags

Ensure that we have all the flags for the languages we support.

* Add AdditionalLanguages field to config

This allows us to support additional languages for new uploaded torrents,
even if we have no translation for it.

* Minor CSS fix

* Add "other" and "multiple" torrent languages

Also removed the TorrentLanguage struct, as it wasn't much useful.

* Fix test

* Add colspan=2 to category when language is empty

Also hide the language column if empty.

* Add lang field to search.

Hopefully it works with Elasticsearch as well, but I haven't tested
(lol Java)

* Add language field to ES index and settings

* Add language column to JS template

* Add keyword type to language ES field

* Remove 'raw' from keyword

* Set "simple" analyzer on language

* Document .Language field on Torrent model
2017-06-12 09:14:26 +10:00
akuma06
ee0e611d11 Replaced hardcoded message errors in email validation
Added some translation string
Improved the way the emails and usernames are checked (less conditions)
Minor fix on clear error functions
2017-06-10 00:58:34 +02:00
sfan5
576e11bf42 Fix both error message + HTML showing on home page
Also remove util.SendError since it's not very useful.
2017-06-06 16:24:15 +02:00
akuma06
5068d83402 Merge branch 'dev' into custom-mascot 2017-06-06 00:38:20 +02:00
ElegantMonkey
e10070b2a9 Add customizable mascot by URL.
Add a new setting for customizable mascots, with a new User field
MascotURL, and a corresponding cookie setting.
2017-06-05 11:32:48 -03:00
tomleb
e60eceba63 Reduce number of queries, update systemd unit service (#925)
* Update/add systemd services

* Avoid roundtrip back to postgresql when doing ES search

* Use only one ES client
2017-06-05 11:33:02 +10:00
MCManuelLP
f6b14e34c1 Url encode the display name
fixes #901
2017-06-04 10:24:27 +02:00
Atvaark
99ad76f76f Add web address config (#888)
* This allows changing the nyaa, sukebei and status URL via config.
  Previously only the nyaa address was configurable
* This helps testing changes locally without having to set up
  a TLS terminating proxy
* Also refactored uses of hardcoded URLs in the html templates
  The html templates will now also use the configured urls
2017-06-03 11:45:24 +10:00
akuma06
61a0ab0bc3 Added also a maxage field
Now you can provide ?maxage=nb_days to get the torrents from the last
nb_days days
2017-06-02 16:25:45 +02:00
akuma06
f41f2c3a25 Field Date Filter
* Search can be filtered out with ?fromDate=2017-05-01 and
?toDate=2017-05-12
2017-06-02 16:10:31 +02:00
akuma06
e116b30b40 Better handle of test files
After some thoughts, it is better to use the config from config files
than default ones
2017-05-31 10:49:01 +02:00
akuma06
5376b9e271 New config files (#854)
* New config files

As decided, config files are parsed at runtime.
I decided to go for YAML config files because there can be comments in
it.
There are 2 files:
* config/default_config.yml <= which shouldn't be edited unless we add a
config parameter
* config/config.yml <= which is the user-defined config. This file
shouldn't be commited

Changed every call to config.XXX to config.Conf.XXX (look to the new
stucture of config in config/types.go)

Of course, putting config parameters in config.yml overrides config in
config_default.yml. You don't have to put everything in it, just add
what you want to override.

* Fixing test

Replacing conf.New by config.Conf

* Fixing call to config.Conf to config.Config{} in test files

* Might have fixed testing with this

Printf instead of Fatalf

* Renaming config.yml in example file

* Forbid commiting config.yml

* Should be now fixed

* Do not need this file anymore
2017-05-30 21:21:57 -05:00
Steindór
ffbbacb84a Maskot to cookie (#857)
* Put the mascot into the cookie as well, major js cleanup

* Update en-us.all.json

* removed redundant translation
2017-05-30 21:21:35 -05:00
akuma06
b0cf17c77c Renamed the search argument FromID instead of TorrentID 2017-05-30 14:12:42 +02:00
akuma06
402fce9f02 Api Last Torrent + xhr automatic refresh
* Added a fiel torrentID in search param
* Search can be limited to torrentID > id provided
* Templates creation through simple JS object
* XHR management through simple JS object
* Torrents object that interface with Templates and Query to get new
torrent uploaded according to the search context
2017-05-30 00:28:21 +02:00
akuma06
517b59b02f Merge pull request #837 from NyaaPantsu/csrf-secure
CSRF Support + better key for context
2017-05-29 22:15:07 +02:00
akuma06
3ec367a759 CSRF Support + better key for context
* Added new dep: gorilla/csrf
* CSRF field in forms
* CSRF variable in commontemplatevariables
* New key for messages and user context

Please change EnableSecureCSRF to false when testing locally and don't
merge config/env.go with the changes
2017-05-29 17:07:18 +02:00
John Smith
61141a1fcf
Exhaustive whitespace trimming 2017-05-29 23:43:27 +10:00
John Smith
0bdd915f9a
Let net/http gracefully close
http.Server.Shutdown gracefully closes listeners/clients, we do not have to
do it ourselves. Making util/signals accept func() instead of io.Closer
allowed for the removal of network/closer.go and util/signals/closers.go.
2017-05-29 16:29:34 +10:00
Atvaark
b31e77be2e Fix infohash decoding (#813)
Calculate the info hash of the uploaded torrent file
instead of the re-encoded torrent file.

The re-encoded torrent files only contain a subset
of the original info values and thus have a different hash.
2017-05-29 07:47:47 +10:00
Eliot Whalan
cdd382cd34
Merge branch 'dev' of https://github.com/NyaaPantsu/nyaa into dev 2017-05-28 19:57:38 +10:00
John Smith
8a5c4543f8
Less code. 2017-05-28 19:57:12 +10:00