Skip to content

Commit

Permalink
fix: template read from const
Browse files Browse the repository at this point in the history
  • Loading branch information
riza committed Jun 26, 2022
1 parent dc7e807 commit e28c306
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 33 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added internal/.DS_Store
Binary file not shown.
49 changes: 48 additions & 1 deletion internal/output/output_html.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,53 @@ import (
)

const templateFile = "./internal/output/output_html_template.html"
const templateRaw = `<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ .Target }} - linx report</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
</head>
<body>
<div class="container">
<div class="mb-5 pb-3 fs-4 border-bottom">
{{ .Target }}
</div>
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead>
<tr>
<th scope="col">URL</th>
<th scope="col">Location in file</th>
</tr>
</thead>
<tbody>
{{range .Results}}
<tr>
<td>{{ .URL }}</td>
<td>
<pre><code>{{ .Location }}</code></pre>
</td>
</tr>
{{end}}
</tbody>
</table>
</div>
<div class="mt-5 pt-3 text-muted border-top">
created with <a href="https://github.com/riza/linx">linx</a>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2"
crossorigin="anonymous"></script>
</body>
</html>`

type OutputHTML struct {
output OutputData
Expand All @@ -22,7 +69,7 @@ func (oh OutputHTML) RenderAndSave() error {
}
defer f.Close()

t, err := template.ParseFiles(templateFile)
t, err := template.New("output").Parse(templateRaw)
if err != nil {
return err
}
Expand Down
59 changes: 27 additions & 32 deletions internal/output/output_html_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,35 @@
</head>
<body>

<div class="col-lg-8 mx-auto p-3 py-md-5">
<header class="d-flex align-items-center pb-3 mb-5 border-bottom">
<a href="/" class="d-flex align-items-center text-dark text-decoration-none">
<span class="fs-4">{{ .Target }}</span>
</a>
</header>
<div class="container">
<div class="mb-5 pb-3 fs-4 border-bottom">
{{ .Target }}
</div>

<main>
<div class="row g-12">
<div class="col-md-12">
<table style="table-layout: fixed" class="table table-striped table-hover">
<thead>
<tr>
<th scope="col">URL</th>
<th scope="col">Location in file</th>
</tr>
</thead>
<tbody>
{{range .Results}}
<tr>
<td>{{ .URL }}</td>
<td>
<pre><code>{{ .Location }}</code></pre>
</td>
</tr>
{{end}}
</tbody>
</table>
</div>
</div>
</main>
<footer class="pt-5 my-5 text-muted border-top">
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead>
<tr>
<th scope="col">URL</th>
<th scope="col">Location in file</th>
</tr>
</thead>
<tbody>
{{range .Results}}
<tr>
<td>{{ .URL }}</td>
<td>
<pre><code>{{ .Location }}</code></pre>
</td>
</tr>
{{end}}
</tbody>
</table>
</div>

<div class="mt-5 pt-3 text-muted border-top">
created with <a href="https://github.com/riza/linx">linx</a>
</footer>
</div>
</div>

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
Expand Down

0 comments on commit e28c306

Please sign in to comment.