Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Merge branch 'master' of https://github.com/ewhal/nyaa into refactor-search

Cette révision appartient à :
bakape 2017-05-09 14:32:10 +03:00
révision ec8bd90c4e
16 fichiers modifiés avec 47 ajouts et 163 suppressions

Voir le fichier

@ -79,7 +79,8 @@ func (t *Torrents) ToJson() TorrentsJson {
commentsJson = append(commentsJson, CommentsJson{Username: c.Username, Content: template.HTML(c.Content), Date: c.Date})
}
for _, c := range t.Comments {
commentsJson = append(commentsJson, CommentsJson{Username: c.User.Username, Content: template.HTML(c.Content), Date: c.CreatedAt})
commentsJson = append(commentsJson, CommentsJson{Username: c.User.Username, Content: util.MarkdownToHTML(c.Content), Date: c.CreatedAt})
}
res := TorrentsJson{
Id: strconv.FormatUint(uint64(t.Id), 10),
@ -88,7 +89,7 @@ func (t *Torrents) ToJson() TorrentsJson {
Hash: t.Hash,
Date: t.Date.Format(time.RFC3339),
Filesize: util.FormatFilesize2(t.Filesize),
Description: template.HTML(t.Description),
Description: util.MarkdownToHTML(t.Description),
Comments: commentsJson,
Sub_Category: strconv.Itoa(t.Sub_Category),
Category: strconv.Itoa(t.Category),

Voir le fichier

@ -27,7 +27,7 @@ type User struct {
Md5 string `json:"md5"`
TokenExpiration time.Time `gorm:"column:api_token_expiry"`
Language string `gorm:"column:language"`
Torrents []Torrents `gorm:"ForeignKey:owner_id"`
Torrents []Torrents `gorm:"ForeignKey:UploaderId"`
}
type PublicUser struct {
@ -38,4 +38,4 @@ type PublicUser struct {
type UsersFollowers struct {
UserID uint `gorm:"column:userId"`
FollowerID uint `gorm:"column:follower_id"`
}
}

Voir le fichier

@ -1,8 +1,4 @@
/* Night mode switcher */
.nightswitch > img {
width: 24px;
}
/*Don't make changes to layout here, only colours*/
/* Torrent status colors */
.remake {
background-color: #795c46;
@ -14,13 +10,10 @@
background-color: #487589;
}
/* modified copy of NyaaTorrent theme */
#mainmenu {
background: #263238;
position: fixed;
color: #f2f2f2;
width: 100%;
z-index: 4;
border: 0px solid #263238;
}
@ -29,7 +22,6 @@
}
#container {
padding-top: 1.25em;
background-color: #29363d;
}
@ -44,14 +36,8 @@
body {
background-color:#282A2E;
color: #eff5f5;
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
.torrentNav {
text-align: center;
}
.pagination > .active > a {
background: #ececec;
@ -62,7 +48,6 @@ body {
/* Links, Text */
a {
color: #81a2be;
text-decoration : none;
}
.btn-success {
color: #fff;
@ -70,138 +55,18 @@ a {
border-color: #b294bb;
}
.download-btn {
font-size: 24px;
}
.table-borderless > tbody > tr > td,
.table-borderless > tbody > tr > th,
.table-borderless > tfoot > tr > td,
.table-borderless > tfoot > tr > th,
.table-borderless > thead > tr > td,
.table-borderless > thead > tr > th {
border: none;
}
.torrent-info .name {
font-weight: bold;
overflow: hidden;
padding-bottom: 3px;
padding-top: 3px;
word-wrap: break-word;
}
.torrent-hash {
font-family: monospace;
}
.torrent-info .filesize {
white-space: nowrap;
}
.comment-row td:first-of-type {
vertical-align: top;
text-align: right;
}
/* Table style & fixes */
.table > tbody > tr > td {
/* fix bootstrap uglyness */
vertical-align: middle;
}
.table > tbody > tr > th, .table > tbody > tr > td {
padding: 4px;
}
.captcha-container {
display: grid;
grid-template-rows: auto;
grid-template-columns: 240px;
}
tr.torrent-info td.date {
white-space: nowrap;
}
.custom-table-hover > tbody > tr:hover {
opacity: 0.82;
}
.comment-row {
border-top: 1px solid #ddd;
}
div.container div.blockBody:nth-of-type(2) table{table-layout:fixed;}
div.container div.blockBody:nth-of-type(2) table tr:first-of-type th:first-of-type, div.container div.blockBody:nth-of-type(2) table tr:first-of-type th:nth-of-type(5){width:10%;}
div.container div.blockBody:nth-of-type(2) table tr:first-of-type th:nth-of-type(3){width:15%;}
div.container div.blockBody:nth-of-type(2) table tr:first-of-type th:nth-of-type(4){width:19%;}
div.container div.blockBody:nth-of-type(2) table tr:first-of-type th:last-of-type{width:6%;}
/* Mobile-friendly main table */
@media only screen and (max-width: 700px) {
table, thead, tbody, tr {
display: block;
}
th {
display: none;
}
td {
display: inline-block;
}
td:nth-of-type(1), td:nth-of-type(2) {
display: block;
}
.table > tbody > tr > td {
border: none;
}
}
/* Credit to bootsnipp.com for the css for the color graph */
.colorgraph {
height: 5px;
border-top: 0;
background: #c4e17f;
border-radius: 5px;
background-image: -webkit-linear-gradient(left, #c4e17f, #c4e17f 12.5%, #f7fdca 12.5%, #f7fdca 25%, #fecf71 25%, #fecf71 37.5%, #f0776c 37.5%, #f0776c 50%, #db9dbe 50%, #db9dbe 62.5%, #c49cde 62.5%, #c49cde 75%, #669ae1 75%, #669ae1 87.5%, #62c2e4 87.5%, #62c2e4);
background-image: -moz-linear-gradient(left, #c4e17f, #c4e17f 12.5%, #f7fdca 12.5%, #f7fdca 25%, #fecf71 25%, #fecf71 37.5%, #f0776c 37.5%, #f0776c 50%, #db9dbe 50%, #db9dbe 62.5%, #c49cde 62.5%, #c49cde 75%, #669ae1 75%, #669ae1 87.5%, #62c2e4 87.5%, #62c2e4);
background-image: -o-linear-gradient(left, #c4e17f, #c4e17f 12.5%, #f7fdca 12.5%, #f7fdca 25%, #fecf71 25%, #fecf71 37.5%, #f0776c 37.5%, #f0776c 50%, #db9dbe 50%, #db9dbe 62.5%, #c49cde 62.5%, #c49cde 75%, #669ae1 75%, #669ae1 87.5%, #62c2e4 87.5%, #62c2e4);
background-image: linear-gradient(to right, #c4e17f, #c4e17f 12.5%, #f7fdca 12.5%, #f7fdca 25%, #fecf71 25%, #fecf71 37.5%, #f0776c 37.5%, #f0776c 50%, #db9dbe 50%, #db9dbe 62.5%, #c49cde 62.5%, #c49cde 75%, #669ae1 75%, #669ae1 87.5%, #62c2e4 87.5%, #62c2e4);
}
.center-image {
max-width: 100%;
max-height: 80vh;
}
/* the curved edges triggered my autism */
.navbar {
border-radius: 0px;
}
:target {
background-color: #585b4f;
}
#mainmenu button .search_text {
display: none;
/* style the dropdown member menu */
.nav > .dropdown.open, .profile-image[aria-expanded="true"], .nav ul.dropdown-menu {
background: #282A2E;
}
#mainmenu .navbar-form select.form-control
{
width: 12rem;
.dropdown-menu > li > a:focus, .dropdown-menu > li > a:hover {
background: #263238;
}
.special-img
{
position: relative;
top: -5px;
float: left;
left: -5px;
}
#mainmenu .badgemenu {
padding-top: 0;
/* Night mode switcher */
#mainmenu a.nightswitch {
background-image: url(/img/moon.png);
}

Voir le fichier

@ -1,7 +1,4 @@
/* Night mode switcher */
.nightswitch > img {
width: 24px;
}
/* Torrent status colors */
.remake {
@ -318,4 +315,12 @@ div.container div.blockBody:nth-of-type(2) table tr:first-of-type th:last-of-typ
padding: 20px;
background: #fff;
min-height: 460px;
}
}
/* Night mode switcher */
#mainmenu a.nightswitch {
background: transparent url(/img/sun.png) no-repeat;
background-size: 24px;
margin-top: 10px;
margin-left: 3px;
width: 24px;
}

BIN
public/img/torrents/19.png Fichier normal

Fichier binaire non affiché.

Après

Largeur:  |  Hauteur:  |  Taille: 4 Kio

BIN
public/img/torrents/20.png Fichier normal

Fichier binaire non affiché.

Après

Largeur:  |  Hauteur:  |  Taille: 4,3 Kio

BIN
public/img/torrents/21.png Fichier normal

Fichier binaire non affiché.

Après

Largeur:  |  Hauteur:  |  Taille: 3,7 Kio

BIN
public/img/torrents/22.png Fichier normal

Fichier binaire non affiché.

Après

Largeur:  |  Hauteur:  |  Taille: 3,1 Kio

BIN
public/img/torrents/23.png Fichier normal

Fichier binaire non affiché.

Après

Largeur:  |  Hauteur:  |  Taille: 4 Kio

BIN
public/img/torrents/24.png Fichier normal

Fichier binaire non affiché.

Après

Largeur:  |  Hauteur:  |  Taille: 4,3 Kio

BIN
public/img/torrents/25.png Fichier normal

Fichier binaire non affiché.

Après

Largeur:  |  Hauteur:  |  Taille: 4 Kio

Voir le fichier

@ -1,18 +1,15 @@
// Night mode
var night = localStorage.getItem("night");
if (night == "true") {
$("#style")[0].href = "/css/style-night.css";
$("#nighticon")[0].src = "/img/sun.png";
$("head").append('<link id="style-dark" rel="stylesheet" type="text/css" href="/css/style-night.css">');
}
function toggleNightMode() {
var night = localStorage.getItem("night");
if(night == "true") {
$("#style")[0].href = "/css/style.css";
$("#nighticon")[0].src = "/img/moon.png";
$("#style-dark")[0].remove()
} else {
$("#style")[0].href = "/css/style-night.css";
$("#nighticon")[0].src = "/img/sun.png";
$("head").append('<link id="style-dark" rel="stylesheet" type="text/css" href="/css/style-night.css">');
}
localStorage.setItem("night", (night == "true") ? "false" : "true");
}

Voir le fichier

@ -243,10 +243,9 @@ func RetrieveUserByUsername(username string) (*model.PublicUser, string, int, er
// RetrieveUserForAdmin retrieves a user for an administrator.
func RetrieveUserForAdmin(id string) (model.User, int, error) {
var user model.User
if db.ORM.First(&user, id).RecordNotFound() {
if db.ORM.Preload("Torrents").First(&user, id).RecordNotFound() {
return user, http.StatusNotFound, errors.New("User is not found.")
}
db.ORM.Model(&user).Related("Torrents").Find(&model.Torrents{})
return user, http.StatusOK, nil
}

Voir le fichier

@ -11,6 +11,7 @@
<th>{{T "links"}}</th>
</tr>
{{ range .Torrents }}
{{ with .ToJson }}
<tr class="torrent-info
{{if eq .Status 2}}remake{{end}}
{{if eq .Status 3}}trusted{{end}}
@ -38,6 +39,7 @@
</td>
</tr>
{{end}}
{{end}}
</table>
<nav class="torrentNav" aria-label="Page navigation">
<ul class="pagination">

Voir le fichier

@ -39,7 +39,7 @@
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="{{.URL.Parse "/"}}">Nyaa Pantsu</a>
<a class="navbar-brand hidden-md pull-right nightswitch" href="javascript:toggleNightMode();" ><img id="nighticon" src="/img/moon.png"></a>
<a class="navbar-brand hidden-md pull-right nightswitch" href="javascript:toggleNightMode();" ></a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">

15
util/markdown.go Fichier normal
Voir le fichier

@ -0,0 +1,15 @@
package util
import (
"github.com/microcosm-cc/bluemonday"
"github.com/russross/blackfriday"
"html/template"
)
// TODO restrict certain types of markdown
func MarkdownToHTML(markdown string) template.HTML {
unsafe := blackfriday.MarkdownCommon([]byte(markdown))
html := bluemonday.UGCPolicy().SanitizeBytes(unsafe)
return template.HTML(html)
}