Navigation Menu

Skip to content

Commit

Permalink
Remove common package
Browse files Browse the repository at this point in the history
Common is no more a thing
Use of TorrentParam instead of SearchParam now
Common structs for search are exported in utils/search/structs
Util has been renamed utils
  • Loading branch information
akuma06 committed Jul 2, 2017
1 parent 188c196 commit 97b3a1d
Show file tree
Hide file tree
Showing 83 changed files with 193 additions and 329 deletions.
8 changes: 0 additions & 8 deletions common/comment.go

This file was deleted.

17 changes: 0 additions & 17 deletions common/errors.go

This file was deleted.

15 changes: 0 additions & 15 deletions common/report.go

This file was deleted.

14 changes: 0 additions & 14 deletions common/scrape.go

This file was deleted.

11 changes: 0 additions & 11 deletions common/user.go

This file was deleted.

4 changes: 2 additions & 2 deletions controllers/activity_handler.go
Expand Up @@ -8,8 +8,8 @@ import (

"github.com/NyaaPantsu/nyaa/models"
"github.com/NyaaPantsu/nyaa/models/activities"
"github.com/NyaaPantsu/nyaa/util/cookies"
"github.com/NyaaPantsu/nyaa/util/log"
"github.com/NyaaPantsu/nyaa/utils/cookies"
"github.com/NyaaPantsu/nyaa/utils/log"
"github.com/gin-gonic/gin"
)

Expand Down
12 changes: 6 additions & 6 deletions controllers/api_handler.go
Expand Up @@ -12,12 +12,12 @@ import (
"github.com/NyaaPantsu/nyaa/models/torrents"
"github.com/NyaaPantsu/nyaa/service"
"github.com/NyaaPantsu/nyaa/service/api"
"github.com/NyaaPantsu/nyaa/util/cookies"
"github.com/NyaaPantsu/nyaa/util/crypto"
"github.com/NyaaPantsu/nyaa/util/log"
msg "github.com/NyaaPantsu/nyaa/util/messages"
"github.com/NyaaPantsu/nyaa/util/search"
"github.com/NyaaPantsu/nyaa/util/upload"
"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/gin-gonic/gin"
)

Expand Down
4 changes: 2 additions & 2 deletions controllers/database_dump_handler.go
Expand Up @@ -7,8 +7,8 @@ import (
"time"

"github.com/NyaaPantsu/nyaa/models"
"github.com/NyaaPantsu/nyaa/util/log"
"github.com/NyaaPantsu/nyaa/util/metainfo"
"github.com/NyaaPantsu/nyaa/utils/log"
"github.com/NyaaPantsu/nyaa/utils/metainfo"
"github.com/gin-gonic/gin"
)

Expand Down
2 changes: 1 addition & 1 deletion controllers/helpers.go
Expand Up @@ -3,7 +3,7 @@ package controllers
import (
"github.com/NyaaPantsu/nyaa/common"
"github.com/NyaaPantsu/nyaa/models"
"github.com/NyaaPantsu/nyaa/util/cookies"
"github.com/NyaaPantsu/nyaa/utils/cookies"
"github.com/gin-gonic/gin"
)

Expand Down
2 changes: 1 addition & 1 deletion controllers/middlewares.go
Expand Up @@ -3,7 +3,7 @@ package controllers
import (
"net/http"

"github.com/NyaaPantsu/nyaa/util/cookies"
"github.com/NyaaPantsu/nyaa/utils/cookies"
"github.com/gin-gonic/gin"
)

Expand Down
16 changes: 8 additions & 8 deletions controllers/modpanel.go
Expand Up @@ -13,11 +13,11 @@ import (
"github.com/NyaaPantsu/nyaa/models/comments"
"github.com/NyaaPantsu/nyaa/models/reports"
"github.com/NyaaPantsu/nyaa/models/torrents"
"github.com/NyaaPantsu/nyaa/util/categories"
"github.com/NyaaPantsu/nyaa/util/cookies"
"github.com/NyaaPantsu/nyaa/util/log"
msg "github.com/NyaaPantsu/nyaa/util/messages"
"github.com/NyaaPantsu/nyaa/util/search"
"github.com/NyaaPantsu/nyaa/utils/categories"
"github.com/NyaaPantsu/nyaa/utils/cookies"
"github.com/NyaaPantsu/nyaa/utils/log"
msg "github.com/NyaaPantsu/nyaa/utils/messages"
"github.com/NyaaPantsu/nyaa/utils/search"
"github.com/gin-gonic/gin"
)

