├── dark.jpg ├── light.jpg ├── favicon.ico ├── .dockerignore ├── .gitignore ├── .gitattributes ├── web ├── views │ ├── article.html │ ├── errors │ │ ├── 404.html │ │ └── 500.html │ ├── home.html │ ├── categories.html │ └── layouts │ │ └── layout.html └── assets │ ├── fonts │ ├── fontawesome-webfont.eot │ ├── fontawesome-webfont.ttf │ ├── fontawesome-webfont.woff │ └── fontawesome-webfont.woff2 │ ├── css │ ├── animation.css.map │ ├── style.css.map │ ├── jquery.simplyscroll.css │ ├── prism.css │ ├── style-dark.css.map │ ├── animation.css │ ├── style.css │ └── style-dark.css │ └── js │ ├── main.js │ ├── typography.js │ ├── jquery.appear.js │ ├── jquery.slimscroll.min.js │ ├── jquery-migrate-1.2.1.min.js │ ├── jquery.simplyscroll.min.js │ └── bootstrap.min.js ├── internal ├── types │ ├── githubstr.go │ ├── analyzer.go │ ├── gitalk.go │ └── GlobleDatas.go ├── utils │ ├── TimeTrack.go │ ├── helper.go │ └── explorer.go ├── api │ └── ErrorResponse.go ├── app │ ├── filebaseReader.go │ ├── githubReader.go │ └── app.go └── bindata │ └── views │ └── views.go ├── Dockerfile.Develop ├── Dockerfile ├── .vscode └── launch.json ├── config └── config.yml.tmp ├── makefile ├── go.mod ├── package.sh ├── main.go ├── README.md └── go.sum /dark.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hotuns/go-markdown-book/HEAD/dark.jpg -------------------------------------------------------------------------------- /light.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hotuns/go-markdown-book/HEAD/light.jpg -------------------------------------------------------------------------------- /favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hotuns/go-markdown-book/HEAD/favicon.ico -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | md 3 | package 4 | cache 5 | web 6 | config 7 | internal 8 | bin -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | md/ 3 | cache/ 4 | package/ 5 | build/ 6 | config/* 7 | !config/config.yml.tmp -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.js linguist-language=go 2 | *.css linguist-language=go 3 | *.html linguist-language=go 4 | -------------------------------------------------------------------------------- /web/views/article.html: -------------------------------------------------------------------------------- 1 |
{{.Preview}}
12 |分类
4 |分类 {{.Categorie}}
19 |更新前 %d 篇文章, 更新后 %d 篇文章
", oldLen, nowLen) 133 | return 134 | } 135 | }) 136 | 137 | app.Run(iris.Addr(":" + strconv.Itoa(parsePort(ctx)))) 138 | 139 | return nil 140 | } 141 | 142 | func initParams(ctx *cli.Context) { 143 | // 设置文件来源 144 | Origin = ctx.String("origin") 145 | 146 | if Origin == "github" { 147 | GithubStr.Owner = ctx.String("github.owner") 148 | GithubStr.Repo = ctx.String("github.repo") 149 | } 150 | 151 | MdDir = ctx.String("dir") 152 | if strings.TrimSpace(MdDir) == "" { 153 | log.Panic("Markdown files folder cannot be empty") 154 | } 155 | MdDir, _ = filepath.Abs(MdDir) 156 | 157 | Env = ctx.String("env") 158 | Title = ctx.String("title") 159 | Title2 = ctx.String("title2") 160 | 161 | _cache := ctx.Int("cache") 162 | 163 | Cache = time.Minute * time.Duration(_cache) 164 | if Env == "dev" { 165 | Cache = time.Minute * 0 166 | } 167 | 168 | // 设置分析器 169 | Analyzer.SetAnalyzer(ctx.String("analyzer-baidu"), ctx.String("analyzer-google")) 170 | 171 | // 设置Gitalk 172 | Gitalk.SetGitalk(ctx.String("gitalk.client-id"), ctx.String("gitalk.client-secret"), ctx.String("gitalk.repo"), ctx.String("gitalk.owner"), ctx.StringSlice("gitalk.admin"), ctx.StringSlice("gitalk.labels")) 173 | 174 | // 忽略文件 175 | IgnoreFile = append(IgnoreFile, ctx.StringSlice("ignore-file")...) 176 | IgnorePath = append(IgnorePath, ctx.StringSlice("ignore-path")...) 177 | } 178 | 179 | func setLog(app *iris.Application) { 180 | os.MkdirAll(LogsDir, 0777) 181 | f, _ := os.OpenFile(LogsDir+"access-"+time.Now().Format("20060102")+".log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0o600) 182 | 183 | if Env == "prod" { 184 | app.Logger().SetOutput(f) 185 | } else { 186 | app.Logger().SetLevel("debug") 187 | app.Logger().Debugf(`Log level set to "debug"`) 188 | } 189 | 190 | // Close the file on shutdown. 191 | app.ConfigureHost(func(su *iris.Supervisor) { 192 | su.RegisterOnShutdown(func() { 193 | f.Close() 194 | }) 195 | }) 196 | 197 | ac := accesslog.New(f) 198 | ac.AddOutput(app.Logger().Printer) 199 | app.UseRouter(ac.Handler) 200 | app.Logger().Debugf("Using <%s> to log requests", f.Name()) 201 | } 202 | 203 | func parsePort(ctx *cli.Context) int { 204 | port := DefaultPort 205 | if ctx.IsSet("port") { 206 | port = ctx.Int("port") 207 | } 208 | if port <= 0 || port >= 65535 { 209 | port = DefaultPort 210 | } 211 | 212 | return port 213 | } 214 | -------------------------------------------------------------------------------- /web/views/layouts/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |