Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added public prefix for oathkeeper. #5

Merged
merged 1 commit into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions util/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package util

import (
"encoding/json"
"fmt"
"html/template"
"time"

"github.com/factly/dega-vito/util/editorjs"
"github.com/jinzhu/gorm/dialects/postgres"
"github.com/spf13/viper"
)

// Template template object
Expand All @@ -15,11 +17,12 @@ var Template *template.Template
// SetupTemplates setups the templates
func SetupTemplates() {
Template = template.Must(template.New("").Funcs(template.FuncMap{
"unmar": unmarshal,
"bmap": editorjs.BlockMap,
"dateFmt": formatDate,
"dateVal": validateDate,
"noesc": noescape,
"unmar": unmarshal,
"bmap": editorjs.BlockMap,
"dateFmt": formatDate,
"dateVal": validateDate,
"noesc": noescape,
"publicURL": publicURL,
}).ParseGlob("web/themes/default/*"))
}

Expand All @@ -40,3 +43,10 @@ func validateDate(date time.Time) bool {
func noescape(str string) template.HTML {
return template.HTML(str)
}

func publicURL(str string) string {
if viper.IsSet("public_prefix") {
return fmt.Sprint(viper.GetString("public_prefix") + str)
}
return str
}
4 changes: 2 additions & 2 deletions web/themes/default/authorlist.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Author List</title>
<link rel="stylesheet" href="/default/css/main.css">
<link rel="stylesheet" href="{{publicURL "/default/css/main.css"}}">
</head>
<body>
<h1>Author List</h1>
Expand All @@ -19,7 +19,7 @@
<img style="width: 10%;" src="{{if $urlMap.proxy}} {{$urlMap.proxy}} {{else}} {{$urlMap.raw}} {{end}}">
<link rel="icon" href="{{if $urlMap.proxy}} {{$urlMap.proxy}} {{else}} {{$urlMap.raw}} {{end}}" />
{{end}}
<h3><a href="/authors/{{$author.ID}}">{{.FirstName}} {{.LastName}}</a></h3>
<h3><a href="{{print "/authors/" $author.ID | publicURL }}">{{.FirstName}} {{.LastName}}</a></h3>
<table>
<tr>
<td><b>Description:</b></td>
Expand Down
2 changes: 1 addition & 1 deletion web/themes/default/categorylist.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/default/css/main.css">
<link rel="stylesheet" href="{{publicURL "/default/css/main.css"}}">
<title>Category List</title>
</head>
<body>
Expand Down
3 changes: 3 additions & 0 deletions web/themes/default/description.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
{{end}}
</table>

{{else if eq .type "embed"}}
{{noesc .data.html}}

{{end}}
{{end}}
{{end}}
4 changes: 2 additions & 2 deletions web/themes/default/postlist.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Post List</title>
<link rel="stylesheet" href="/default/css/main.css">
<link rel="stylesheet" href="{{publicURL "/default/css/main.css"}}">
</head>
<body>

Expand All @@ -21,7 +21,7 @@
<link rel="icon" href="{{if $urlMap.proxy}} {{$urlMap.proxy}} {{else}} {{$urlMap.raw}} {{end}}" />
{{end}}
<br>
<h3><a href="/posts/{{$post.ID}}">{{$post.Title}}</a></h3>
<h3><a href="{{ print "/posts/" $post.Slug | publicURL}}">{{$post.Title}}</a></h3>
{{if dateVal $post.PublishedDate}} <b>Published Date:</b> {{$post.PublishedDate | dateFmt}} {{end}} <br>

<b>Authors:</b>
Expand Down
2 changes: 1 addition & 1 deletion web/themes/default/taglist.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/default/css/main.css">
<link rel="stylesheet" href="{{publicURL "/default/css/main.css"}}">
<title>Tag List</title>
</head>
<body>
Expand Down