Skip to content

Commit

Permalink
fixes #11
Browse files Browse the repository at this point in the history
  • Loading branch information
hjhee committed Apr 27, 2020
1 parent 3878d6d commit f66d916
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ func homepageParser(done <-chan struct{}, page *HTMLPage, pc *PageChannel, tmMap
}
log.Printf("[homepage] Title: %s", title)
tf.Title = title
// issue #11 add url to page content
tf.Url = page.URL.String()

var pageNum int64
if s := doc.Find("span.red").Eq(1); s.Text() == "" {
Expand Down
3 changes: 2 additions & 1 deletion template.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@ func renderHTML(done <-chan struct{}, tempc <-chan *TemplateField, tmpl *templat
err = writeOutput(filename, func(w *bufio.Writer) error {
if err := tmpl.Execute(w, struct {
Title string
Url string
Comments []*OutputField
Lzls map[uint64]*LzlComment
}{Title: t.Title, Comments: t.Comments, Lzls: t.Lzls.Map}); err != nil {
}{Title: t.Title, Url: t.Url, Comments: t.Comments, Lzls: t.Lzls.Map}); err != nil {
return fmt.Errorf("error executing template %s: %v", filename, err)
}
return nil
Expand Down
3 changes: 3 additions & 0 deletions template/template1.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
</style>
</head>
<body>
<h1>{{.Title}}</h1>
<div><a href="{{.Url}}">{{.Url}}</a></div>
<hr />
{{range .Comments}}
<div>
<div>
Expand Down
1 change: 1 addition & 0 deletions type.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ func (lzl *LzlMap) IsExist(k uint64) bool {
// TemplateField stores all necessary information to render a HTML page
type TemplateField struct {
Title string
Url string
ThreadID uint64
Comments []*OutputField
pagesLeft int64
Expand Down

0 comments on commit f66d916

Please sign in to comment.