Expand Down Expand Up @@ -388,7 +388,7 @@ func TorrentsPostListPanel(c *gin.Context) {
*/
func APIMassMod(c *gin.Context) {
torrentManyAction(c)
messages := msg.GetMessages(c) // new util for errors and infos
messages := msg.GetMessages(c) // new utils for errors and infos
c.Header("Content-Type", "application/json")

var mapOk map[string]interface{}
Expand All @@ -404,7 +404,7 @@ func APIMassMod(c *gin.Context) {
// DeletedTorrentsModPanel : Controller for viewing deleted torrents, accept common search arguments
func DeletedTorrentsModPanel(c *gin.Context) {
page := c.Param("page")
messages := msg.GetMessages(c) // new util for errors and infos
messages := msg.GetMessages(c) // new utils for errors and infos
deleted := c.Request.URL.Query()["deleted"]
unblocked := c.Request.URL.Query()["unblocked"]
blocked := c.Request.URL.Query()["blocked"]
Expand Down Expand Up @@ -487,7 +487,7 @@ func torrentManyAction(c *gin.Context) {
owner, _ := strconv.Atoi(c.PostForm("owner"))
category := c.PostForm("category")
withReport, _ := strconv.ParseBool(c.DefaultPostForm("withreport", "false"))
messages := msg.GetMessages(c) // new util for errors and infos
messages := msg.GetMessages(c) // new utils for errors and infos
catID, subCatID := -1, -1
var err error

Expand Down
8 changes: 4 additions & 4 deletions controllers/publicSettingsHandler.go
Expand Up @@ -5,10 +5,10 @@ import (
"net/url"

"github.com/NyaaPantsu/nyaa/config"
"github.com/NyaaPantsu/nyaa/util/cookies"
msg "github.com/NyaaPantsu/nyaa/util/messages"
"github.com/NyaaPantsu/nyaa/util/publicSettings"
"github.com/NyaaPantsu/nyaa/util/timeHelper"
"github.com/NyaaPantsu/nyaa/utils/cookies"
msg "github.com/NyaaPantsu/nyaa/utils/messages"
"github.com/NyaaPantsu/nyaa/utils/publicSettings"
"github.com/NyaaPantsu/nyaa/utils/timeHelper"
"github.com/gin-gonic/gin"
)

Expand Down
2 changes: 1 addition & 1 deletion controllers/router.go
Expand Up @@ -3,7 +3,7 @@ package controllers
import (
"net/http"

"github.com/NyaaPantsu/nyaa/util/captcha"
"github.com/NyaaPantsu/nyaa/utils/captcha"
"github.com/gin-gonic/gin"
"github.com/justinas/nosurf"
)
Expand Down
10 changes: 5 additions & 5 deletions controllers/rss_handler.go
Expand Up @@ -12,11 +12,11 @@ import (

"github.com/NyaaPantsu/nyaa/config"
"github.com/NyaaPantsu/nyaa/models"
"github.com/NyaaPantsu/nyaa/util/categories"
userService "github.com/NyaaPantsu/nyaa/util/cookies"
"github.com/NyaaPantsu/nyaa/util/feeds"
"github.com/NyaaPantsu/nyaa/util/publicSettings"
"github.com/NyaaPantsu/nyaa/util/search"
"github.com/NyaaPantsu/nyaa/utils/categories"
userService "github.com/NyaaPantsu/nyaa/utils/cookies"
"github.com/NyaaPantsu/nyaa/utils/feeds"
"github.com/NyaaPantsu/nyaa/utils/publicSettings"
"github.com/NyaaPantsu/nyaa/utils/search"
"github.com/gin-gonic/gin"
"github.com/gorilla/feeds"
)
Expand Down
4 changes: 2 additions & 2 deletions controllers/search_handler.go
Expand Up @@ -6,8 +6,8 @@ import (
"strconv"

"github.com/NyaaPantsu/nyaa/models"
"github.com/NyaaPantsu/nyaa/util/log"
"github.com/NyaaPantsu/nyaa/util/search"
"github.com/NyaaPantsu/nyaa/utils/log"
"github.com/NyaaPantsu/nyaa/utils/search"
"github.com/gin-gonic/gin"
)

Expand Down
8 changes: 4 additions & 4 deletions controllers/template.go
Expand Up @@ -6,10 +6,10 @@ import (

"github.com/NyaaPantsu/nyaa/config"
"github.com/NyaaPantsu/nyaa/models"
userForms "github.com/NyaaPantsu/nyaa/util/cookies"
"github.com/NyaaPantsu/nyaa/util/filelist"
"github.com/NyaaPantsu/nyaa/util/messages"
"github.com/NyaaPantsu/nyaa/util/publicSettings"
userForms "github.com/NyaaPantsu/nyaa/utils/cookies"
"github.com/NyaaPantsu/nyaa/utils/filelist"
"github.com/NyaaPantsu/nyaa/utils/messages"
"github.com/NyaaPantsu/nyaa/utils/publicSettings"
"github.com/gin-gonic/gin"
"github.com/justinas/nosurf"

Expand Down
12 changes: 6 additions & 6 deletions controllers/template_functions.go
Expand Up @@ -13,12 +13,12 @@ import (
"github.com/NyaaPantsu/nyaa/models"
"github.com/NyaaPantsu/nyaa/models/activities"
"github.com/NyaaPantsu/nyaa/models/torrents"
"github.com/NyaaPantsu/nyaa/util"
"github.com/NyaaPantsu/nyaa/util/categories"
"github.com/NyaaPantsu/nyaa/util/cookies"
"github.com/NyaaPantsu/nyaa/util/filelist"
"github.com/NyaaPantsu/nyaa/util/publicSettings"
"github.com/NyaaPantsu/nyaa/util/torrentLanguages"
"github.com/NyaaPantsu/nyaa/utils"
"github.com/NyaaPantsu/nyaa/utils/categories"
"github.com/NyaaPantsu/nyaa/utils/cookies"
"github.com/NyaaPantsu/nyaa/utils/filelist"
"github.com/NyaaPantsu/nyaa/utils/publicSettings"
"github.com/NyaaPantsu/nyaa/utils/torrentLanguages"
)

type captchaData struct {
Expand Down
2 changes: 1 addition & 1 deletion controllers/template_test.go
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/NyaaPantsu/nyaa/model"
"github.com/NyaaPantsu/nyaa/service/api"
userForm "github.com/NyaaPantsu/nyaa/service/user/form"
"github.com/NyaaPantsu/nyaa/util/publicSettings"
"github.com/NyaaPantsu/nyaa/utils/publicSettings"
"github.com/gin-gonic/gin"
)

Expand Down
14 changes: 7 additions & 7 deletions controllers/upload_handler.go
Expand Up @@ -9,12 +9,12 @@ import (
"github.com/NyaaPantsu/nyaa/models"
"github.com/NyaaPantsu/nyaa/models/torrents"
"github.com/NyaaPantsu/nyaa/service/api"
"github.com/NyaaPantsu/nyaa/util/captcha"
"github.com/NyaaPantsu/nyaa/util/cookies"
"github.com/NyaaPantsu/nyaa/util/log"
msg "github.com/NyaaPantsu/nyaa/util/messages"
"github.com/NyaaPantsu/nyaa/util/publicSettings"
"github.com/NyaaPantsu/nyaa/util/upload"
"github.com/NyaaPantsu/nyaa/utils/captcha"
"github.com/NyaaPantsu/nyaa/utils/cookies"
"github.com/NyaaPantsu/nyaa/utils/log"
msg "github.com/NyaaPantsu/nyaa/utils/messages"
"github.com/NyaaPantsu/nyaa/utils/publicSettings"
"github.com/NyaaPantsu/nyaa/utils/upload"
"github.com/gin-gonic/gin"
)

Expand All @@ -38,7 +38,7 @@ func UploadHandler(c *gin.Context) {
func UploadPostHandler(c *gin.Context) {
var uploadForm apiService.TorrentRequest
user := getUser(c)
messages := msg.GetMessages(c) // new util for errors and infos
messages := msg.GetMessages(c) // new utils for errors and infos

if userPermission.NeedsCaptcha(user) {
userCaptcha := captcha.Extract(c)
Expand Down
12 changes: 6 additions & 6 deletions controllers/user_handler.go
Expand Up @@ -8,12 +8,12 @@ import (

"github.com/NyaaPantsu/nyaa/models"
"github.com/NyaaPantsu/nyaa/models/notifications"
"github.com/NyaaPantsu/nyaa/util/captcha"
"github.com/NyaaPantsu/nyaa/util/cookies"
"github.com/NyaaPantsu/nyaa/util/crypto"
msg "github.com/NyaaPantsu/nyaa/util/messages"
"github.com/NyaaPantsu/nyaa/util/publicSettings"
"github.com/NyaaPantsu/nyaa/util/search"
"github.com/NyaaPantsu/nyaa/utils/captcha"
"github.com/NyaaPantsu/nyaa/utils/cookies"
"github.com/NyaaPantsu/nyaa/utils/crypto"
msg "github.com/NyaaPantsu/nyaa/utils/messages"
"github.com/NyaaPantsu/nyaa/utils/publicSettings"
"github.com/NyaaPantsu/nyaa/utils/search"
"github.com/gin-gonic/gin"
)

Expand Down
12 changes: 6 additions & 6 deletions controllers/view_torrent_handler.go
Expand Up @@ -18,12 +18,12 @@ import (
"github.com/NyaaPantsu/nyaa/models/reports"
"github.com/NyaaPantsu/nyaa/models/torrents"
"github.com/NyaaPantsu/nyaa/service/api"
"github.com/NyaaPantsu/nyaa/util"
"github.com/NyaaPantsu/nyaa/util/captcha"
"github.com/NyaaPantsu/nyaa/util/cookies"
"github.com/NyaaPantsu/nyaa/util/filelist"
msg "github.com/NyaaPantsu/nyaa/util/messages"
"github.com/NyaaPantsu/nyaa/util/publicSettings"
"github.com/NyaaPantsu/nyaa/utils"
"github.com/NyaaPantsu/nyaa/utils/captcha"
"github.com/NyaaPantsu/nyaa/utils/cookies"
"github.com/NyaaPantsu/nyaa/utils/filelist"
msg "github.com/NyaaPantsu/nyaa/utils/messages"
"github.com/NyaaPantsu/nyaa/utils/publicSettings"
"github.com/gin-gonic/gin"
)

Expand Down
10 changes: 5 additions & 5 deletions main.go
Expand Up @@ -11,11 +11,11 @@ import (

"github.com/NyaaPantsu/nyaa/config"
"github.com/NyaaPantsu/nyaa/controllers"
"github.com/NyaaPantsu/nyaa/util/cookies"
"github.com/NyaaPantsu/nyaa/util/log"
"github.com/NyaaPantsu/nyaa/util/publicSettings"
"github.com/NyaaPantsu/nyaa/util/search"
"github.com/NyaaPantsu/nyaa/util/signals"
"github.com/NyaaPantsu/nyaa/utils/cookies"
"github.com/NyaaPantsu/nyaa/utils/log"
"github.com/NyaaPantsu/nyaa/utils/publicSettings"
"github.com/NyaaPantsu/nyaa/utils/search"
"github.com/NyaaPantsu/nyaa/utils/signals"
)

var buildversion string
Expand Down
4 changes: 2 additions & 2 deletions models/dumps.go
Expand Up @@ -4,7 +4,7 @@ import (
"html/template"
"time"

"github.com/NyaaPantsu/nyaa/util"
"github.com/NyaaPantsu/nyaa/utils/format"
)

// DatabaseDump model
Expand All @@ -28,7 +28,7 @@ type DatabaseDumpJSON struct {
func (dump *DatabaseDump) ToJSON() DatabaseDumpJSON {
json := DatabaseDumpJSON{
Date: dump.Date.Format(time.RFC3339),
Filesize: util.FormatFilesize(dump.Filesize),
Filesize: format.FileSize(dump.Filesize),
Name: dump.Name,
TorrentLink: template.URL(dump.TorrentLink),
}
Expand Down
2 changes: 1 addition & 1 deletion models/gorm.go
Expand Up @@ -2,7 +2,7 @@ package models

import (
"github.com/NyaaPantsu/nyaa/config"
"github.com/NyaaPantsu/nyaa/util/log"
"github.com/NyaaPantsu/nyaa/utils/log"
"github.com/azhao12345/gorm"
_ "github.com/jinzhu/gorm/dialects/postgres" // Need for postgres support
_ "github.com/jinzhu/gorm/dialects/sqlite" // Need for sqlite
Expand Down

0 comments on commit 97b3a1d

Please sign in to comment.