Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebrand #1

Draft
wants to merge 10 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
*.db
*.sql
main
nyaa
nyaa.exe
nyaa-master.exe
mogupantsu
mogupantsu.exe
mogupantsu-master.exe
*.zip
*.swp
.idea
Expand All @@ -16,7 +16,7 @@ templates/*.html.go
tags
*.retry
config/config.yml

Godeps/_workspace
# emacs temp files
*\#*
*~
Expand Down
2 changes: 1 addition & 1 deletion Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
![nyanpasu~](https://my.mixtape.moe/aglaxe.png)

# Nyaa replacement [![Build Status](https://travis-ci.org/NyaaPantsu/nyaa.svg?branch=master)](https://travis-ci.org/NyaaPantsu/nyaa) [![Go Report Card](https://goreportcard.com/badge/github.com/NyaaPantsu/nyaa)](https://goreportcard.com/report/github.com/NyaaPantsu/nyaa) [![GoDoc](https://godoc.org/github.com/NyaaPantsu/nyaa?status.svg)](https://godoc.org/github.com/NyaaPantsu/nyaa)[![Coverage Status](https://coveralls.io/repos/github/NyaaPantsu/nyaa/badge.svg?branch=dev)](https://coveralls.io/github/NyaaPantsu/nyaa?branch=dev)
# Nyaa replacement [![Build Status](https://travis-ci.org/NyaaPantsu/nyaa.svg?branch=master)](https://travis-ci.org/NyaaPantsu/nyaa) [![Go Report Card](https://goreportcard.com/badge/github.com/HoloPirates/mogupantsu)](https://goreportcard.com/report/github.com/HoloPirates/mogupantsu) [![GoDoc](https://godoc.org/github.com/HoloPirates/mogupantsu?status.svg)](https://godoc.org/github.com/HoloPirates/mogupantsu)[![Coverage Status](https://coveralls.io/repos/github/NyaaPantsu/nyaa/badge.svg?branch=dev)](https://coveralls.io/github/NyaaPantsu/nyaa?branch=dev)

## Motivation
The aim of this project is to write a fully featured nyaa replacement in golang
that anyone will be able to deploy locally or remotely.

## [Roadmap](https://github.com/NyaaPantsu/nyaa/projects/2)
As of August 17th the [trello board](https://trello.com/b/gMJBwoRq/nyaa-pantsu-cat-roadmap) has been moved to [GitHub Projects](https://github.com/NyaaPantsu/nyaa/projects/2)
## [Roadmap](https://github.com/HoloPirates/mogupantsu/projects/2)
As of August 17th the [trello board](https://trello.com/b/gMJBwoRq/nyaa-pantsu-cat-roadmap) has been moved to [GitHub Projects](https://github.com/HoloPirates/mogupantsu/projects/2)

The Roadmap will give you an overview of the features and tasks that the project are currently discussing, working on and have completed.
If you are looking for a feature that is not listed just make a GitHub Issue and it will get added to the trello board.

You can view the public GitHub Projects board [here](https://github.com/NyaaPantsu/nyaa/projects/2) or click on the "Roadmap".
You can view the public GitHub Projects board [here](https://github.com/HoloPirates/mogupantsu/projects/2) or click on the "Roadmap".

# Requirements

Expand All @@ -22,7 +22,7 @@ You can view the public GitHub Projects board [here](https://github.com/NyaaPant
All tested versions of Ubuntu fail to build, use a different OS or docker
* Install [Golang](https://golang.org/doc/install) (version >=1.8)
* `go get -u github.com/tools/godep`
* `go get github.com/NyaaPantsu/nyaa`
* `go get github.com/HoloPirates/mogupantsu`

On Windows, a specific version of GCC is used to build a specific depedency we use
The GCC version packaged with [msys2](https://github.com/orlp/dev-on-windows/wiki/Installing-GCC--&-MSYS2) should work
Expand Down Expand Up @@ -73,7 +73,7 @@ download [dos2unix](https://sourceforge.net/projects/dos2unix/files/latest/downl
on the /deploy/init.sh to convert CR+LF to LF.

```sh
# Make sure the project is in here $GOPATH/src/github.com/NyaaPantsu/nyaa
# Make sure the project is in here $GOPATH/src/github.com/HoloPirates/mogupantsu
$ cd deploy/
# You may choose another backend by pointing to the
# appropriate docker-compose file.
Expand Down
63 changes: 38 additions & 25 deletions config/default_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Host of server
host: localhost
# Version of the app
version: "1.1.0"
version: "1.1.0-mogu"
# port of server
port: 9999
# database type
Expand All @@ -24,15 +24,15 @@ comment_length: 2000
# the default config for web addresses
web_address:
# Nyaa : Origin of the website
nyaa: https://nyaa.pantsu.cat
nyaa: https://mogu.holopirates.moe
# Sukebei : Origin of the sukebei website
sukebei: https://sukebei.pantsu.cat
sukebei: soon_maybe
# Status : Origin of the status website
status: https://status.pantsu.cat
status: soon_maybe
# the default config for session cookies
cookies:
# DomainName : The host domain so the cookies can be shared across subdomains
domain_name: pantsu.cat
domain_name: holopirates.moe
# MaxAge : The expiration time of sessions cookies in seconds (default: 7 days)
max_age: 604800
# HashKey : 64 byte key used to authenticate cookies using HMAC. Leave blank for a random key after each restart.
Expand All @@ -45,7 +45,7 @@ scraper:
workers: 4
interval: 3600
trackers:
- {url: "udp://tracker.coppersurfer.tk:6969/", name: coppersurfer.tk}
- {url: "udp://tracker.holopirates.moe:1337/announce", name: holopirates.moe}
# StatScrapingFrequency : On-demand stat scraping JS will only be loaded if the stats have been scraped X hours ago or higher
stat_scraping_frequency: 48
# StatScrapingFrequencyUnknown : On-demand stat scraping for unknown torrents JS will only be loaded if the stats have been scraped X hours ago or higher
Expand Down Expand Up @@ -110,16 +110,27 @@ torrents:
# TorrentStatus : Config of different status id for torrents
status: [true, true, true, true, true, true]
# TorrentSukebeiCategories : Config for Sukebei categories
sukebei_categories: {"1_": "art", "1_1": "art_anime", "1_2": "art_doujinshi", "1_3": "art_games", "1_4": "art_manga", "1_5": "art_pictures", "2_": "real_life", "2_1": "real_life_photobooks_and_pictures", "2_2": "real_life_videos"}
sukebei_categories: {}
# TorrentCleanCategories : Config for Site categories
clean_categories: {"3_": "anime", "3_12": "anime_amv", "3_5": "anime_english_translated", "3_13": "anime_non_english_translated", "3_6": "anime_raw", "2_": "audio", "2_3": "audio_lossless", "2_4": "audio_lossy", "4_": "literature", "4_7": "literature_english_translated", "4_8": "literature_raw", "4_14": "literature_non_english_translated", "5_": "live_action", "5_9": "live_action_english_translated", "5_10": "live_action_idol_pv", "5_18": "live_action_non_english_translated", "5_11": "live_action_raw", "6_": "pictures", "6_15": "pictures_graphics", "6_16": "pictures_photos", "1_": "software", "1_1": "software_applications", "1_2": "software_games"}
# EnglishOnlyCategories : Which categories will only accept English torrents
english_only_categories: ["3_5", "4_7", "5_9"]
clean_categories:
{
"1_": "unarchived",
"1_1": "unarchived_karaoke",
"1_2": "unarchived_copyright",
"1_3": "unarchived_yab",
"2_": "paid",
"2_1": "paid_membership",
"2_2": "paid_voice_pack",
"2_3": "paid_concert",
"2_4": "paid_songs",
}
# EnglishOnlyCategories : Which categories will only accept English torrents
english_only_categories: []
# NonEnglishOnlyCategories : Which categories will only accept non-English torrents
non_english_only_categories: ["3_13", "4_14", "5_18"]
non_english_only_categories: []
# AdditionalLanguages : Which languages are available for selection when uploading a torrent, aside from
# the ones we have translations.
additional_languages: ["es-mx"]
additional_languages: []
# TorrentFileStorage : Path to default torrent storage location (eg /var/www/wherever/you/want)
torrents:
# GenerationClientPort : Port used by the torrent client created during torrent generation
Expand All @@ -133,7 +144,7 @@ torrents:
trackers:
# Trackers : Default trackers supported
default:
- udp://tracker.uw0.xyz:6969/announce
- udp://tracker.holopirates.moe:1337/announce
- udp://tracker.coppersurfer.tk:6969
- udp://tracker.zer0day.to:1337/announce
- udp://tracker.leechers-paradise.org:6969
Expand Down Expand Up @@ -176,16 +187,18 @@ torrents:
default: tags
# Array of tag types allowed for now
types:
- name: anidbid
field: AnidbID
defaults:
- db
- name: vndbid
field: VndbID
- name: dlsite
field: Dlsite
- name: vgmdbid
field: VgmdbID
# - name: anidbid
# field: AnidbID
# defaults:
# - db
# - name: vndbid
# field: VndbID
# - name: dlsite
# field: Dlsite
# - name: vgmdbid
# field: VgmdbID
- name: youtubeid
field: YoutubeID
- name: videoquality
field: VideoQuality
defaults:
Expand Down Expand Up @@ -221,7 +234,7 @@ log:
error_log_max_age: 30
email:
# SendEmail : Enable Email
send_email: true
send_email: false
# EmailFrom : email address by default
from: [email protected]
# EmailTestTo : when testing to who send email
Expand Down Expand Up @@ -257,7 +270,7 @@ models:
scrape_table_name: scrape
#Default themes
default_theme:
theme: g
theme: okayu
dark: tomorrow
forced:
#Put a theme name in forced to force it for everyone
16 changes: 8 additions & 8 deletions controllers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ Our routing system is based on [Gin-Gonic](https://github.com/gin-gonic/gin) HTT
This readme will only explain to you how the routing works and how to easily render a static 'hello world!' template.

## How the routing works
1. Our routing system based on gin has one main file that connect all our controllers. This file is controllers/router.go [here](https://github.com/NyaaPantsu/nyaa/blob/dev/controllers/router.go).
1. Our routing system based on gin has one main file that connect all our controllers. This file is controllers/router.go [here](https://github.com/HoloPirates/mogupantsu/blob/dev/controllers/router.go).
You can see that in the first lines, that this file import multiple sub directories. All the import that start with an underscore is a controller package. In fact, the main `router.go` only imports the different controllers and do nothing else. So if you need to create a whole new controller, you would have to **add it in this main `router.go` as an import that start with an underscore**.
2. Every controller package have another `router.go` file. It can be named differently but for homogenuity purposes, please name it like that. This file is the core of your controller package, you need it to add your controllers to the main router. All of the sub router.go files look pretty much the same.
For example, [here](https://github.com/NyaaPantsu/nyaa/blob/dev/controllers/search/router.go) is the `searchController` package `router.go` file.
For example, [here](https://github.com/HoloPirates/mogupantsu/blob/dev/controllers/search/router.go) is the `searchController` package `router.go` file.
* This file first import the `controllers/router` package. This step is important in order to have access to the function `router.Get()`.
* After it declares an `init()` function. This function is called automatically when the `searchController` package is imported.
* In this function we call `router.Get().XXX()`. This part is where you link the different controllers to the routes. The XXX part are gin functions. In fact, `router.Get()` return a gin.Router so you can use all the functions from the gin.Router here.
* Therefore `router.Get().Any("/", SearchHandler)` tells that every time you go to "/", it is the SearchHandler controller that should be called.
3. Every controller package have other go files. Those files should be where you put your controllers functions. Try to not put every controller functions in the same file. A controller function is the same as those designed by the Gin documentation. They should be function that accept as only argument: `c *gin.Context` and return nothing. For example, you can see [here](https://github.com/NyaaPantsu/nyaa/blob/dev/controllers/search/search.go#L19) the `SearchHandler` controller function.
3. Every controller package have other go files. Those files should be where you put your controllers functions. Try to not put every controller functions in the same file. A controller function is the same as those designed by the Gin documentation. They should be function that accept as only argument: `c *gin.Context` and return nothing. For example, you can see [here](https://github.com/HoloPirates/mogupantsu/blob/dev/controllers/search/search.go#L19) the `SearchHandler` controller function.

## Router Nyaa Functions
Our routing system doesn't have much function that you can use besides the gin defined one. However we have one that you might find very helpful, it is `router.GetUser(c)`. This function declared in the `controllers/router` package returns the current `User` during the request. You can only use this function in a controller function which have access to the `c *gin.Context`.
Expand All @@ -22,8 +22,8 @@ To use this templating system, it is quite easy. First you need to import the te
For example, `templates.ModelList(c, "url/of/template/file.jet.html", ArrayOfModels, Navigation, SearchForm)` is a function displaying a template file with a local variable `Models` which is your `ArrayOfModels`.
You also have `templates.Form(c, "url/of/template/file.jet.html", form)` which is a function displaying a template file with a `Form` local variable that is equal to the `form` variable passed.
Furthermore you have `templates.Static(c, "url/of/template/file.jet.html")` which is a function displaying a static template file without any local variables
Finally, you can use a mix of `templates.CommonVariables` and `templates.Render(c, "url/of/template/file.jet.html", variables)` to render more specific templates which need special cases like [here](https://github.com/NyaaPantsu/nyaa/blob/dev/controllers/search/search.go#L70).
When you have rendered and you don't want to continue executing the function after the display of the template, you have to return. For example, [here](https://github.com/NyaaPantsu/nyaa/blob/dev/controllers/search/search.go#L70), we want to stop the function and render the template "errors/no_results.jet.html", so we return just after calling `templates.Render()`.
Finally, you can use a mix of `templates.CommonVariables` and `templates.Render(c, "url/of/template/file.jet.html", variables)` to render more specific templates which need special cases like [here](https://github.com/HoloPirates/mogupantsu/blob/dev/controllers/search/search.go#L70).
When you have rendered and you don't want to continue executing the function after the display of the template, you have to return. For example, [here](https://github.com/HoloPirates/mogupantsu/blob/dev/controllers/search/search.go#L70), we want to stop the function and render the template "errors/no_results.jet.html", so we return just after calling `templates.Render()`.

## Mini Tutorial: Hello World!
To do this you will need a template file, a controller function and that's all!
Expand All @@ -41,7 +41,7 @@ In `helloworld.go` we will place in it the controller function `HelloWorld(c *gi
package helloWorldController

import (
"github.com/NyaaPantsu/nyaa/templates" // We import the templates package to use templates.* functions
"github.com/HoloPirates/mogupantsu/templates" // We import the templates package to use templates.* functions
"github.com/gin-gonic/gin" // We import the gin package to use c *gin.Context
)

Expand All @@ -57,7 +57,7 @@ In `router.go` we will link the controller function to the route we want to use
```
package helloWorldController

import "github.com/NyaaPantsu/nyaa/controllers/router" // We import the router package to get the gin.Router and add the route
import "github.com/HoloPirates/mogupantsu/controllers/router" // We import the router package to get the gin.Router and add the route
// When the package is called, we do what's inside
func init() {
// we get the gin.Router an for Any method (Get/POST/PUT...) we associate /hello path url to the HelloWorld controller
Expand All @@ -68,7 +68,7 @@ func init() {
### The link to the main `router.go`
Now we need to tell to the Nyaa Programm that we have yet another controller package to add, for this you need to go to `controllers/router.go` and add the following line to the import section:
```
_ "github.com/NyaaPantsu/nyaa/controllers/helloworld" // helloworld controller
_ "github.com/HoloPirates/mogupantsu/controllers/helloworld" // helloworld controller
```

### The End
Expand Down
8 changes: 4 additions & 4 deletions controllers/activities/activities.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"strconv"
"strings"

"github.com/NyaaPantsu/nyaa/controllers/router"
"github.com/NyaaPantsu/nyaa/models/activities"
"github.com/NyaaPantsu/nyaa/templates"
"github.com/NyaaPantsu/nyaa/utils/log"
"github.com/HoloPirates/mogupantsu/controllers/router"
"github.com/HoloPirates/mogupantsu/models/activities"
"github.com/HoloPirates/mogupantsu/templates"
"github.com/HoloPirates/mogupantsu/utils/log"
"github.com/gin-gonic/gin"
)

Expand Down
2 changes: 1 addition & 1 deletion controllers/activities/router.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package activitiesController

import "github.com/NyaaPantsu/nyaa/controllers/router"
import "github.com/HoloPirates/mogupantsu/controllers/router"

func init() {
router.Get().Any("/activities", ActivityListHandler)
Expand Down
32 changes: 16 additions & 16 deletions controllers/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ import (
"strings"
"time"

"github.com/NyaaPantsu/nyaa/config"
"github.com/NyaaPantsu/nyaa/controllers/feed"
"github.com/NyaaPantsu/nyaa/controllers/router"
"github.com/NyaaPantsu/nyaa/models"
"github.com/NyaaPantsu/nyaa/models/torrents"
"github.com/NyaaPantsu/nyaa/models/users"
"github.com/NyaaPantsu/nyaa/utils/api"
"github.com/NyaaPantsu/nyaa/utils/cookies"
"github.com/NyaaPantsu/nyaa/utils/crypto"
"github.com/NyaaPantsu/nyaa/utils/log"
msg "github.com/NyaaPantsu/nyaa/utils/messages"
"github.com/NyaaPantsu/nyaa/utils/search"
"github.com/NyaaPantsu/nyaa/utils/upload"
"github.com/NyaaPantsu/nyaa/utils/validator"
"github.com/NyaaPantsu/nyaa/utils/validator/torrent"
"github.com/NyaaPantsu/nyaa/utils/validator/user"
"github.com/HoloPirates/mogupantsu/config"
"github.com/HoloPirates/mogupantsu/controllers/feed"
"github.com/HoloPirates/mogupantsu/controllers/router"
"github.com/HoloPirates/mogupantsu/models"
"github.com/HoloPirates/mogupantsu/models/torrents"
"github.com/HoloPirates/mogupantsu/models/users"
"github.com/HoloPirates/mogupantsu/utils/api"
"github.com/HoloPirates/mogupantsu/utils/cookies"
"github.com/HoloPirates/mogupantsu/utils/crypto"
"github.com/HoloPirates/mogupantsu/utils/log"
msg "github.com/HoloPirates/mogupantsu/utils/messages"
"github.com/HoloPirates/mogupantsu/utils/search"
"github.com/HoloPirates/mogupantsu/utils/upload"
"github.com/HoloPirates/mogupantsu/utils/validator"
"github.com/HoloPirates/mogupantsu/utils/validator/torrent"
"github.com/HoloPirates/mogupantsu/utils/validator/user"
"github.com/gin-gonic/gin"
"github.com/ory/fosite"
"github.com/pkg/errors"
Expand Down
4 changes: 2 additions & 2 deletions controllers/api/router.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package apiController

import (
"github.com/NyaaPantsu/nyaa/controllers/middlewares"
"github.com/NyaaPantsu/nyaa/controllers/router"
"github.com/HoloPirates/mogupantsu/controllers/middlewares"
"github.com/HoloPirates/mogupantsu/controllers/router"
)

func init() {
Expand Down
4 changes: 2 additions & 2 deletions controllers/captcha/router.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package captchaController

import (
"github.com/NyaaPantsu/nyaa/controllers/router"
"github.com/NyaaPantsu/nyaa/utils/captcha"
"github.com/HoloPirates/mogupantsu/controllers/router"
"github.com/HoloPirates/mogupantsu/utils/captcha"
)

func init() {
Expand Down
8 changes: 4 additions & 4 deletions controllers/databasedumps/databasedumps.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"path/filepath"
"time"

"github.com/NyaaPantsu/nyaa/models"
"github.com/NyaaPantsu/nyaa/templates"
"github.com/NyaaPantsu/nyaa/utils/log"
"github.com/NyaaPantsu/nyaa/utils/metainfo"
"github.com/HoloPirates/mogupantsu/models"
"github.com/HoloPirates/mogupantsu/templates"
"github.com/HoloPirates/mogupantsu/utils/log"
"github.com/HoloPirates/mogupantsu/utils/metainfo"
"github.com/gin-gonic/gin"
)

Expand Down
2 changes: 1 addition & 1 deletion controllers/databasedumps/router.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package databasedumpsController

import "github.com/NyaaPantsu/nyaa/controllers/router"
import "github.com/HoloPirates/mogupantsu/controllers/router"

func init() {
router.Get().Any("/dumps", DatabaseDumpHandler)
Expand Down
2 changes: 1 addition & 1 deletion controllers/faq/faq.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package faqController

import (
"github.com/NyaaPantsu/nyaa/templates"
"github.com/HoloPirates/mogupantsu/templates"
"github.com/gin-gonic/gin"
)

Expand Down
Loading