つぶやきを見るページ(list_quote.pl)を追加
このコミットが含まれているのは:
コミット
bb8e434000
50
check.go
50
check.go
|
@ -2,33 +2,63 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
"net/url"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func getid(u string) (string, error) {
|
||||||
|
parse, err := url.Parse(u)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
params, err := url.ParseQuery(parse.RawQuery)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
id, ok := params["id"]
|
||||||
|
if !ok || len(id) == 0 {
|
||||||
|
return "", fmt.Errorf("IDを見つけられませんでした。")
|
||||||
|
}
|
||||||
|
|
||||||
|
return id[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
/* 記事かの確認 */
|
/* 記事かの確認 */
|
||||||
func isarticle(url string) bool {
|
func isarticle(u string) bool {
|
||||||
chk := strings.Split(url, "=")
|
chk := strings.Split(u, "=")
|
||||||
return len(chk) > 2 &&
|
return len(chk) > 2 &&
|
||||||
(chk[0] == "/view_news.pl?id" || chk[0] == "/view_news.pl?from" || chk[0] == "/view_news.pl?media_id" || chk[0] == "/view_news.pl?stkt")
|
(chk[0] == "/view_news.pl?id" || chk[0] == "/view_news.pl?from" || chk[0] == "/view_news.pl?media_id" || chk[0] == "/view_news.pl?stkt")
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 部分圏かの確認 */
|
/* 部分圏かの確認 */
|
||||||
func issubcat(url string) bool {
|
func issubcat(u string) bool {
|
||||||
chk := strings.Split(url, "=")
|
chk := strings.Split(u, "=")
|
||||||
return len(chk) > 1 &&
|
return len(chk) > 1 &&
|
||||||
(chk[0] == "/list_news_category.pl?id" || chk[0] == "/list_news_category.pl?page" || chk[0] == "/list_news_category.pl?sort" || chk[0] == "/list_news_category.pl?type" || chk[0] == "/list_news_category.pl?sub_category_id") &&
|
(chk[0] == "/list_news_category.pl?id" || chk[0] == "/list_news_category.pl?page" || chk[0] == "/list_news_category.pl?sort" || chk[0] == "/list_news_category.pl?type" || chk[0] == "/list_news_category.pl?sub_category_id") &&
|
||||||
strings.Contains(url, "type=bn")
|
strings.Contains(u, "type=bn")
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 部分かの確認 */
|
/* 部分かの確認 */
|
||||||
func iscategory(url string) bool {
|
func iscategory(u string) bool {
|
||||||
chk := strings.Split(url, "=")
|
chk := strings.Split(u, "=")
|
||||||
return len(chk) > 1 &&
|
return len(chk) > 1 &&
|
||||||
(chk[0] == "/list_news_category.pl?id" || chk[0] == "/list_news_category.pl?sub_category_id" || chk[0] == "/list_news_category?from") &&
|
(chk[0] == "/list_news_category.pl?id" || chk[0] == "/list_news_category.pl?sub_category_id" || chk[0] == "/list_news_category?from") &&
|
||||||
!strings.Contains(url, "type=bn")
|
!strings.Contains(u, "type=bn")
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 出版社かの確認 */
|
/* 出版社かの確認 */
|
||||||
func ispublish(url string) bool {
|
func ispublish(u string) bool {
|
||||||
chk := strings.Split(url, "=")
|
chk := strings.Split(u, "=")
|
||||||
return len(chk) > 1 && (chk[0] == "/list_news_media.pl?id" || chk[0] == "/list_news_media.pl?page")
|
return len(chk) > 1 && (chk[0] == "/list_news_media.pl?id" || chk[0] == "/list_news_media.pl?page")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* つぶやきかの確認 */
|
||||||
|
func istubayaki(u string) bool {
|
||||||
|
chk := strings.Split(u, "=")
|
||||||
|
return len(chk) > 1 &&
|
||||||
|
(chk[0] == "/list_quote.pl?id" || chk[0] == "/list_quote.pl?type" || chk[0] == "/list_quote.pl?sort" || chk[0] == "/list_quote.pl?news_id") &&
|
||||||
|
strings.Contains(u, "type=voice") &&
|
||||||
|
(strings.Contains(u, "sort=post_time") || strings.Contains(u, "sort=feedback_count"))
|
||||||
|
}
|
||||||
|
|
10
page.go
10
page.go
|
@ -77,13 +77,15 @@ func get(url string, cnf Config) map[string]string {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
id, _ := getid(url)
|
||||||
|
|
||||||
res["title"] = gettitle(body)
|
res["title"] = gettitle(body)
|
||||||
if isarticle(url) {
|
if isarticle(url) {
|
||||||
if !strings.Contains(body, "newsArticle") {
|
if !strings.Contains(body, "newsArticle") {
|
||||||
res["content"] = rmebloat(body, cnf)
|
res["content"] = rmebloat(body, cnf)
|
||||||
} else {
|
} else {
|
||||||
res["img"] = getimg(body, cnf)
|
res["img"] = getimg(body, cnf)
|
||||||
res["content"] = rmbloat(body, cnf)
|
res["content"] = rmbloat(id, body, cnf)
|
||||||
}
|
}
|
||||||
} else if ispublish(url) {
|
} else if ispublish(url) {
|
||||||
res["content"] = rmpbloat(body, cnf)
|
res["content"] = rmpbloat(body, cnf)
|
||||||
|
@ -93,6 +95,12 @@ func get(url string, cnf Config) map[string]string {
|
||||||
} else {
|
} else {
|
||||||
res["content"] = rmsbloat(body, cnf)
|
res["content"] = rmsbloat(body, cnf)
|
||||||
}
|
}
|
||||||
|
} else if istubayaki(url) {
|
||||||
|
if !strings.Contains(body, "quoteList") {
|
||||||
|
res["content"] = rmebloat(body, cnf)
|
||||||
|
} else {
|
||||||
|
res["content"] = rmqbloat(body, cnf)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if !strings.Contains(body, "注目のニュース") {
|
if !strings.Contains(body, "注目のニュース") {
|
||||||
res["content"] = rmebloat(body, cnf)
|
res["content"] = rmebloat(body, cnf)
|
||||||
|
|
46
rmbloat.go
46
rmbloat.go
|
@ -53,7 +53,7 @@ func rmcbloat(body string, cnf Config) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
body = strings.TrimSpace("<div class=\"subCategoryNavi\" class=\"LEGACY_UI2016_subCategoryNavi\">\n" + strings.TrimSpace(body)) + "\n </div>\n"
|
body = strings.TrimSpace("<div class=\"subCategoryNavi\" class=\"LEGACY_UI2016_subCategoryNavi\">\n" + strings.TrimSpace(body)) + "\n </div>\n"
|
||||||
return "<div class=\"newsArticle\">" + body + "</div>"
|
return "<div class=\"newsArticle\">\n<a class=\"totop\" href=\"/\">トップへ</a>\n" + body + "</div>"
|
||||||
}
|
}
|
||||||
|
|
||||||
/* エラーだけが残るまで消す */
|
/* エラーだけが残るまで消す */
|
||||||
|
@ -73,7 +73,36 @@ func rmebloat(body string, cnf Config) string {
|
||||||
body = re.ReplaceAllString(body, r.repl)
|
body = re.ReplaceAllString(body, r.repl)
|
||||||
}
|
}
|
||||||
|
|
||||||
body = strings.TrimSpace("<div class=\"newsArticle\">\n" + strings.TrimSpace(body)) + "\n </div>\n"
|
body = strings.TrimSpace("<div class=\"newsArticle\">\n<a class=\"totop\" href=\"/\">トップへ</a>\n" + strings.TrimSpace(body)) + "\n </div>\n"
|
||||||
|
return body
|
||||||
|
}
|
||||||
|
|
||||||
|
/* つばやきだけが残るまで消す */
|
||||||
|
func rmqbloat(body string, cnf Config) string {
|
||||||
|
var re *regexp.Regexp
|
||||||
|
|
||||||
|
rep := []struct {
|
||||||
|
pat string
|
||||||
|
repl string
|
||||||
|
}{
|
||||||
|
{`(?s)<!DOCTYPE html>.*?<div id="bodyMainArea" class="FRAME2016_bodyMainArea" >`, ""},
|
||||||
|
{`(?s)<div class="adsenseBannerArea">.*?</html>`, ""},
|
||||||
|
{`(?s)<div class="shareButtonArea">.*?<div class="relationNewsDescription">`, `<div class="relationNewsDescription">`},
|
||||||
|
{`https://news-image.mixi.net`, cnf.imgproxy + `/news-image.mixi.net`},
|
||||||
|
{`https://img.mixi.net`, cnf.imgproxy + `/img.mixi.net`},
|
||||||
|
{`https://news.mixi.jp/`, cnf.domain + `/`},
|
||||||
|
{`(?s)<div class="sortSwitch01">.*?</div>`, ""},
|
||||||
|
// {`・ `, ""},
|
||||||
|
// {`\[`, ""},
|
||||||
|
// {`\]`, ""},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, r := range rep {
|
||||||
|
re = regexp.MustCompile(r.pat)
|
||||||
|
body = re.ReplaceAllString(body, r.repl)
|
||||||
|
}
|
||||||
|
|
||||||
|
body = strings.TrimSpace("<div class=\"newsArticle\">\n<a class=\"totop\" href=\"/\">トップへ</a>\n" + strings.TrimSpace(body)) + "\n </div>\n"
|
||||||
return body
|
return body
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +129,7 @@ func rmsbloat(body string, cnf Config) string {
|
||||||
body = re.ReplaceAllString(body, r.repl)
|
body = re.ReplaceAllString(body, r.repl)
|
||||||
}
|
}
|
||||||
|
|
||||||
body = strings.TrimSpace("<div class=\"newsArticle\">\n" + strings.TrimSpace(body)) + "\n </div>\n"
|
body = strings.TrimSpace("<div class=\"newsArticle\">\n<a class=\"totop\" href=\"/\">トップへ</a>\n" + strings.TrimSpace(body)) + "\n </div>\n"
|
||||||
return body
|
return body
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,12 +157,12 @@ func rmpbloat(body string, cnf Config) string {
|
||||||
body = re.ReplaceAllString(body, r.repl)
|
body = re.ReplaceAllString(body, r.repl)
|
||||||
}
|
}
|
||||||
|
|
||||||
body = strings.TrimSpace("<div class=\"newsArticle\">\n" + strings.TrimSpace(body)) + "\n </div>\n"
|
body = strings.TrimSpace("<div class=\"newsArticle\">\n<a class=\"totop\" href=\"/\">トップへ</a>\n" + strings.TrimSpace(body)) + "\n </div>\n"
|
||||||
return body
|
return body
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 記事だけが残るまで消す */
|
/* 記事だけが残るまで消す */
|
||||||
func rmbloat(body string, cnf Config) string {
|
func rmbloat(id string, body string, cnf Config) string {
|
||||||
var re *regexp.Regexp
|
var re *regexp.Regexp
|
||||||
|
|
||||||
rep := []struct {
|
rep := []struct {
|
||||||
|
@ -157,7 +186,6 @@ func rmbloat(body string, cnf Config) string {
|
||||||
{`<!--`, ""},
|
{`<!--`, ""},
|
||||||
{`(?s)<img src="https://(.*?)"`, `<img src="` + cnf.imgproxy + `/$1"`},
|
{`(?s)<img src="https://(.*?)"`, `<img src="` + cnf.imgproxy + `/$1"`},
|
||||||
{`https://news-image.mixi.net`, cnf.imgproxy + `/news-image.mixi.net`},
|
{`https://news-image.mixi.net`, cnf.imgproxy + `/news-image.mixi.net`},
|
||||||
{`(?s)<br /><p><a href="https://mixi.jp/bypass_stats.pl.*?</a></p>`, ""},
|
|
||||||
{`https://news.mixi.jp/`, cnf.domain + `/`},
|
{`https://news.mixi.jp/`, cnf.domain + `/`},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,6 +194,10 @@ func rmbloat(body string, cnf Config) string {
|
||||||
body = re.ReplaceAllString(body, r.repl)
|
body = re.ReplaceAllString(body, r.repl)
|
||||||
}
|
}
|
||||||
|
|
||||||
body = strings.TrimSpace("<div class=\"newsArticle\">\n" + strings.TrimSpace(body)) + "\n </div>\n"
|
body = strings.TrimSpace("<div class=\"newsArticle\">\n<a class=\"totop\" href=\"/\">トップへ</a>\n" + strings.TrimSpace(body))
|
||||||
|
if id != "" {
|
||||||
|
body += "\n<p class=\"footer\"><a class=\"tubuyaki-btn\" href=\"/list_quote.pl?news_id=" + id + "&type=voice&sort=feedback_count\">つぶやきを見る</a></p>\n"
|
||||||
|
}
|
||||||
|
body += "\n </div>\n"
|
||||||
return body
|
return body
|
||||||
}
|
}
|
||||||
|
|
113
static/style.css
113
static/style.css
|
@ -10,6 +10,7 @@ body {
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: #ea5fea;
|
color: #ea5fea;
|
||||||
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1, h2 {
|
h1, h2 {
|
||||||
|
@ -44,13 +45,35 @@ code {
|
||||||
width: auto;
|
width: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.reactionCountBalloon, .totop, p.reactions, a.tubuyaki-btn {
|
||||||
|
border: 1px solid #f976de;
|
||||||
|
border-radius: 2px;
|
||||||
|
background-color: #232629;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reactionCountBalloon {
|
||||||
|
margin-left: 8px;
|
||||||
|
font-size: 60%;
|
||||||
|
padding: 0 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.totop, p.reactions {
|
||||||
|
padding: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.reactions {
|
||||||
|
font-size: 80%;
|
||||||
|
max-width: 50px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
.newsArticle {
|
.newsArticle {
|
||||||
width: calc(100% - 20px);
|
width: calc(100% - 20px);
|
||||||
max-width: 1200px;
|
max-width: 1200px;
|
||||||
background: #31363b;
|
background: #31363b;
|
||||||
border: 2px solid #4d4d4d;
|
border: 2px solid #4d4d4d;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
margin: auto;
|
margin: 32px auto;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +112,7 @@ code {
|
||||||
background: #3c213c;
|
background: #3c213c;
|
||||||
}
|
}
|
||||||
|
|
||||||
.LEGACY_UI2016_subCategoryNavi > p > a, .pageList01 > div > ul > li {
|
.LEGACY_UI2016_subCategoryNavi > p > a, .pageList01 > div > ul > li, .pageList01 > ul > li, .pageNavigation02 > p.first, .pageNavigation02 > p.last, ul.sortTab > li {
|
||||||
background-color: #4d4d4d;
|
background-color: #4d4d4d;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
border: 1px solid #c625ef;
|
border: 1px solid #c625ef;
|
||||||
|
@ -97,18 +120,85 @@ code {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pageList01 > div > ul {
|
.pageNavigation02 > p, .pageList01 > ul > li {
|
||||||
|
padding: 8px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pageNavigation02 > p.none, .pageList01 > ul > li.on, ul.sortTab > li.current, ul.sortTab > li.current > a {
|
||||||
|
background-color: #232629;
|
||||||
|
color: #4d4d4d;
|
||||||
|
border-color: #4d4d4d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pageList01 > div > ul, .pageList01 > ul, .pageNavigation02 > p.first, .pageNavigation02 > p.last, ul.sortTab {
|
||||||
padding-left: unset;
|
padding-left: unset;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pageList01 > div > ul, .pageList01 > div > ul > li, .entryList01, .entryList01 > li, .NEWS_pickupNewsList {
|
.pageList01 > div > ul,
|
||||||
|
.pageList01 > div > ul > li,
|
||||||
|
.pageList01 > ul > li,
|
||||||
|
.entryList01, .entryList01 > li,
|
||||||
|
.NEWS_pickupNewsList,
|
||||||
|
.pageNavigation02 > p.first,
|
||||||
|
.pageNavigation02 > p.last,
|
||||||
|
ul.sortTab > li,
|
||||||
|
ul.voiceList01 .attributes li,
|
||||||
|
ul.listAction,
|
||||||
|
h2.newsTitle {
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
.newsCategoryList {
|
.relationNewsDescription {
|
||||||
|
margin-top: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.voiceList01 {
|
||||||
|
padding-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pageNavigation02 {
|
||||||
|
display: ruby;
|
||||||
|
}
|
||||||
|
|
||||||
|
.newsCategoryList, .timestamp, .iine, .comment, .item {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.itemIn > .clearfix {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.voiceList01 > li.item {
|
||||||
|
background-color: #2f2e2f;
|
||||||
|
border: 1px dashed #4d4d4d;
|
||||||
|
margin: 8px 0;
|
||||||
|
padding: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.attributes, ul.listAction {
|
||||||
|
font-size: 80%;
|
||||||
|
color: #adadad;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.attributes {
|
||||||
|
position: absolute;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.listAction {
|
||||||
|
clear: both;
|
||||||
|
width: 100%;
|
||||||
|
margin-top: 5px;
|
||||||
|
margin-left: 4px;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.voiceList01 ul.listAction li {
|
||||||
|
margin-left: 10px;
|
||||||
|
font-size: 100%;
|
||||||
|
display: initial;
|
||||||
|
}
|
||||||
|
|
||||||
.NEWS_tempPhoto {
|
.NEWS_tempPhoto {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
@ -129,3 +219,16 @@ code {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-top: 32px;
|
margin-top: 32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
li.iine > img, li.comment > img {
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.tubuyaki-btn {
|
||||||
|
display: inline-table;
|
||||||
|
padding: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nextArticle > a.tubuyaki-btn {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
{{template "header" .}}
|
{{template "header" .}}
|
||||||
<a href="/">トップへ</a>
|
|
||||||
{{ .Bdy }}
|
{{ .Bdy }}
|
||||||
{{template "footer" .}}
|
{{template "footer" .}}
|
||||||
|
|
読み込み中…
新しいイシューから参照