コミットを比較
3 コミット
c5ce8b8647
...
fea93bdad0
作成者 | SHA1 | 日付 |
---|---|---|
守矢諏訪子 | fea93bdad0 | |
守矢諏訪子 | f45290221e | |
守矢諏訪子 | 8d7de23cdf |
|
@ -1,3 +1,7 @@
|
|||
# 1.3.0
|
||||
* BSD2clause→ISCライセンスに変更
|
||||
* 変なエンコーディングの変換
|
||||
|
||||
# 1.2.0
|
||||
* 静的ファイルの修正
|
||||
* 新しいルールに従い
|
||||
|
|
21
LICENSE.txt
21
LICENSE.txt
|
@ -1,11 +1,14 @@
|
|||
BSD 2-Clause License
|
||||
Copyright © 2004-2011 by Internet Systems Consortium, Inc. ("ISC")
|
||||
Copyright © 2018-2024 by 076.moe
|
||||
|
||||
Copyright 2024 テクニカル諏訪子
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
|
||||
TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
|
||||
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
SOFTWARE.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package common
|
||||
|
||||
var sofname = "hozonsite"
|
||||
var version = "1.2.0"
|
||||
var version = "1.3.0"
|
||||
|
||||
func GetSofname() string {
|
||||
return sofname
|
||||
|
|
2
go.mod
2
go.mod
|
@ -3,3 +3,5 @@ module gitler.moe/suwako/hozonsite
|
|||
go 1.20
|
||||
|
||||
require gitler.moe/suwako/goliblocale v1.0.0
|
||||
|
||||
require golang.org/x/text v0.14.0 // indirect
|
||||
|
|
2
go.sum
2
go.sum
|
@ -1,2 +1,4 @@
|
|||
gitler.moe/suwako/goliblocale v1.0.0 h1:QiQKNzdgpavwmAaYhAb5pth0I6qS8IJ7q2hYAgpXacU=
|
||||
gitler.moe/suwako/goliblocale v1.0.0/go.mod h1:pdv9Go5taevY8ClBOA+oLXjGap7G1RmIVKUMF8HSJmU=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
|
|
|
@ -5,7 +5,11 @@ import (
|
|||
"fmt"
|
||||
"net/http"
|
||||
"io"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/text/encoding/japanese"
|
||||
"golang.org/x/text/transform"
|
||||
)
|
||||
|
||||
// URLでパラメートル(?、=等)がある場合
|
||||
|
@ -22,7 +26,8 @@ func Getpage (url string, path string) {
|
|||
fmt.Println("CURLエラー:", err)
|
||||
return
|
||||
}
|
||||
defer curl.Body.Close() // ソフトの終了する時に実行する
|
||||
// ソフトの終了する時に実行する
|
||||
defer curl.Body.Close()
|
||||
|
||||
// ページの内容を読み込む
|
||||
body, err2 := io.ReadAll(curl.Body)
|
||||
|
@ -31,17 +36,62 @@ func Getpage (url string, path string) {
|
|||
return
|
||||
}
|
||||
|
||||
// 空index.htmlファイルを創作する
|
||||
fn, err3 := os.Create(path + "/index.html")
|
||||
if err3 != nil {
|
||||
fmt.Println("ファイルの創作エラー:", err3)
|
||||
// Content-TypeヘッダーはUTF-8又は駄目のエンコーディングかの確認
|
||||
checkJis := `(?i)<meta.*?charset=(["']?)shift[_-]?jis`
|
||||
jisRegex, errr := regexp.Compile(checkJis)
|
||||
if errr != nil {
|
||||
fmt.Println(errr)
|
||||
return
|
||||
}
|
||||
defer fn.Close() // ソフトの終了する時に実行する
|
||||
|
||||
checkEuc := `(?i)<meta.*?charset=(["']?)euc[_-]?jp`
|
||||
eucRegex, erre := regexp.Compile(checkEuc)
|
||||
if erre != nil {
|
||||
fmt.Println(erre)
|
||||
return
|
||||
}
|
||||
|
||||
// 文字エンコーディングを変換する
|
||||
if jisRegex.Match(body) {
|
||||
shiftJISDecoder := japanese.ShiftJIS.NewDecoder()
|
||||
utf8Reader := transform.NewReader(
|
||||
strings.NewReader(string(body)),
|
||||
shiftJISDecoder,
|
||||
)
|
||||
utf8Body, err3 := io.ReadAll(utf8Reader)
|
||||
if err3 != nil {
|
||||
fmt.Println("文字エンコーディング変換エラー:", err3)
|
||||
return
|
||||
}
|
||||
|
||||
body = utf8Body
|
||||
} else if eucRegex.Match(body) {
|
||||
eucJPDecoder := japanese.EUCJP.NewDecoder()
|
||||
utf8Reader := transform.NewReader(
|
||||
strings.NewReader(string(body)),
|
||||
eucJPDecoder,
|
||||
)
|
||||
utf8Body, err3 := io.ReadAll(utf8Reader)
|
||||
if err3 != nil {
|
||||
fmt.Println("文字エンコーディング変換エラー:", err3)
|
||||
return
|
||||
}
|
||||
|
||||
body = utf8Body
|
||||
}
|
||||
|
||||
// 空index.htmlファイルを創作する
|
||||
fn, err4 := os.Create(path + "/index.html")
|
||||
if err4 != nil {
|
||||
fmt.Println("ファイルの創作エラー:", err4)
|
||||
return
|
||||
}
|
||||
// ソフトの終了する時に実行する
|
||||
defer fn.Close()
|
||||
|
||||
// あのindex.htmlファイルに内容をそのまま書き込む
|
||||
_, err4 := fn.WriteString(string(body))
|
||||
if err4 != nil {
|
||||
fmt.Println("ファイル書込エラー:", err4)
|
||||
_, err5 := fn.WriteString(string(body))
|
||||
if err5 != nil {
|
||||
fmt.Println("ファイル書込エラー:", err5)
|
||||
}
|
||||
}
|
||||
|
|
読み込み中…
新しいイシューから参照