Browse Source

Set address bar width to screen width

pull/5/head
Trevor Slocum 2 years ago
parent
commit
f71136c1a5
  1. 3
      CHANGELOG
  2. 27
      pkg/gmitohtml/assets.go
  3. 8
      pkg/gmitohtml/convert.go
  4. 7
      pkg/gmitohtml/daemon.go

3
CHANGELOG

@ -1,3 +1,6 @@
1.0.3:
- Set address bar width to screen width
1.0.2:
- Support bookmarks

27
pkg/gmitohtml/assets.go

@ -10,15 +10,15 @@ const pageHeader = `
<link rel="stylesheet" href="/assets/style.css">
</head>
<body>
<div>
<form method="post" action="/" novalidate>
<input type="url" name="address" placeholder="Address" size="40" value="~GEMINICURRENTURL~" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" css="width: 100%;" ~GEMINIAUTOFOCUS~>
</form>`
const navigationMenuText = `
<div style="padding-left: 84px;padding-bottom: 7px;">
<input type="url" name="address" id="navigationaddress" placeholder="Address" size="40" value="~GEMINICURRENTURL~" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" ~GEMINIAUTOFOCUS~>
</form>
<div id="navigationbar"">
<a href="/bookmarks" class="navlink">View bookmarks</a> &nbsp;-&nbsp; <a href="/bookmarks?add=~GEMINICURRENTURL~" class="navlink">Add bookmark</a>
</div>
`
</div>
<div id="content">`
const inputPrompt = `
<form method="post" action="~GEMINIINPUTFORM~">
@ -32,6 +32,7 @@ const inputPrompt = `
`
const pageFooter = `
</div>
</body>
</html>
`
@ -61,9 +62,23 @@ html {
*/
body {
margin: 0;
width: 100%;
}
#content {
margin: 0.67em;
}
#navigationaddress {
box-sizing: border-box;
width: 100%
}
#navigationbar {
padding: 4px 21px 7px 21px;
}
/**
* Render the main element consistently in IE.
*/

8
pkg/gmitohtml/convert.go

@ -61,13 +61,6 @@ func rewriteURL(u string, loc *url.URL) string {
return u
}
func navigationMenu() []byte {
if daemonAddress == "" {
return nil
}
return []byte(navigationMenuText)
}
// Convert converts text/gemini to text/html.
func Convert(page []byte, u string) []byte {
var result []byte
@ -156,7 +149,6 @@ func Convert(page []byte, u string) []byte {
}
data := []byte(pageHeader)
data = append(data, navigationMenu()...)
data = append(data, result...)
data = append(data, []byte(pageFooter)...)
return fillTemplateVariables(data, u, false)

7
pkg/gmitohtml/daemon.go

@ -39,8 +39,6 @@ func bookmarksList() []byte {
fakeURL, _ := url.Parse("/") // Always succeeds
var b bytes.Buffer
b.Write([]byte(`<div style="padding-left: 12px;">`))
b.Write([]byte(`<br><a href="/bookmarks" class="navlink">Bookmarks</a><br></div>`))
b.Write([]byte(`<ul>`))
for _, u := range bookmarksSorted {
b.Write([]byte(fmt.Sprintf(`<li><a href="%s">%s</a></li>`, rewriteURL(u, fakeURL), bookmarks[u])))
@ -118,7 +116,6 @@ func fetch(u string) ([]byte, []byte, error) {
requestSensitiveInput := bytes.HasPrefix(header, []byte("11"))
data = []byte(pageHeader)
data = append(data, navigationMenu()...)
data = append(data, []byte(inputPrompt)...)
@ -294,7 +291,7 @@ func handleBookmarks(writer http.ResponseWriter, request *http.Request) {
data = []byte(pageHeader)
data = append(data, []byte(fmt.Sprintf(`<br><form method="post" action="%s"><h3>Edit bookmark</h3><input type="text" size="40" name="address" placeholder="Address" value="%s" autofocus><br><br><input type="text" size="40" name="label" placeholder="Label" value="%s"><br><br><input type="submit" value="Update"></form>`, request.URL.Path+"?"+request.URL.RawQuery, html.EscapeString(editBookmark), html.EscapeString(label)))...)
data = append(data, []byte(fmt.Sprintf(`<form method="post" action="%s"><h3>Edit bookmark</h3><input type="text" size="40" name="address" placeholder="Address" value="%s" autofocus><br><br><input type="text" size="40" name="label" placeholder="Label" value="%s"><br><br><input type="submit" value="Update"></form>`, request.URL.Path+"?"+request.URL.RawQuery, html.EscapeString(editBookmark), html.EscapeString(label)))...)
data = append(data, []byte(pageFooter)...)
@ -326,7 +323,7 @@ func handleBookmarks(writer http.ResponseWriter, request *http.Request) {
labelFocus = "autofocus"
}
data = append(data, []byte(fmt.Sprintf(`<br><form method="post" action="/bookmarks"><h3>Add bookmark</h3><input type="text" size="40" name="address" placeholder="Address" value="%s" %s><br><br><input type="text" size="40" name="label" placeholder="Label" %s><br><br><input type="submit" value="Add"></form>`, html.EscapeString(addBookmark), addressFocus, labelFocus))...)
data = append(data, []byte(fmt.Sprintf(`<form method="post" action="/bookmarks"><h3>Add bookmark</h3><input type="text" size="40" name="address" placeholder="Address" value="%s" %s><br><br><input type="text" size="40" name="label" placeholder="Label" %s><br><br><input type="submit" value="Add"></form>`, html.EscapeString(addBookmark), addressFocus, labelFocus))...)
if len(bookmarks) > 0 && addBookmark == "" {
fakeURL, _ := url.Parse("/") // Always succeeds

Loading…
Cancel
Save