-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9381ac7
Showing
11 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "大岩潤矢", | ||
"hira_name": "おおいわじゅんや", | ||
"alp_name": "Junya Oiwa", | ||
"school": "東京都市大学", | ||
"department": "メディア情報学部 社会メディア学科", | ||
"grade": "3", | ||
"profile_url": "https://res.cloudinary.com/oj920/image/upload/w_600/q_auto/v1610184430/920oj-net/profile_c9reqy.jpg", | ||
"logo_url": "https://res.cloudinary.com/oj920/image/upload/v1610184429/920oj-net/logo_fd84tv.png" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# title | ||
|
||
- list1 | ||
- list2 | ||
|
||
## title2 | ||
|
||
this is markdown. | ||
hello, world. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module github.com/920oj/oj-portfolio-go | ||
|
||
go 1.15 | ||
|
||
require ( | ||
github.com/otiai10/copy v1.4.2 // indirect | ||
github.com/russross/blackfriday/v2 v2.1.0 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
github.com/otiai10/copy v1.4.2 h1:RTiz2sol3eoXPLF4o+YWqEybwfUa/Q2Nkc4ZIUs3fwI= | ||
github.com/otiai10/copy v1.4.2/go.mod h1:XWfuS3CrI0R6IE0FbgHsEazaXO8G0LpMp9o8tos0x4E= | ||
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= | ||
github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= | ||
github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= | ||
github.com/otiai10/mint v1.3.2/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= | ||
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= | ||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= | ||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"fmt" | ||
"io" | ||
"io/ioutil" | ||
"os" | ||
"text/template" | ||
|
||
Copy "github.com/otiai10/copy" | ||
"github.com/russross/blackfriday/v2" | ||
) | ||
|
||
// InputData 入力データ | ||
type InputData struct { | ||
Name string `json:"name"` | ||
HiraName string `json:"hira_name"` | ||
AlpName string `json:"alp_name"` | ||
School string `json:"school"` | ||
Department string `json:"department"` | ||
Grade string `json:"grade"` | ||
ProfileURL string `json:"profile_url"` | ||
LogoURL string `json:"logo_url"` | ||
HTML string | ||
} | ||
|
||
func main() { | ||
// Markdownファイル読み込み | ||
md, err := ioutil.ReadFile("./contents/index.md") | ||
if err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
return | ||
} | ||
|
||
// 設定ファイル読み込み | ||
conf, err := ioutil.ReadFile("./conf/conf.json") | ||
if err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
return | ||
} | ||
|
||
// MarkdownをHTML化 | ||
html := blackfriday.Run(md, blackfriday.WithNoExtensions()) | ||
|
||
// 設定ファイルとHTML化したMarkdownを一つの構造体に移す | ||
data := new(InputData) | ||
err = json.Unmarshal([]byte(conf), data) | ||
data.HTML = string(html) | ||
|
||
// 書き出し準備 | ||
buff := new(bytes.Buffer) | ||
fw := io.Writer(buff) | ||
|
||
// テンプレートファイルを読み込んで変換する | ||
t := template.Must(template.ParseFiles("./templates/index.html.tql")) | ||
if err := t.ExecuteTemplate(fw, "index.html.tql", data); err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
} | ||
|
||
// ファイル書き込み | ||
err = writeBytes("./dist/index.html", buff.Bytes()) | ||
if err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
return | ||
} | ||
|
||
err = Copy.Copy("./public", "./dist") | ||
if err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
return | ||
} | ||
} | ||
|
||
func writeBytes(filename string, lines []byte) error { | ||
file, err := os.OpenFile(filename, os.O_CREATE, 0666) | ||
if err != nil { | ||
return err | ||
} | ||
defer file.Close() | ||
|
||
_, err = file.Write(lines) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<html lang="ja"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="./reset.css" /> | ||
<title>OJ Portfolio</title> | ||
</head> | ||
|
||
<body> | ||
<header> | ||
<img src="{{ .LogoURL }}" alt="logo"> | ||
</header> | ||
<main> | ||
<div class="introduction"> | ||
<div class="profile_img"> | ||
<img src="{{ .ProfileURL }}" alt="profile"> | ||
</div> | ||
<div class="profile_text"> | ||
<p>{{ .Name }}<br>{{ .HiraName }} / {{ .AlpName }}</p> | ||
<p>{{ .School }} {{ .Department }} {{ .Grade }}年</p> | ||
</div> | ||
</div> | ||
<div class="portfolio"> | ||
{{ .HTML }} | ||
</div> | ||
</main> | ||
</body> | ||
|
||
</html> |