Use <base> element to set target
authorr <r@freesoftwareextremist.com>
Sun, 23 Feb 2020 13:26:39 +0000 (13:26 +0000)
committerr <r@freesoftwareextremist.com>
Sun, 23 Feb 2020 18:01:50 +0000 (18:01 +0000)
renderer/model.go
service/service.go
templates/header.tmpl
templates/nav.tmpl
templates/notification.tmpl
templates/postform.tmpl
templates/status.tmpl

index 45d3117fd55a4f9aec5a4e5714b0ce906a4c09d5..0d89af70d413d572006d137571c567d1dbe0eafb 100644 (file)
@@ -25,6 +25,7 @@ type CommonData struct {
        CustomCSS   string
        CSRFToken   string
        AutoRefresh bool
+       Target      string
 }
 
 type ErrorData struct {
index 9e015096e7c81f1c2b88daf9b668d24687389737..4316f86098a47e1880d4e78144ed79a9c439083a 100644 (file)
@@ -189,6 +189,7 @@ func (svc *service) ServeNavPage(ctx context.Context, c *model.Client) (err erro
        }
 
        commonData := svc.getCommonData(ctx, c, "Nav")
+       commonData.Target = "main"
        data := &renderer.NavData{
                User:        u,
                CommonData:  commonData,
@@ -422,6 +423,7 @@ func (svc *service) ServeNotificationPage(ctx context.Context, c *model.Client,
 
        commonData := svc.getCommonData(ctx, c, "notifications")
        commonData.AutoRefresh = c.Session.Settings.AutoRefreshNotifications
+       commonData.Target = "main"
        data := &renderer.NotificationData{
                Notifications: notifications,
                UnreadCount:   unreadCount,
index 76831f2514ae117f44b8eec582ecf7a506c46265..ca2986de4c63113b0abeb650d803e39f56fae379 100644 (file)
@@ -4,6 +4,9 @@
 <head>
        <meta charset='utf-8'>
        <meta content='width=device-width, initial-scale=1' name='viewport'>
+       {{if .Target}}
+       <base href="" target="{{.Target}}">
+       {{end}}
        {{if .CSRFToken}}
        <meta name="csrf_token" content="{{.CSRFToken}}">
        {{end}}
index 620643e755dcb07b17178f77c4902fc823a59f65..8922ba7157de13f855bd48c3d05f1d072d711dd6 100644 (file)
@@ -2,24 +2,24 @@
 {{template "header.tmpl" (WithContext .CommonData $.Ctx)}}
 <div class="user-info">
        <div class="user-info-img-container">
-               <a class="img-link" href="/timeline/home" title="home" target="main">
+               <a class="img-link" href="/timeline/home" title="home">
                        <img class="user-info-img" src="{{.User.AvatarStatic}}" alt="profile-avatar" />
                </a>
        </div>
        <div class="user-info-details-container">
                <div>
                        <span class="status-dname"> {{EmojiFilter .User.DisplayName .User.Emojis}} </span>  
-                       <a class="nav-link" href="/user/{{.User.ID}}" target="main">
+                       <a class="nav-link" href="/user/{{.User.ID}}">
                                <span class="status-uname"> {{.User.Acct}} </span>
                        </a>
                </div>
                <div>
-                       <a class="nav-link" href="/timeline/home" target="main">home</a>
-                       <a class="nav-link" href="/timeline/direct" target="main">direct</a>
-                       <a class="nav-link" href="/timeline/local" target="main">local</a>
-                       <a class="nav-link" href="/timeline/twkn" target="main">twkn</a>
-                       <a class="nav-link" href="/search" target="main">search</a>
-                       <a class="nav-link" href="/about" target="main">about</a>
+                       <a class="nav-link" href="/timeline/home">home</a>
+                       <a class="nav-link" href="/timeline/direct">direct</a>
+                       <a class="nav-link" href="/timeline/local">local</a>
+                       <a class="nav-link" href="/timeline/twkn">twkn</a>
+                       <a class="nav-link" href="/search">search</a>
+                       <a class="nav-link" href="/about">about</a>
                </div>
                <div>
                        <a class="nav-link" href="/settings" target="_top">settings</a>
index 9e1854cc5234ce10e5f09d8ab5ba1c5f4734158a..02b38472bf1a1df8969871cdf7015a3f598df3fe 100644 (file)
@@ -5,9 +5,9 @@
                Notifications
                {{if gt .UnreadCount 0}}({{.UnreadCount }}){{end}}
        </div>
-       <a class="notification-refresh" href="/notifications">refresh</a>
+       <a class="notification-refresh" href="/notifications" target="_self">refresh</a>
        {{if .ReadID}}
-       <form action="/notifications/read?max_id={{.ReadID}}" method="post">
+       <form action="/notifications/read?max_id={{.ReadID}}" method="post" target="_self">
                <input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
                <input type="submit" value="read" class="btn-link">
        </form>
@@ -19,7 +19,7 @@
        {{if eq .Type "follow"}}
        <div class="notification-follow-container">
                <div class="status-profile-img-container">
-                       <a class="img-link" href="/user/{{.Account.ID}}" target="main" >
+                       <a class="img-link" href="/user/{{.Account.ID}}">
                                <img class="status-profile-img" src="{{.Account.AvatarStatic}}" alt="profile-avatar" />
                        </a>
                </div>
@@ -42,7 +42,7 @@
 
        {{else if eq .Type "reblog"}}
        <div class="retweet-info">
-               <a class="img-link" href="/user/{{.Account.ID}}" target="main">
+               <a class="img-link" href="/user/{{.Account.ID}}">
                        <img class="status-profile-img" src="{{.Account.AvatarStatic}}" alt="avatar" />
                </a>
                <span class="status-dname"> {{EmojiFilter .Account.DisplayName .Account.Emojis}} </span>  
@@ -55,7 +55,7 @@
 
        {{else if eq .Type "favourite"}}
        <div class="retweet-info">
-               <a class="img-link" href="/user/{{.Account.ID}}" target="main">
+               <a class="img-link" href="/user/{{.Account.ID}}">
                        <img class="status-profile-img" src="{{.Account.AvatarStatic}}" alt="avatar" />
                </a>
                <span class="status-dname"> {{EmojiFilter .Account.DisplayName .Account.Emojis}} </span>  
@@ -71,7 +71,7 @@
 
 <div class="pagination">
        {{if .NextLink}}
-               <a href="{{.NextLink}}">next</a>
+               <a href="{{.NextLink}}" target="_self">next</a>
        {{end}}
 </div>
 
index d5c1fb93e0a98d21c5b6bc546b40c400a14a5eb2..9c674e9d9e9b0743cce7da4bf3364039eaba5280 100644 (file)
@@ -1,5 +1,5 @@
 {{with .Data}}
-<form class="post-form" action="/post" method="POST" enctype="multipart/form-data">
+<form class="post-form" action="/post" method="POST" enctype="multipart/form-data" target="_self">
        <input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
        {{if .ReplyContext}}
        <input type="hidden" name="reply_to_id" value="{{.ReplyContext.InReplyToID}}" />
index 536f515318fda1b830ebf83b0c0cbec71aed8267..0371a4edc33241b026e7d0d707fa36384e5630ab 100644 (file)
@@ -2,7 +2,7 @@
 <div id="status-{{.ID}}" class="status-container-container">
        {{if .Reblog}}
        <div class="retweet-info">
-               <a class="img-link" href="/user/{{.Account.ID}}" target="main">
+               <a class="img-link" href="/user/{{.Account.ID}}">
                        <img class="status-profile-img" src="{{.Account.AvatarStatic}}" alt="avatar" />
                </a>
                <span class="status-dname"> {{EmojiFilter .Account.DisplayName .Account.Emojis}} </span>  
        {{with $s := .Data}}
        <div class="status-container status-{{.ID}}" data-id="{{.ID}}">
                <div class="status-profile-img-container">
-                       <a class="img-link" href="/user/{{.Account.ID}}" target="main">
+                       <a class="img-link" href="/user/{{.Account.ID}}">
                                <img class="status-profile-img" src="{{.Account.AvatarStatic}}" alt="avatar" />
                        </a>
                </div>
                <div class="status"> 
                        <div class="status-name">
                                <span class="status-dname"> {{EmojiFilter .Account.DisplayName .Account.Emojis}} </span> 
-                               <a href="/user/{{.Account.ID}}"  target="main">
+                               <a href="/user/{{.Account.ID}}">
                                        <span class="status-uname"> {{.Account.Acct}} </span>
                                </a>
                                <div class="more-container">
                                                        source
                                                </a>
                                                {{if .Muted}}
-                                               <form action="/unmuteconv/{{.ID}}" method="post">
+                                               <form action="/unmuteconv/{{.ID}}" method="post" target="_self">
                                                        <input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
                                                        <input type="submit" value="unmute" class="btn-link more-link">
                                                </form>
                                                {{else}}
-                                               <form action="/muteconv/{{.ID}}" method="post">
+                                               <form action="/muteconv/{{.ID}}" method="post" target="_self">
                                                        <input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
                                                        <input type="submit" value="mute" class="btn-link more-link">
                                                </form>
                                                {{end}}
                                                {{if eq $.Ctx.UserID .Account.ID}}
-                                               <form action="/delete/{{.ID}}" method="post">
+                                               <form action="/delete/{{.ID}}" method="post" target="_self">
                                                        <input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
                                                        <input type="submit" value="delete" class="btn-link more-link">
                                                </form>
@@ -55,7 +55,7 @@
                        <div class="status-reply-container">
                                {{if .InReplyToID}}
                                <div class="status-reply-to">
-                                       <a class="status-reply-to-link" href="{{if not .ShowReplies}}/thread/{{.InReplyToID}}{{end}}#status-{{.InReplyToID}}" target="main"
+                                       <a class="status-reply-to-link" href="{{if not .ShowReplies}}/thread/{{.InReplyToID}}{{end}}#status-{{.InReplyToID}}"> 
                                                 reply to {{.Pleroma.InReplyToAccountAcct}} 
                                        </a>
                                </div>
                                {{end}}
                        </div>
                        {{if .Poll}}
-                       <form class="poll-form" action="/vote/{{.Poll.ID}}" method="POST">
+                       <form class="poll-form" action="/vote/{{.Poll.ID}}" method="POST" target="_self">
                                <input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
                                <input type="hidden" name="status_id" value="{{$s.ID}}">
                                {{range $i, $o := .Poll.Options}}
                        {{end}}
                        <div class="status-action-container"> 
                                <div class="status-action">
-                                       <a href="/thread/{{.ID}}?reply=true#status-{{.ID}}" target="main"
+                                       <a href="/thread/{{.ID}}?reply=true#status-{{.ID}}"> 
                                                reply
                                        </a>
-                                       <a class="status-reply-count" href="/thread/{{.ID}}#status-{{.ID}}" target="{{if $.Ctx.ThreadInNewTab}}_blank{{else}}main{{end}}">
+                                       <a class="status-reply-count" href="/thread/{{.ID}}#status-{{.ID}}" {{if $.Ctx.ThreadInNewTab}}target="_blank"{{end}}>
                                                {{if .RepliesCount}} ({{DisplayInteractionCount .RepliesCount}}) {{end}}
                                        </a>
                                </div>
                                <div class="status-action">
                                        {{if or (eq .Visibility "private") (eq .Visibility "direct")}}
-                                       <a class="status-retweet" href="" title="this status cannot be retweeted" target="main"
+                                       <a class="status-retweet" href="" title="this status cannot be retweeted"> 
                                                retweet
                                        </a>
                                        {{else}}
                                        {{if .Reblogged}}
-                                       <form class="status-retweet" data-action="unretweet" action="/unretweet/{{.ID}}" method="post">
+                                       <form class="status-retweet" data-action="unretweet" action="/unretweet/{{.ID}}" method="post" target="_self">
                                                <input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
                                                <input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}">
                                                <input type="submit" value="unretweet" class="btn-link">
                                        </form>
                                        {{else}}
-                                       <form class="status-retweet" data-action="retweet" action="/retweet/{{.ID}}" method="post">
+                                       <form class="status-retweet" data-action="retweet" action="/retweet/{{.ID}}" method="post" target="_self">
                                                <input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
                                                <input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}">
                                                <input type="submit" value="retweet" class="btn-link">
                                        </form>
                                        {{end}}
                                        {{end}}
-                                       <a class="status-retweet-count" href="/retweetedby/{{.ID}}" title="click to see the the list" target="main"
+                                       <a class="status-retweet-count" href="/retweetedby/{{.ID}}" title="click to see the the list"> 
                                                {{if .ReblogsCount}} ({{DisplayInteractionCount .ReblogsCount}}) {{end}}
                                        </a>
                                </div>
                                <div class="status-action">
                                        {{if .Favourited}}
-                                       <form class="status-like" data-action="unlike" action="/unlike/{{.ID}}" method="post">
+                                       <form class="status-like" data-action="unlike" action="/unlike/{{.ID}}" method="post" target="_self">
                                                <input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
                                                <input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}">
                                                <input type="submit" value="unlike" class="btn-link">
                                        </form>
                                        {{else}}
-                                       <form class="status-like" data-action="like" action="/like/{{.ID}}" method="post">
+                                       <form class="status-like" data-action="like" action="/like/{{.ID}}" method="post" target="_self">
                                                <input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
                                                <input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}">
                                                <input type="submit" value="like" class="btn-link">
                                        </form>
                                        {{end}}
-                                       <a class="status-like-count" href="/likedby/{{.ID}}" title="click to see the the list" target="main"
+                                       <a class="status-like-count" href="/likedby/{{.ID}}" title="click to see the the list"> 
                                                {{if .FavouritesCount}} ({{DisplayInteractionCount .FavouritesCount}}) {{end}}
                                        </a>
                                </div>
                                <div class="status-action">
-                                       <a class="status-time" href="{{if not .ShowReplies}}/thread/{{.ID}}{{end}}#status-{{.ID}}" 
-                                               target="{{if $.Ctx.ThreadInNewTab}}_blank{{else}}main{{end}}"
+                                       <a class="status-time" href="{{if not .ShowReplies}}/thread/{{.ID}}{{end}}#status-{{.ID}}"
+                                               {{if $.Ctx.ThreadInNewTab}}target="_blank"{{end}}
                                                <time datetime="{{FormatTimeRFC3339 .CreatedAt}}" title="{{FormatTimeRFC822 .CreatedAt}}"> 
                                                        {{TimeSince .CreatedAt}}
                                                </time>