Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

feature: Better SEO title+description (#382)

Guilherme Oenning8f4ac39345e1
diff --git a/app/cmd/routes.go b/app/cmd/routes.go
index 5b2bf1ce4..d54d0dd13 100644
--- a/app/cmd/routes.go
+++ b/app/cmd/routes.go
@@ -106,8 +106,8 @@ func routes(r *web.Engine) *web.Engine {
private.Use(middlewares.IsAuthorized(models.RoleCollaborator, models.RoleAdministrator))
private.Get("/admin", handlers.GeneralSettingsPage())
- private.Get("/admin/privacy", handlers.Page())
- private.Get("/admin/invitations", handlers.Page())
+ private.Get("/admin/privacy", handlers.Page("Privacy · Site Settings", ""))
+ private.Get("/admin/invitations", handlers.Page("Invitations · Site Settings", ""))
private.Get("/admin/members", handlers.ManageMembers())
private.Get("/admin/tags", handlers.ManageTags())
private.Post("/api/admin/invitations/send", handlers.SendInvites())
@@ -115,7 +115,7 @@ func routes(r *web.Engine) *web.Engine {
private.Use(middlewares.IsAuthorized(models.RoleAdministrator))
- private.Get("/admin/export", handlers.Page())
+ private.Get("/admin/export", handlers.Page("Export · Site Settings", ""))
private.Get("/admin/export/ideas.csv", handlers.ExportIdeasToCSV())
private.Delete("/api/ideas/:number", handlers.DeleteIdea())
private.Post("/api/admin/settings/general", handlers.UpdateSettings())
diff --git a/app/handlers/admin.go b/app/handlers/admin.go
index ee9c20634..ae3b9f76e 100644
--- a/app/handlers/admin.go
+++ b/app/handlers/admin.go
@@ -13,8 +13,12 @@ func GeneralSettingsPage() web.HandlerFunc {
if err != nil {
c.Logger().Error(err)
}
- return c.Page(web.Map{
- "publicIP": publicIP,
+
+ return c.Page(web.Props{
+ Title: "General · Site Settings",
+ Data: web.Map{
+ "publicIP": publicIP,
+ },
})
}
}
@@ -60,8 +64,12 @@ func ManageMembers() web.HandlerFunc {
if err != nil {
return c.Failure(err)
}
- return c.Page(web.Map{
- "users": users,
+
+ return c.Page(web.Props{
+ Title: "Manage Members · Site Settings",
+ Data: web.Map{
+ "users": users,
+ },
})
}
}
diff --git a/app/handlers/common.go b/app/handlers/common.go
index b71048f74..9f8211a30 100644
--- a/app/handlers/common.go
+++ b/app/handlers/common.go
@@ -17,9 +17,12 @@ func Health() web.HandlerFunc {
}
//Page returns a page without properties
-func Page() web.HandlerFunc {
+func Page(title, description string) web.HandlerFunc {
return func(c web.Context) error {
- return c.Page(web.Map{})
+ return c.Page(web.Props{
+ Title: title,
+ Description: description,
+ })
}
}
diff --git a/app/handlers/idea.go b/app/handlers/idea.go
index 44f2ffedd..16c638f53 100644
--- a/app/handlers/idea.go
+++ b/app/handlers/idea.go
@@ -4,6 +4,7 @@ import (
"github.com/getfider/fider/app/actions"
"github.com/getfider/fider/app/models"
"github.com/getfider/fider/app/pkg/csv"
+ "github.com/getfider/fider/app/pkg/markdown"
"github.com/getfider/fider/app/pkg/web"
"github.com/getfider/fider/app/tasks"
)
@@ -30,10 +31,20 @@ func Index() web.HandlerFunc {
return c.Failure(err)
}
- return c.Page(web.Map{
- "ideas": ideas,
- "tags": tags,
- "countPerStatus": stats,
+ description := ""
+ if c.Tenant().WelcomeMessage != "" {
+ description = markdown.PlainText(c.Tenant().WelcomeMessage)
+ } else {
+ description = "We'd love to hear what you're thinking about. What can we do better? This is the place for you to vote, discuss and share ideas."
+ }
+
+ return c.Page(web.Props{
+ Description: description,
+ Data: web.Map{
+ "ideas": ideas,
+ "tags": tags,
+ "countPerStatus": stats,
+ },
})
}
}
@@ -140,11 +151,15 @@ func IdeaDetails() web.HandlerFunc {
return c.Failure(err)
}
- return c.Page(web.Map{
- "comments": comments,
- "subscribed": subscribed,
- "idea": idea,
- "tags": tags,
+ return c.Page(web.Props{
+ Title: idea.Title,
+ Description: markdown.PlainText(idea.Description),
+ Data: web.Map{
+ "comments": comments,
+ "subscribed": subscribed,
+ "idea": idea,
+ "tags": tags,
+ },
})
}
}
diff --git a/app/handlers/notification.go b/app/handlers/notification.go
index f634b3a68..a6e8ee1b1 100644
--- a/app/handlers/notification.go
+++ b/app/handlers/notification.go
@@ -26,8 +26,11 @@ func Notifications() web.HandlerFunc {
return c.Failure(err)
}
- return c.Page(web.Map{
- "notifications": notifications,
+ return c.Page(web.Props{
+ Title: "Notifications",
+ Data: web.Map{
+ "notifications": notifications,
+ },
})
}
}
diff --git a/app/handlers/settings.go b/app/handlers/settings.go
index c0b77b462..0665c1bba 100644
--- a/app/handlers/settings.go
+++ b/app/handlers/settings.go
@@ -61,8 +61,12 @@ func UserSettings() web.HandlerFunc {
if err != nil {
return err
}
- return c.Page(web.Map{
- "settings": settings,
+
+ return c.Page(web.Props{
+ Title: "Settings",
+ Data: web.Map{
+ "settings": settings,
+ },
})
}
}
diff --git a/app/handlers/signin.go b/app/handlers/signin.go
index 9a1a9f917..423432346 100644
--- a/app/handlers/signin.go
+++ b/app/handlers/signin.go
@@ -135,14 +135,20 @@ func SignInPage() web.HandlerFunc {
if c.IsAuthenticated() || !c.Tenant().IsPrivate {
return c.Redirect(c.BaseURL())
}
- return c.Page(web.Map{})
+
+ return c.Page(web.Props{
+ Title: "Sign in",
+ })
}
}
// NotInvitedPage renders the not invited page
func NotInvitedPage() web.HandlerFunc {
return func(c web.Context) error {
- return c.Render(http.StatusForbidden, "not-invited.html", web.Map{})
+ return c.Render(http.StatusForbidden, "not-invited.html", web.Props{
+ Title: "Not Invited",
+ Description: "We couldn't find your account for your email address.",
+ })
}
}
diff --git a/app/handlers/signup.go b/app/handlers/signup.go
index 7d65ef1f7..f2a033efe 100644
--- a/app/handlers/signup.go
+++ b/app/handlers/signup.go
@@ -106,7 +106,11 @@ func SignUp() web.HandlerFunc {
return c.Redirect("/")
}
}
- return c.Page(web.Map{})
+
+ return c.Page(web.Props{
+ Title: "Sign up",
+ Description: "Sign up for Fider and let your customers share, vote and discuss on suggestions they have to make your product even better.",
+ })
}
}
diff --git a/app/handlers/tag.go b/app/handlers/tag.go
index 719599a4a..a5a4204e6 100644
--- a/app/handlers/tag.go
+++ b/app/handlers/tag.go
@@ -14,8 +14,11 @@ func ManageTags() web.HandlerFunc {
return c.Failure(err)
}
- return c.Page(web.Map{
- "tags": tags,
+ return c.Page(web.Props{
+ Title: "Manage Tags · Site Settings",
+ Data: web.Map{
+ "tags": tags,
+ },
})
}
}
diff --git a/app/pkg/markdown/markdown.go b/app/pkg/markdown/markdown.go
index 13b23b91f..fa1e52909 100644
--- a/app/pkg/markdown/markdown.go
+++ b/app/pkg/markdown/markdown.go
@@ -2,34 +2,38 @@ package markdown
import (
"html/template"
+ "strings"
"github.com/russross/blackfriday"
)
-//const full = md('commonmark', { html: false, breaks: true, linkify: true }).enable('linkify');
-//const simple = md('commonmark', { html: false, breaks: true, linkify: true }).enable('linkify').disable('heading').disable('image');
+var mdExtns = 0 | blackfriday.EXTENSION_TABLES |
+ blackfriday.EXTENSION_AUTOLINK |
+ blackfriday.EXTENSION_FENCED_CODE |
+ blackfriday.EXTENSION_TITLEBLOCK |
+ blackfriday.EXTENSION_STRIKETHROUGH |
+ blackfriday.EXTENSION_DEFINITION_LISTS |
+ blackfriday.EXTENSION_NO_INTRA_EMPHASIS |
+ blackfriday.EXTENSION_HARD_LINE_BREAK
+
+var htmlExtns = 0 |
+ blackfriday.HTML_USE_XHTML |
+ blackfriday.HTML_USE_SMARTYPANTS |
+ blackfriday.HTML_SKIP_IMAGES |
+ blackfriday.HTML_SMARTYPANTS_FRACTIONS |
+ blackfriday.HTML_SMARTYPANTS_DASHES |
+ blackfriday.HTML_SMARTYPANTS_LATEX_DASHES
// Parse given markdown input into html with all enabled features
func Parse(input string) template.HTML {
- mdExtns := 0
- mdExtns |= blackfriday.EXTENSION_TABLES
- mdExtns |= blackfriday.EXTENSION_AUTOLINK
- mdExtns |= blackfriday.EXTENSION_FENCED_CODE
- mdExtns |= blackfriday.EXTENSION_TITLEBLOCK
- mdExtns |= blackfriday.EXTENSION_STRIKETHROUGH
- mdExtns |= blackfriday.EXTENSION_DEFINITION_LISTS
- mdExtns |= blackfriday.EXTENSION_NO_INTRA_EMPHASIS
- mdExtns |= blackfriday.EXTENSION_HARD_LINE_BREAK
-
- htmlExtns := 0 |
- blackfriday.HTML_USE_XHTML |
- blackfriday.HTML_USE_SMARTYPANTS |
- blackfriday.HTML_SKIP_IMAGES |
- blackfriday.HTML_SMARTYPANTS_FRACTIONS |
- blackfriday.HTML_SMARTYPANTS_DASHES |
- blackfriday.HTML_SMARTYPANTS_LATEX_DASHES
-
renderer := blackfriday.HtmlRenderer(htmlExtns, "", "")
output := blackfriday.Markdown([]byte(input), renderer, mdExtns)
return template.HTML(output)
}
+
+// PlainText parses given markdown input and return only the text
+func PlainText(input string) string {
+ renderer := TextRenderer()
+ output := blackfriday.Markdown([]byte(input), renderer, mdExtns)
+ return strings.TrimSpace(string(output))
+}
diff --git a/app/pkg/markdown/markdown_test.go b/app/pkg/markdown/markdown_test.go
index b45e7927e..2fb3a32bc 100644
--- a/app/pkg/markdown/markdown_test.go
+++ b/app/pkg/markdown/markdown_test.go
@@ -46,3 +46,27 @@ This will allow to send and receive SMS and get the IMEI No. in our app.</p>
Expect(output).Equals(template.HTML(expected))
}
}
+
+func TestPlainTextMarkdown(t *testing.T) {
+ RegisterT(t)
+
+ for input, expected := range map[string]string{
+ "**Hello World**": `Hello World`,
+ "[My Image](http://example.com/hello.jpg)": `My Image`,
+ "Go to http://example.com/hello.jpg": `Go to http://example.com/hello.jpg`,
+ "~~Option 3~~": `Option 3`,
+ "# Hello World": `Hello World`,
+ `# Hello World
+How are you?`: `Hello World
+How are you?`,
+ `Hello World
+
+How are you?`: `Hello World
+How are you?`,
+ "### Hello World": `Hello World`,
+ "Check this out: `HEEEY`": "Check this out: `HEEEY`",
+ } {
+ output := markdown.PlainText(input)
+ Expect(output).Equals(expected)
+ }
+}
diff --git a/app/pkg/markdown/renderer.go b/app/pkg/markdown/renderer.go
new file mode 100644
index 000000000..ba112bd87
--- /dev/null
+++ b/app/pkg/markdown/renderer.go
@@ -0,0 +1,172 @@
+package markdown
+
+import (
+ "bytes"
+
+ "github.com/russross/blackfriday"
+)
+
+// Ensure we implement the Blackfriday Markdown Renderer interface
+var _ blackfriday.Renderer = (*renderer)(nil)
+
+// renderer renders Markdown to plain-text meant for listings and excerpts,
+// and implements the blackfriday.Renderer interface.
+//
+// Many of the methods are stubs with no output to prevent output of HTML markup.
+type renderer struct{}
+
+//TextRenderer returns a plain text renderer
+func TextRenderer() renderer {
+ return renderer{}
+}
+
+// Blocklevel callbacks
+
+// BlockCode is the code tag callback.
+func (r renderer) BlockCode(out *bytes.Buffer, text []byte, land string) {}
+
+// BlockQuote is the quote tag callback.
+func (r renderer) BlockQuote(out *bytes.Buffer, text []byte) {}
+
+// BlockHtml is the HTML tag callback.
+func (r renderer) BlockHtml(out *bytes.Buffer, text []byte) {}
+
+// Header is the header tag callback.
+func (r renderer) Header(out *bytes.Buffer, text func() bool, level int, id string) {
+ marker := out.Len()
+ if !text() {
+ out.Truncate(marker)
+ }
+ out.Write([]byte{'\n'})
+}
+
+// HRule is the horizontal rule tag callback.
+func (r renderer) HRule(out *bytes.Buffer) {}
+
+// List is the list tag callback.
+func (r renderer) List(out *bytes.Buffer, text func() bool, flags int) {
+ // TODO: This is not desired (we'd rather not write lists as part of summary),
+ // but see this issue: https://github.com/russross/blackfriday/issues/189
+ marker := out.Len()
+ if !text() {
+ out.Truncate(marker)
+ }
+ out.Write([]byte{' '})
+}
+
+// ListItem is the list item tag callback.
+func (r renderer) ListItem(out *bytes.Buffer, text []byte, flags int) {}
+
+// Paragraph is the paragraph tag callback. This renders simple paragraph text
+// into plain text, such that summaries can be easily generated.
+func (r renderer) Paragraph(out *bytes.Buffer, text func() bool) {
+ marker := out.Len()
+ if !text() {
+ out.Truncate(marker)
+ }
+ out.Write([]byte{'\n'})
+}
+
+// Table is the table tag callback.
+func (r renderer) Table(out *bytes.Buffer, header []byte, body []byte, columnData []int) {}
+
+// TableRow is the table row tag callback.
+func (r renderer) TableRow(out *bytes.Buffer, text []byte) {}
+
+// TableHeaderCell is the table header cell tag callback.
+func (r renderer) TableHeaderCell(out *bytes.Buffer, text []byte, flags int) {}
+
+// TableCell is the table cell tag callback.
+func (r renderer) TableCell(out *bytes.Buffer, text []byte, flags int) {}
+
+// Footnotes is the foot notes tag callback.
+func (r renderer) Footnotes(out *bytes.Buffer, text func() bool) {}
+
+// FootnoteItem is the footnote item tag callback.
+func (r renderer) FootnoteItem(out *bytes.Buffer, name, text []byte, flags int) {}
+
+// TitleBlock is the title tag callback.
+func (r renderer) TitleBlock(out *bytes.Buffer, text []byte) {
+ out.Write(text)
+}
+
+// Spanlevel callbacks
+
+// AutoLink is the autolink tag callback.
+func (r renderer) AutoLink(out *bytes.Buffer, link []byte, kind int) {
+ out.Write(link)
+}
+
+// CodeSpan is the code span tag callback. Outputs a simple Markdown version
+// of the code span.
+func (r renderer) CodeSpan(out *bytes.Buffer, text []byte) {
+ out.Write([]byte("`"))
+ out.Write(text)
+ out.Write([]byte("`"))
+}
+
+// DoubleEmphasis is the double emphasis tag callback. Outputs a simple
+// plain-text version of the input.
+func (r renderer) DoubleEmphasis(out *bytes.Buffer, text []byte) {
+ out.Write(text)
+}
+
+// Emphasis is the emphasis tag callback. Outputs a simple plain-text
+// version of the input.
+func (r renderer) Emphasis(out *bytes.Buffer, text []byte) {
+ out.Write(text)
+}
+
+// Image is the image tag callback.
+func (r renderer) Image(out *bytes.Buffer, link []byte, title []byte, alt []byte) {}
+
+// LineBreak is the line break tag callback.
+func (r renderer) LineBreak(out *bytes.Buffer) {
+ out.Write([]byte{'\n'})
+}
+
+// Link is the link tag callback. Outputs a sipmle plain-text version
+// of the input.
+func (r renderer) Link(out *bytes.Buffer, link []byte, title []byte, content []byte) {
+ out.Write(content)
+}
+
+// RawHtmlTag is the raw HTML tag callback.
+func (r renderer) RawHtmlTag(out *bytes.Buffer, tag []byte) {}
+
+// TripleEmphasis is the triple emphasis tag callback. Outputs a simple plain-text
+// version of the input.
+func (r renderer) TripleEmphasis(out *bytes.Buffer, text []byte) {
+ out.Write(text)
+}
+
+// StrikeThrough is the strikethrough tag callback.
+func (r renderer) StrikeThrough(out *bytes.Buffer, text []byte) {
+ out.Write(text)
+}
+
+// FootnoteRef is the footnote ref tag callback.
+func (r renderer) FootnoteRef(out *bytes.Buffer, ref []byte, id int) {}
+
+// Lowlevel callbacks
+
+// Entity callback. Outputs a simple plain-text version of the input.
+func (r renderer) Entity(out *bytes.Buffer, entity []byte) {
+ out.Write(entity)
+}
+
+// NormalText callback. Outputs a simple plain-text version of the input.
+func (r renderer) NormalText(out *bytes.Buffer, text []byte) {
+ out.Write(text)
+}
+
+// Header and footer
+
+// DocumentHeader callback.
+func (r renderer) DocumentHeader(out *bytes.Buffer) {}
+
+// DocumentFooter callback.
+func (r renderer) DocumentFooter(out *bytes.Buffer) {}
+
+// GetFlags returns zero.
+func (r renderer) GetFlags() int { return 0 }
diff --git a/app/pkg/web/context.go b/app/pkg/web/context.go
index c30905869..ccfdbb57b 100644
--- a/app/pkg/web/context.go
+++ b/app/pkg/web/context.go
@@ -23,12 +23,19 @@ import (
"github.com/getfider/fider/app/pkg/worker"
)
-// Map defines a generic map of type `map[string]interface{}`.
+// Map defines a generic map of type `map[string]interface{}`
type Map map[string]interface{}
-// StringMap defines a map of type `map[string]string`.
+// StringMap defines a map of type `map[string]string`
type StringMap map[string]string
+// Props defines the data required to rende rages
+type Props struct {
+ Title string
+ Description string
+ Data Map
+}
+
// HTMLMimeType is the mimetype for HTML responses
var (
PlainContentType = "text/plain"
@@ -175,17 +182,26 @@ func (ctx *Context) Unauthorized() error {
if ctx.IsAjax() {
return ctx.JSON(http.StatusForbidden, Map{})
}
- return ctx.Render(http.StatusForbidden, "403.html", Map{})
+ return ctx.Render(http.StatusForbidden, "403.html", Props{
+ Title: "Not Authorized",
+ Description: "You are not authorized to view this page.",
+ })
}
//NotFound returns a 404 page
func (ctx *Context) NotFound() error {
- return ctx.Render(http.StatusNotFound, "404.html", Map{})
+ return ctx.Render(http.StatusNotFound, "404.html", Props{
+ Title: "Page not found",
+ Description: "The link you clicked may be broken or the page may have been removed.",
+ })
}
//Gone returns a 410 page
func (ctx *Context) Gone() error {
- return ctx.Render(http.StatusGone, "410.html", Map{})
+ return ctx.Render(http.StatusGone, "410.html", Props{
+ Title: "Expired",
+ Description: "The link you clicked has expired.",
+ })
}
//Failure returns a 500 page
@@ -208,7 +224,10 @@ func (ctx *Context) Failure(err error) error {
url := ctx.BaseURL() + ctx.Request.RequestURI
message := fmt.Sprintf("URL: %s\nTenant: %s\nUser: %s\n%s", url, tenant, user, err.Error())
ctx.Logger().Errorf(log.Red(message))
- ctx.Render(http.StatusInternalServerError, "500.html", Map{})
+ ctx.Render(http.StatusInternalServerError, "500.html", Props{
+ Title: "Shoot! Well, this is unexpected…",
+ Description: "An error has occurred and we're working to fix the problem!",
+ })
return err
}
@@ -246,14 +265,14 @@ func (ctx *Context) BadRequest(dict Map) error {
}
//Page returns a page with given variables
-func (ctx *Context) Page(dict Map) error {
- return ctx.Render(http.StatusOK, "index.html", dict)
+func (ctx *Context) Page(props Props) error {
+ return ctx.Render(http.StatusOK, "index.html", props)
}
// Render renders a template with data and sends a text/html response with status
-func (ctx *Context) Render(code int, template string, data Map) error {
+func (ctx *Context) Render(code int, template string, props Props) error {
buf := new(bytes.Buffer)
- if err := ctx.engine.renderer.Render(buf, template, data, ctx); err != nil {
+ if err := ctx.engine.renderer.Render(buf, template, props, ctx); err != nil {
return err
}
return ctx.Blob(code, HTMLContentType, buf.Bytes())
@@ -421,27 +440,6 @@ func (ctx *Context) ParamAsInt(name string) (int, error) {
return intValue, nil
}
-//RenderVars returns all registered RenderVar
-func (ctx *Context) RenderVars() Map {
- vars := ctx.Get("__renderVars")
- if vars != nil {
- return vars.(Map)
- }
- return nil
-}
-
-//AddRenderVar register given key/value to RenderVar map
-func (ctx *Context) AddRenderVar(name string, value interface{}) {
- var renderVars = ctx.Get("__renderVars")
- if renderVars == nil {
- renderVars = make(Map)
- ctx.Set("__renderVars", renderVars)
- }
-
- ctx.Logger().Debugf("storage.%v: %v", name, value)
- renderVars.(Map)[name] = value
-}
-
// Get retrieves data from the context.
func (ctx *Context) Get(key string) interface{} {
return ctx.store[key]
diff --git a/app/pkg/web/renderer.go b/app/pkg/web/renderer.go
index 0b6dd85a6..87d94f30c 100644
--- a/app/pkg/web/renderer.go
+++ b/app/pkg/web/renderer.go
@@ -4,6 +4,7 @@ import (
"fmt"
"html/template"
"io"
+ "strings"
"io/ioutil"
@@ -72,7 +73,7 @@ func (r *Renderer) getBundle(folder string) string {
}
//Render a template based on parameters
-func (r *Renderer) Render(w io.Writer, name string, data interface{}, ctx *Context) error {
+func (r *Renderer) Render(w io.Writer, name string, props Props, ctx *Context) error {
tmpl, ok := r.templates[name]
if !ok {
panic(fmt.Errorf("The template '%s' does not exist", name))
@@ -84,7 +85,28 @@ func (r *Renderer) Render(w io.Writer, name string, data interface{}, ctx *Conte
r.cssBundle = r.getBundle("/dist/css")
}
- m := data.(Map)
+ m := props.Data
+ if m == nil {
+ m = make(Map, 0)
+ }
+
+ tenantName := "Fider"
+ if ctx.Tenant() != nil {
+ tenantName = ctx.Tenant().Name
+ }
+
+ title := tenantName
+ if props.Title != "" {
+ title = fmt.Sprintf("%s · %s", props.Title, tenantName)
+ }
+
+ m["__Title"] = title
+
+ if props.Description != "" {
+ description := strings.Replace(props.Description, "\n", " ", -1)
+ m["__Description"] = fmt.Sprintf("%.150s", description)
+ }
+
m["__JavaScriptBundle"] = r.jsBundle
m["__StyleBundle"] = r.cssBundle
m["__ContextID"] = ctx.ContextID()
@@ -108,12 +130,6 @@ func (r *Renderer) Render(w io.Writer, name string, data interface{}, ctx *Conte
},
}
- if renderVars := ctx.RenderVars(); renderVars != nil {
- for key, value := range renderVars {
- m[key] = value
- }
- }
-
if ctx.IsAuthenticated() {
u := ctx.User()
m["user"] = &Map{
diff --git a/public/pages/Administration/pages/Export.page.tsx b/public/pages/Administration/pages/Export.page.tsx
index 283c96468..a2a36196b 100644
--- a/public/pages/Administration/pages/Export.page.tsx
+++ b/public/pages/Administration/pages/Export.page.tsx
@@ -5,7 +5,6 @@ import * as React from "react";
import { CurrentUser } from "@fider/models";
import { Button } from "@fider/components/common";
import { AdminBasePage } from "../components";
-import { page } from "@fider/services";
interface ExportPageProps {
user: CurrentUser;
@@ -18,12 +17,6 @@ export class ExportPage extends AdminBasePage<ExportPageProps, {}> {
public title = "Export";
public subtitle = "Download your data";
- constructor(props: ExportPageProps) {
- super(props);
-
- page.setTitle(`Export · Site Settings · ${document.title}`);
- }
-
public content() {
return (
<div className="ui form">
diff --git a/public/pages/Administration/pages/GeneralSettings.page.tsx b/public/pages/Administration/pages/GeneralSettings.page.tsx
index 58f7e3c2c..876792143 100644
--- a/public/pages/Administration/pages/GeneralSettings.page.tsx
+++ b/public/pages/Administration/pages/GeneralSettings.page.tsx
@@ -47,8 +47,6 @@ export class GeneralSettingsPage extends AdminBasePage<GeneralSettingsPageProps,
welcomeMessage: this.props.tenant.welcomeMessage,
invitation: this.props.tenant.invitation
};
-
- page.setTitle(`General · Site Settings · ${document.title}`);
}
private async save(e: ButtonClickEvent) {
diff --git a/public/pages/Administration/pages/Invitations.page.tsx b/public/pages/Administration/pages/Invitations.page.tsx
index e9ec22dde..4d4a15865 100644
--- a/public/pages/Administration/pages/Invitations.page.tsx
+++ b/public/pages/Administration/pages/Invitations.page.tsx
@@ -2,7 +2,7 @@ import * as React from "react";
import { SystemSettings, CurrentUser, Tenant } from "@fider/models";
import { Button, ButtonClickEvent, Textarea, DisplayError } from "@fider/components/common";
-import { actions, page, notify, Failure } from "@fider/services";
+import { actions, notify, Failure } from "@fider/services";
import { AdminBasePage } from "../components";
interface InvitationsPageProps {
@@ -49,8 +49,6 @@ ${this.props.user.name} (${this.props.tenant.name})`,
numOfRecipients: 0,
rawRecipients: ""
};
-
- page.setTitle(`Invitations · Site Settings · ${document.title}`);
}
private setRecipients = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
diff --git a/public/pages/Administration/pages/ManageMembers.page.tsx b/public/pages/Administration/pages/ManageMembers.page.tsx
index 79f359aee..cc470cdbc 100644
--- a/public/pages/Administration/pages/ManageMembers.page.tsx
+++ b/public/pages/Administration/pages/ManageMembers.page.tsx
@@ -1,7 +1,7 @@
import * as React from "react";
import { Button, Gravatar, UserName } from "@fider/components/common";
import { User, CurrentUser, UserRole } from "@fider/models";
-import { page, actions } from "@fider/services";
+import { actions } from "@fider/services";
import { AdminBasePage } from "../components";
interface ManageMembersPageState {
@@ -29,8 +29,6 @@ export class ManageMembersPage extends AdminBasePage<ManageMembersPageProps, Man
constructor(props: ManageMembersPageProps) {
super(props);
this.state = this.groupUsers();
-
- page.setTitle(`Manage Members · Site Settings · ${document.title}`);
}
private async changeRole(user: User, role: UserRole): Promise<any> {
diff --git a/public/pages/Administration/pages/ManageTags.page.tsx b/public/pages/Administration/pages/ManageTags.page.tsx
index b0ed8125b..04cdb7672 100644
--- a/public/pages/Administration/pages/ManageTags.page.tsx
+++ b/public/pages/Administration/pages/ManageTags.page.tsx
@@ -3,7 +3,7 @@ import { ShowTag, Button, Gravatar, UserName } from "@fider/components";
import { AdminBasePage, TagForm, TagFormState } from "../components";
import { Tag, CurrentUser, UserRole } from "@fider/models";
-import { page, actions, Failure } from "@fider/services";
+import { actions, Failure } from "@fider/services";
interface ManageTagsPageProps {
user: CurrentUser;
@@ -30,8 +30,6 @@ export class ManageTagsPage extends AdminBasePage<ManageTagsPageProps, ManageTag
isAdding: false,
allTags: this.props.tags
};
-
- page.setTitle(`Manage Tags · Site Settings · ${document.title}`);
}
private async saveNewTag(data: TagFormState): Promise<Failure | undefined> {
diff --git a/public/pages/Administration/pages/PrivacySettings.page.tsx b/public/pages/Administration/pages/PrivacySettings.page.tsx
index d886ddd68..f336ed0a9 100644
--- a/public/pages/Administration/pages/PrivacySettings.page.tsx
+++ b/public/pages/Administration/pages/PrivacySettings.page.tsx
@@ -4,7 +4,7 @@ import * as React from "react";
import { SystemSettings, CurrentUser, Tenant } from "@fider/models";
import { Button, ButtonClickEvent, Textarea, DisplayError, Toggle } from "@fider/components/common";
-import { actions, page, notify, Failure } from "@fider/services";
+import { actions, notify, Failure } from "@fider/services";
import { AdminBasePage } from "../components";
interface PrivacySettingsPageProps {
@@ -29,8 +29,6 @@ export class PrivacySettingsPage extends AdminBasePage<PrivacySettingsPageProps,
this.state = {
isPrivate: this.props.tenant.isPrivate
};
-
- page.setTitle(`Privacy · Site Settings · ${document.title}`);
}
private toggle = async (active: boolean) => {
diff --git a/public/pages/ShowIdea/ShowIdea.page.tsx b/public/pages/ShowIdea/ShowIdea.page.tsx
index a63ba6f8e..4c53df043 100644
--- a/public/pages/ShowIdea/ShowIdea.page.tsx
+++ b/public/pages/ShowIdea/ShowIdea.page.tsx
@@ -3,7 +3,7 @@ import "./ShowIdea.page.scss";
import * as React from "react";
import { CurrentUser, Comment, Idea, Tag } from "@fider/models";
-import { page, actions, Failure } from "@fider/services";
+import { actions, Failure } from "@fider/services";
import { TagsPanel, DiscussionPanel, ResponseForm, NotificationsPanel, ModerationPanel } from "./";
import {
@@ -42,8 +42,6 @@ export class ShowIdeaPage extends React.Component<ShowIdeaPageProps, ShowIdeaPag
newTitle: this.props.idea.title,
newDescription: this.props.idea.description
};
-
- page.setTitle(`${this.props.idea.title} · ${document.title}`);
}
private async saveChanges() {
diff --git a/public/pages/SignIn/SignIn.page.tsx b/public/pages/SignIn/SignIn.page.tsx
index e320010fe..f522766a2 100644
--- a/public/pages/SignIn/SignIn.page.tsx
+++ b/public/pages/SignIn/SignIn.page.tsx
@@ -13,8 +13,6 @@ export class SignInPage extends React.Component<SignInPageProps, {}> {
constructor(props: SignInPageProps) {
super(props);
this.state = {};
-
- page.setTitle(`Sign in · ${document.title}`);
}
private onEmailSent = (email: string) => {
diff --git a/public/pages/SignUp/SignUp.page.tsx b/public/pages/SignUp/SignUp.page.tsx
index 8c66f8351..6b5c6de98 100644
--- a/public/pages/SignUp/SignUp.page.tsx
+++ b/public/pages/SignUp/SignUp.page.tsx
@@ -41,8 +41,6 @@ export class SignUpPage extends React.Component<SignUpPageProps, SignUpPageState
subdomain: { available: false }
};
- page.setTitle(page.isSingleHostMode() ? "Installation · Fider" : "Sign up · Fider");
-
const token = page.getQueryString("token");
if (token) {
const data = jwt.decode(token);
diff --git a/public/services/page.ts b/public/services/page.ts
index fca424c3a..91fb5f090 100644
--- a/public/services/page.ts
+++ b/public/services/page.ts
@@ -8,10 +8,6 @@ export const refresh = (): void => {
document.location.reload();
};
-export const setTitle = (title: string): void => {
- document.title = title;
-};
-
export const getBaseUrl = (): string => {
return (window as any).props.baseURL;
};
diff --git a/views/403.html b/views/403.html
index 153b9f5bd..a0c65dd33 100644
--- a/views/403.html
+++ b/views/403.html
@@ -1,7 +1,3 @@
-{{define "title"}}
-Not Authorized &middot; Fider
-{{end}}
-
{{define "javascript"}}{{end}}
{{define "content"}}
diff --git a/views/404.html b/views/404.html
index 2cb9ec877..3d93e3bb8 100644
--- a/views/404.html
+++ b/views/404.html
@@ -1,7 +1,3 @@
-{{define "title"}}
- Page not found &middot; Fider
-{{end}}
-
{{define "javascript"}}{{end}}
{{define "content"}}
diff --git a/views/410.html b/views/410.html
index 5f7604a22..80bb4a9ad 100644
--- a/views/410.html
+++ b/views/410.html
@@ -1,7 +1,3 @@
-{{define "title"}}
- Expired &middot; Fider
-{{end}}
-
{{define "javascript"}}{{end}}
{{define "content"}}
diff --git a/views/500.html b/views/500.html
index 469ec6f66..f078e6eb0 100644
--- a/views/500.html
+++ b/views/500.html
@@ -1,7 +1,3 @@
-{{define "title"}}
- Shoot! Well, this is unexpected… &middot; Fider
-{{end}}
-
{{define "javascript"}}{{end}}
{{define "content"}}
diff --git a/views/base.html b/views/base.html
index aa0e625ef..27c96b447 100644
--- a/views/base.html
+++ b/views/base.html
@@ -5,9 +5,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<link rel="icon" type="image/x-icon" href="{{ .__favicon }}">
<link rel="stylesheet" href="/assets/css/{{ .__StyleBundle }}" />
- <title>{{ template "title" .}}</title>
- <meta property="og:title" content="{{template "title" .}}" />
- <meta property="og:description" content="We'd love to hear what you're thinking about. What can we do better? This is the place for you to vote, discuss and share ideas." />
+ <title>{{ .__Title }}</title>
+ <meta name="description" content="{{ .__Description }}" />
+ <meta property="og:title" content="{{ .__Title }}" />
+ <meta property="og:description" content="{{ .__Description }}" />
<meta property="og:type" content="website" />
<meta property="og:url" content="{{ .baseURL }}" />
<meta property="og:image" content="{{ .__logo }}">
diff --git a/views/index.html b/views/index.html
index 3c51406c1..67deaa2e9 100644
--- a/views/index.html
+++ b/views/index.html
@@ -1,5 +1,3 @@
-{{define "title"}}{{ if .tenant }}{{ .tenant.Name }}{{ end }}{{end}}
-
// Print all variables that does not start with _ (95)
// Compressed to avoid whitespace being printed