コミットを比較
13 コミット
spliti-2.0
...
master
作成者 | SHA1 | 日付 |
---|---|---|
守矢諏訪子 | bd0e2e2d0a | |
守矢諏訪子 | a406479189 | |
守矢諏訪子 | 594eab89d5 | |
守矢諏訪子 | 7f646dd8a8 | |
守矢諏訪子 | ac2ddda27e | |
守矢諏訪子 | 13a283d75f | |
守矢諏訪子 | 59aa57f4bc | |
守矢諏訪子 | bb8e434000 | |
守矢諏訪子 | c7063f75c3 | |
守矢諏訪子 | 1750418646 | |
守矢諏訪子 | b81c1c0ae8 | |
守矢諏訪子 | a5aeb32f19 | |
守矢諏訪子 | 5374096c8a |
12
CHANGELOG.md
12
CHANGELOG.md
|
@ -1,3 +1,15 @@
|
|||
# 2.2.0
|
||||
* GNU MakeからBSD Makeに変更
|
||||
* 社会、トレンド、地域、海外、コラム、及びライフスタイルのカテゴリページの修正
|
||||
* マウスオーバーのハイライトの追加
|
||||
* .pageList02のスタイリングの追加
|
||||
|
||||
# 2.1.0
|
||||
* 出版社ページを追加
|
||||
* 出版社ページのページネーション
|
||||
* カテゴリーのページネーション
|
||||
* つぶやきを見るページ(list_quote.pl)を追加
|
||||
|
||||
# 2.0.1
|
||||
* manページを修正
|
||||
* 「-h」を修正
|
||||
|
|
10
Makefile
10
Makefile
|
@ -1,10 +1,10 @@
|
|||
NAME := $(shell cat main.go | grep "var sofname" | awk '{print $$4}' | sed "s/\"//g")
|
||||
VERSION := $(shell cat main.go | grep "var version" | awk '{print $$4}' | sed "s/\"//g")
|
||||
NAME!=cat main.go | grep "var sofname" | awk '{print $$4}' | sed "s/\"//g"
|
||||
VERSION!=cat main.go | grep "var version" | awk '{print $$4}' | sed "s/\"//g"
|
||||
# Linux、Haiku、Illumos = /usr、FreeBSDとOpenBSD = /usr/local、NetBSD = /usr/pkg
|
||||
PREFIX=/usr/local
|
||||
MANPREFIX=${PREFIX}/share/man
|
||||
# FreeBSD = /usr/local/etc、それ以外 = /etc
|
||||
CNFPREFIX=/etc
|
||||
# FreeBSD = /usr/local/etc、NetBSD = /usr/pkg/etc、それ以外 = /etc
|
||||
CNFPREFIX?=/etc
|
||||
CC=CGO_ENABLED=0 go build
|
||||
# リリース。なし=デバッグ。
|
||||
RELEASE=-ldflags="-s -w" -buildvcs=false
|
||||
|
@ -48,7 +48,7 @@ dist: clean
|
|||
rm -rf ${NAME}-${VERSION}
|
||||
|
||||
config:
|
||||
make -p ${DESTDIR}${CNFPREFIX}/spliti
|
||||
mkdir -p ${DESTDIR}${CNFPREFIX}/spliti
|
||||
cp config.json ${DESTDIR}${CNFPREFIX}/spliti
|
||||
|
||||
install: all
|
||||
|
|
32
README.md
32
README.md
|
@ -13,12 +13,27 @@ git clone https://gitler.moe/suwako/spliti.git && cd spliti
|
|||
find . -type f -name "config.json" -exec sed -i 's/mixi.076.moe/$domain/g'
|
||||
```
|
||||
|
||||
### Linux
|
||||
### OpenBSD(オススメ)
|
||||
|
||||
```sh
|
||||
make
|
||||
doas make install PREFIX=/usr
|
||||
doas make install
|
||||
doas make config
|
||||
cd /etc
|
||||
wget https://076.moe/repo/webserver/relayd/spliti.conf
|
||||
mv spliti.conf relayd.conf
|
||||
find . -type f -name "/etc/relayd.conf" -exec sed -i 's/DOMAIN/$domain/g'
|
||||
rcctl restart relayd
|
||||
```
|
||||
|
||||
### Linux
|
||||
|
||||
**注意:BSD Makeをインストールして下さい。GNU Makeは未対応です。**
|
||||
|
||||
```sh
|
||||
bmake
|
||||
doas bmake install PREFIX=/usr
|
||||
doas bmake config
|
||||
cp /etc/nginx/sites-enabled
|
||||
wget https://076.moe/repo/webserver/nginx/spliti.conf
|
||||
find . -type f -name "/etc/nginx/sites-enabled/spliti.conf" -exec sed -i 's/DOMAIN/$domain/g'
|
||||
|
@ -37,17 +52,16 @@ find . -type f -name "/usr/local/etc/nginx/sites-enabled/spliti.conf" -exec sed
|
|||
service nginx restart
|
||||
```
|
||||
|
||||
### OpenBSD
|
||||
### NetBSD
|
||||
|
||||
```sh
|
||||
make
|
||||
doas make install
|
||||
doas make config
|
||||
cd /etc
|
||||
wget https://076.moe/repo/webserver/relayd/spliti.conf
|
||||
mv spliti.conf relayd.conf
|
||||
find . -type f -name "/etc/relayd.conf" -exec sed -i 's/DOMAIN/$domain/g'
|
||||
rcctl restart relayd
|
||||
doas make config CNFPREFIX=/usr/pkg/etc
|
||||
cp srv/nginx.conf /usr/pkg/etc/nginx/sites-enabled/spliti.conf
|
||||
wget https://076.moe/repo/webserver/nginx/spliti.conf
|
||||
find . -type f -name "/usr/pkg/etc/nginx/sites-enabled/spliti.conf" -exec sed -i 's/DOMAIN/$domain/g'
|
||||
service nginx restart
|
||||
```
|
||||
|
||||
## インスタンス一覧
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"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(u string) bool {
|
||||
chk := strings.Split(u, "=")
|
||||
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")
|
||||
}
|
||||
|
||||
/* 部分圏かの確認 */
|
||||
func issubcat(u string) bool {
|
||||
chk := strings.Split(u, "=")
|
||||
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") &&
|
||||
strings.Contains(u, "type=bn")
|
||||
}
|
||||
|
||||
/* 部分かの確認 */
|
||||
func iscategory(u string) bool {
|
||||
chk := strings.Split(u, "=")
|
||||
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") &&
|
||||
!strings.Contains(u, "type=bn")
|
||||
}
|
||||
|
||||
/* 出版社かの確認 */
|
||||
func ispublish(u string) bool {
|
||||
chk := strings.Split(u, "=")
|
||||
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"))
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"io"
|
||||
"strings"
|
||||
"bytes"
|
||||
|
||||
"golang.org/x/net/html"
|
||||
"golang.org/x/text/encoding/japanese"
|
||||
"golang.org/x/text/transform"
|
||||
)
|
||||
|
||||
/* PHPであるstrip_tagsはGo言語で存在しないから、自分で作る */
|
||||
func strip_tags(data string) string {
|
||||
doc, err := html.Parse(strings.NewReader(data))
|
||||
if err != nil {
|
||||
panic("HTMLをパーシングに失敗。")
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
var f func(*html.Node)
|
||||
f = func(n *html.Node) {
|
||||
if n.Type == html.TextNode {
|
||||
buf.WriteString(n.Data)
|
||||
}
|
||||
for c := n.FirstChild; c != nil; c = c.NextSibling {
|
||||
f(c)
|
||||
}
|
||||
}
|
||||
f(doc)
|
||||
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
func EUCJPToUTF8(input []byte) (string, error) {
|
||||
transformer := japanese.EUCJP.NewDecoder()
|
||||
reader := transform.NewReader(bytes.NewReader(input), transformer)
|
||||
result, err := io.ReadAll(reader)
|
||||
if err != nil {
|
||||
return "エンコーディングに失敗", err
|
||||
}
|
||||
|
||||
return string(result), nil
|
||||
}
|
5
main.go
5
main.go
|
@ -7,9 +7,12 @@ import (
|
|||
)
|
||||
|
||||
var sofname = "spliti"
|
||||
var version = "2.0.1"
|
||||
var version = "2.2.0"
|
||||
|
||||
func help() {
|
||||
fmt.Println("076 " + sofname + "-" + version + " - mixi向けプライバシーUI")
|
||||
fmt.Println("https://mixi.076.moe/ | https://gitler.moe/suwako/spliti")
|
||||
fmt.Println("")
|
||||
fmt.Println("使い方:")
|
||||
fmt.Println(sofname + " -v :バージョンを表示")
|
||||
fmt.Println(sofname + " -s [ポート番号] :ポート番号でウエブサーバーを実行(デフォルト=9930)")
|
||||
|
|
174
page.go
174
page.go
|
@ -2,50 +2,12 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
"bytes"
|
||||
|
||||
"golang.org/x/net/html"
|
||||
"golang.org/x/text/encoding/japanese"
|
||||
"golang.org/x/text/transform"
|
||||
)
|
||||
|
||||
/* PHPであるstrip_tagsはGo言語で存在しないから、自分で作る */
|
||||
func strip_tags(data string) string {
|
||||
doc, err := html.Parse(strings.NewReader(data))
|
||||
if err != nil {
|
||||
panic("HTMLをパーシングに失敗。")
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
var f func(*html.Node)
|
||||
f = func(n *html.Node) {
|
||||
if n.Type == html.TextNode {
|
||||
buf.WriteString(n.Data)
|
||||
}
|
||||
for c := n.FirstChild; c != nil; c = c.NextSibling {
|
||||
f(c)
|
||||
}
|
||||
}
|
||||
f(doc)
|
||||
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
func EUCJPToUTF8(input []byte) (string, error) {
|
||||
transformer := japanese.EUCJP.NewDecoder()
|
||||
reader := transform.NewReader(bytes.NewReader(input), transformer)
|
||||
result, err := ioutil.ReadAll(reader)
|
||||
if err != nil {
|
||||
return "エンコーディングに失敗", err
|
||||
}
|
||||
|
||||
return string(result), nil
|
||||
}
|
||||
|
||||
/* ページのタイトル */
|
||||
func gettitle(str string) string {
|
||||
re := regexp.MustCompile("<title>(.*)</title>")
|
||||
|
@ -71,120 +33,6 @@ func getdesc(str string) string {
|
|||
return strip_tags(res)
|
||||
}
|
||||
|
||||
/* 記事かの確認 */
|
||||
func isarticle(url string) bool {
|
||||
chk := strings.Split(url, "=")
|
||||
return len(chk) > 2 && chk[0] == "/view_news.pl?id"
|
||||
}
|
||||
|
||||
/* カテゴリーだけが残るまで消す */
|
||||
func rmcbloat(body string, cnf Config) string {
|
||||
var re *regexp.Regexp
|
||||
|
||||
rep := []struct {
|
||||
pat string
|
||||
repl string
|
||||
}{
|
||||
{`(?s)<!DOCTYPE html>.*?<!--注目のニュース-->`, ""},
|
||||
{`(?s)<!--/newsCategoryList-->.*?</html>`, ""},
|
||||
{`(?s)<div class="COMMONDOC_header2017_mainNavHeader.*?</div>`, ""},
|
||||
{`(?s)<div class="COMMONDOC_header2017_mainNav.*?</div>`, ""},
|
||||
{`(?s)<div class="COMMONDOC_header2017_toggleNav.*?</div>`, ""},
|
||||
{`(?s)<div class="COMMONDOC_header2017_localNavArea.*?</div>`, ""},
|
||||
{`(?s)<div class="COMMONDOC_header2017_globalNav__account.*?</div>`, ""},
|
||||
{`(?s)<div class="COMMONDOC_header2017_globalNav__logo.*?</div>`, ""},
|
||||
{`(?s)<div class="COMMONDOC_header2017_globalNav__toggleNav.*?</div>`, ""},
|
||||
{`(?s)<div class="COMMONDOC_header2017_adBanner.*?</div>`, ""},
|
||||
{`(?s)<div class="COMMONDOC_header2017_globalNav.*?</div>`, ""},
|
||||
{`(?s)<div class="COMMONDOC_header2017_globalNavArea.*?</div>`, ""},
|
||||
{`(?s)<div class="COMMONDOC_header2017_headerArea.*?</div>`, ""},
|
||||
{`(?s)<div id="page" class="FRAME2016_page">.*?</div>`, ""},
|
||||
{`(?s)<div id="subCategoryNavi.*?</div>`, ""},
|
||||
{`(?s)<div role="navigation".*?</div>`, ""},
|
||||
{`(?s)<div id="div-gpt-ad-.*?</div>`, ""},
|
||||
{`(?s)<h3.*?</h3>`, ""},
|
||||
{`(?s)<script.*?</script>`, ""},
|
||||
{`(?s)<ul class="entryList0.*?</ul>`, ""},
|
||||
{`(?s)<div class="adMain.*?</div>`, ""},
|
||||
{`(?s)<div class="gAdComponent.*?</div>`, ""},
|
||||
{`(?s)<div class="adsense0.*?</div>`, ""},
|
||||
{`(?s)<div class="adsense.*?</div>`, ""},
|
||||
{`(?s)<div class="pageList02.*?</div>`, ""},
|
||||
{`(?s)<span class="reactionCountBalloon.*?</span>`, ""},
|
||||
{`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 + `/`},
|
||||
{`・ `, ""},
|
||||
{`\[`, ""},
|
||||
{`\]`, ""},
|
||||
}
|
||||
|
||||
for _, r := range rep {
|
||||
re = regexp.MustCompile(r.pat)
|
||||
body = re.ReplaceAllString(body, r.repl)
|
||||
}
|
||||
|
||||
body = strings.TrimSpace("<div class=\"subCategoryNavi\" class=\"LEGACY_UI2016_subCategoryNavi\">\n" + strings.TrimSpace(body)) + "\n </div>\n"
|
||||
return "<div class=\"newsArticle\">" + body + "</div>"
|
||||
}
|
||||
|
||||
/* エラーだけが残るまで消す */
|
||||
func rmebloat(body string, cnf Config) string {
|
||||
var re *regexp.Regexp
|
||||
|
||||
rep := []struct {
|
||||
pat string
|
||||
repl string
|
||||
}{
|
||||
{`(?s)<!DOCTYPE html>.*?<p class="messageAlert">`, ""},
|
||||
{`(?s)</p>.*?</html>`, ""},
|
||||
}
|
||||
|
||||
for _, r := range rep {
|
||||
re = regexp.MustCompile(r.pat)
|
||||
body = re.ReplaceAllString(body, r.repl)
|
||||
}
|
||||
|
||||
body = strings.TrimSpace("<div class=\"newsArticle\">\n" + strings.TrimSpace(body)) + "\n </div>\n"
|
||||
return body
|
||||
}
|
||||
|
||||
/* 記事だけが残るまで消す */
|
||||
func rmbloat(body string, cnf Config) string {
|
||||
var re *regexp.Regexp
|
||||
|
||||
rep := []struct {
|
||||
pat string
|
||||
repl string
|
||||
}{
|
||||
{`(?s)<!DOCTYPE html>.*?<div class="newsArticle">`, ""},
|
||||
{`(?s)<!--/newsArticle-->.*?</html>`, ""},
|
||||
{`(?s)<p class="reactions">.*?</p>`, ""},
|
||||
{`(?s)<ul class="diaryUtility\d*">.*?</ul>`, ""},
|
||||
{`(?s)<table>.*?</table>`, ""},
|
||||
{`(?s)<div class="adsense0.*?</div>`, ""},
|
||||
{`(?s)<div class="adsense.*?</div>`, ""},
|
||||
{`www\.?youtube\.com`, "youtube.owacon.moe"},
|
||||
{`(?s)<div class="subInfo">.*?</div>`, ""},
|
||||
{`(?s)<div class="additional\d*.*?</div>`, ""},
|
||||
{`(?s)(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+`, "\n"},
|
||||
{`<!--article_image-->`, ""},
|
||||
{`<!--/article_image-->`, ""},
|
||||
{`(?s)<!--.*?-->`, ""},
|
||||
{`<!--`, ""},
|
||||
{`(?s)<img src="https://(.*?)"`, `<img src="` + cnf.imgproxy + `/$1"`},
|
||||
{`https://news-image.mixi.net`, cnf.imgproxy + `/news-image.mixi.net`},
|
||||
}
|
||||
|
||||
for _, r := range rep {
|
||||
re = regexp.MustCompile(r.pat)
|
||||
body = re.ReplaceAllString(body, r.repl)
|
||||
}
|
||||
|
||||
body = strings.TrimSpace("<div class=\"newsArticle\">\n" + strings.TrimSpace(body)) + "\n </div>\n"
|
||||
return body
|
||||
}
|
||||
|
||||
/* 記事の受取 */
|
||||
func get(url string, cnf Config) map[string]string {
|
||||
// デフォルト=エラー
|
||||
|
@ -215,7 +63,7 @@ func get(url string, cnf Config) map[string]string {
|
|||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
bytebody, err := ioutil.ReadAll(resp.Body)
|
||||
bytebody, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
res["err"] = "内容はバイトコードとして読み込みに失敗。"
|
||||
fmt.Println(res["err"])
|
||||
|
@ -229,13 +77,29 @@ func get(url string, cnf Config) map[string]string {
|
|||
return res
|
||||
}
|
||||
|
||||
id, _ := getid(url)
|
||||
|
||||
res["title"] = gettitle(body)
|
||||
if isarticle(url) {
|
||||
if !strings.Contains(body, "newsArticle") {
|
||||
res["content"] = rmebloat(body, cnf)
|
||||
} else {
|
||||
res["img"] = getimg(body, cnf)
|
||||
res["content"] = rmbloat(body, cnf)
|
||||
res["content"] = rmbloat(id, body, cnf)
|
||||
}
|
||||
} else if ispublish(url) {
|
||||
res["content"] = rmpbloat(body, cnf)
|
||||
} else if issubcat(url) {
|
||||
if strings.Contains(body, `<p class="messageAlert">存在しないカテゴリです</p>`) {
|
||||
res["content"] = rmebloat(body, cnf)
|
||||
} else {
|
||||
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 {
|
||||
if !strings.Contains(body, "注目のニュース") {
|
||||
|
|
|
@ -0,0 +1,203 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
/* カテゴリーだけが残るまで消す */
|
||||
func rmcbloat(body string, cnf Config) string {
|
||||
var re *regexp.Regexp
|
||||
|
||||
rep := []struct {
|
||||
pat string
|
||||
repl string
|
||||
}{
|
||||
{`(?s)<!DOCTYPE html>.*?<!--注目のニュース-->`, ""},
|
||||
{`(?s)<!--/newsCategoryList-->.*?</html>`, ""},
|
||||
{`(?s)<div class="COMMONDOC_header2017_mainNavHeader.*?</div>`, ""},
|
||||
{`(?s)<div class="COMMONDOC_header2017_mainNav.*?</div>`, ""},
|
||||
{`(?s)<div class="COMMONDOC_header2017_toggleNav.*?</div>`, ""},
|
||||
{`(?s)<div class="COMMONDOC_header2017_localNavArea.*?</div>`, ""},
|
||||
{`(?s)<div class="COMMONDOC_header2017_globalNav__account.*?</div>`, ""},
|
||||
{`(?s)<div class="COMMONDOC_header2017_globalNav__logo.*?</div>`, ""},
|
||||
{`(?s)<div class="COMMONDOC_header2017_globalNav__toggleNav.*?</div>`, ""},
|
||||
{`(?s)<div class="COMMONDOC_header2017_adBanner.*?</div>`, ""},
|
||||
{`(?s)<div class="COMMONDOC_header2017_globalNav.*?</div>`, ""},
|
||||
{`(?s)<div class="COMMONDOC_header2017_globalNavArea.*?</div>`, ""},
|
||||
{`(?s)<div class="COMMONDOC_header2017_headerArea.*?</div>`, ""},
|
||||
{`(?s)<div id="page" class="FRAME2016_page">.*?</div>`, ""},
|
||||
{`(?s)<div id="subCategoryNavi.*?</div>`, ""},
|
||||
{`(?s)<div role="navigation".*?</div>`, ""},
|
||||
{`(?s)<div id="div-gpt-ad-.*?</div>`, ""},
|
||||
{`(?s)<h3.*?</h3>`, ""},
|
||||
{`(?s)<script.*?</script>`, ""},
|
||||
{`(?s)<ul class="entryList0.*?</ul>`, ""},
|
||||
{`(?s)<div class="adMain.*?</div>`, ""},
|
||||
{`(?s)<div class="gAdComponent.*?</div>`, ""},
|
||||
{`(?s)<div class="adsense0.*?</div>`, ""},
|
||||
{`(?s)<div class="adsense.*?</div>`, ""},
|
||||
{`(?s)<div class="pageList02.*?</div>`, ""},
|
||||
{`(?s)<span class="reactionCountBalloon.*?</span>`, ""},
|
||||
{`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 + `/`},
|
||||
{`・ `, ""},
|
||||
{`\[`, ""},
|
||||
{`\]`, ""},
|
||||
}
|
||||
|
||||
for _, r := range rep {
|
||||
re = regexp.MustCompile(r.pat)
|
||||
body = re.ReplaceAllString(body, r.repl)
|
||||
}
|
||||
|
||||
body = strings.TrimSpace("<div class=\"subCategoryNavi\" class=\"LEGACY_UI2016_subCategoryNavi\">\n" + strings.TrimSpace(body)) + "\n </div>\n"
|
||||
return "<div class=\"newsArticle\">\n<a class=\"totop\" href=\"/\">トップへ</a>\n" + body + "</div>"
|
||||
}
|
||||
|
||||
/* エラーだけが残るまで消す */
|
||||
func rmebloat(body string, cnf Config) string {
|
||||
var re *regexp.Regexp
|
||||
|
||||
rep := []struct {
|
||||
pat string
|
||||
repl string
|
||||
}{
|
||||
{`(?s)<!DOCTYPE html>.*?<p class="messageAlert">`, ""},
|
||||
{`(?s)</p>.*?</html>`, ""},
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
/* つばやきだけが残るまで消す */
|
||||
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
|
||||
}
|
||||
|
||||
/* 部分圏だけが残るまで消す */
|
||||
func rmsbloat(body string, cnf Config) string {
|
||||
var re *regexp.Regexp
|
||||
|
||||
rep := []struct {
|
||||
pat string
|
||||
repl string
|
||||
}{
|
||||
{`(?s)<!DOCTYPE html>.*?<!-- InstanceBeginEditable name="bodyMain" -->`, ""},
|
||||
{`(?s)<div class="adsenseBannerArea">.*?</html>`, ""},
|
||||
{`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 + `/`},
|
||||
{`・ `, ""},
|
||||
{`\[`, ""},
|
||||
{`\]`, ""},
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
/* 出版社だけが残るまで消す */
|
||||
func rmpbloat(body string, cnf Config) string {
|
||||
var re *regexp.Regexp
|
||||
|
||||
rep := []struct {
|
||||
pat string
|
||||
repl string
|
||||
}{
|
||||
{`(?s)<!DOCTYPE html>.*?<!-- InstanceBeginEditable name="bodyMain" -->`, ""},
|
||||
{`(?s)<!-- InstanceEndEditable -->.*?</html>`, ""},
|
||||
{`(?s)<div class="pageList02.*?</div>`, ""},
|
||||
{`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 + `/`},
|
||||
{`・ `, ""},
|
||||
{`\[`, ""},
|
||||
{`\]`, ""},
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
/* 記事だけが残るまで消す */
|
||||
func rmbloat(id string, body string, cnf Config) string {
|
||||
var re *regexp.Regexp
|
||||
|
||||
rep := []struct {
|
||||
pat string
|
||||
repl string
|
||||
}{
|
||||
{`(?s)<!DOCTYPE html>.*?<div class="newsArticle">`, ""},
|
||||
{`(?s)<!--/newsArticle-->.*?</html>`, ""},
|
||||
{`(?s)<p class="reactions">.*?</p>`, ""},
|
||||
{`(?s)<ul class="diaryUtility\d*">.*?</ul>`, ""},
|
||||
{`(?s)<table>.*?</table>`, ""},
|
||||
{`(?s)<div class="adsense0.*?</div>`, ""},
|
||||
{`(?s)<div class="adsense.*?</div>`, ""},
|
||||
{`www\.?youtube\.com`, "youtube.owacon.moe"},
|
||||
{`(?s)<div class="subInfo">.*?</div>`, ""},
|
||||
{`(?s)<div class="additional\d*.*?</div>`, ""},
|
||||
{`(?s)(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+`, "\n"},
|
||||
{`<!--article_image-->`, ""},
|
||||
{`<!--/article_image-->`, ""},
|
||||
{`(?s)<!--.*?-->`, ""},
|
||||
{`<!--`, ""},
|
||||
{`(?s)<img src="https://(.*?)"`, `<img src="` + cnf.imgproxy + `/$1"`},
|
||||
{`https://news-image.mixi.net`, cnf.imgproxy + `/news-image.mixi.net`},
|
||||
{`https://news.mixi.jp/`, cnf.domain + `/`},
|
||||
}
|
||||
|
||||
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))
|
||||
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
|
||||
}
|
145
static/style.css
145
static/style.css
|
@ -10,6 +10,7 @@ body {
|
|||
|
||||
a {
|
||||
color: #ea5fea;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
h1, h2 {
|
||||
|
@ -44,13 +45,35 @@ code {
|
|||
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 {
|
||||
width: calc(100% - 20px);
|
||||
max-width: 1200px;
|
||||
background: #31363b;
|
||||
border: 2px solid #4d4d4d;
|
||||
border-radius: 10px;
|
||||
margin: auto;
|
||||
margin: 32px auto;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
|
@ -89,7 +112,10 @@ code {
|
|||
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,
|
||||
.pageList02 > ul > li {
|
||||
background-color: #4d4d4d;
|
||||
padding: 4px;
|
||||
border: 1px solid #c625ef;
|
||||
|
@ -97,18 +123,114 @@ code {
|
|||
text-decoration: none;
|
||||
}
|
||||
|
||||
.pageList01 > div > ul {
|
||||
.pageList01 > div > ul > li:not([class]):hover,
|
||||
.pageList01 > ul > li:hover,
|
||||
ul.sortTab > li:hover,
|
||||
.pageList02 > ul > li[rel="__prev"]:hover,
|
||||
.pageList02 > ul > li[rel="__next"]:hover,
|
||||
li.NEWS_pickupNewsItem:hover,
|
||||
p.NEWS_pickupItems__moreLink:hover,
|
||||
li.newCategoryList > a:hover,
|
||||
.photoNewsArea > a:hover,
|
||||
.NEWS_photoNewsItems__contentsArea:hover,
|
||||
a.tubuyaki-btn:hover,
|
||||
p.first:hover, p.last:hover,
|
||||
tr.odd:hover, tr.even:hover, .totop:hover {
|
||||
background-color: #ae6bdb;
|
||||
}
|
||||
|
||||
.pageNavigation02 > p, .pageList01 > ul > li, .pageList02 > 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, .pageList02 > ul > li {
|
||||
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,
|
||||
.pageList02 > 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;
|
||||
}
|
||||
|
||||
.newsCategoryList {
|
||||
.pageList02 {
|
||||
text-align: center;
|
||||
padding-top: 8px;
|
||||
}
|
||||
|
||||
.relationNewsDescription {
|
||||
margin-top: 18px;
|
||||
}
|
||||
|
||||
.relationNewsDescription > p.date {
|
||||
border-left: 3px solid #f976de;
|
||||
padding: 0 0 0 8px;
|
||||
}
|
||||
|
||||
ul.voiceList01 {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.pageNavigation02 {
|
||||
display: ruby;
|
||||
}
|
||||
|
||||
.newsCategoryList, .timestamp, .iine, .comment, .item {
|
||||
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 {
|
||||
text-align: center;
|
||||
}
|
||||
|
@ -129,3 +251,16 @@ code {
|
|||
text-align: center;
|
||||
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" .}}
|
||||
<a href="/">トップへ</a>
|
||||
{{ .Bdy }}
|
||||
{{template "footer" .}}
|
||||
|
|
読み込み中…
新しいイシューから参照