Changeset 31 in code for trunk/morty.go


Ignore:
Timestamp:
Nov 23, 2016, 8:55:12 PM (9 years ago)
Author:
alex
Message:

[mod] static HTML :

  • footer remains at the bottom except when the page is too small
  • wider input box for URL
  • information on proxyfied pages are (perhaps?) always display in the same way (same size, same font)
  • the referrer is not sent to the original page (rel="noreferrer")
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/morty.go

    r30 r31  
    110110<div id="mortyheader">
    111111  <input type="checkbox" id="mortytoggle" autocomplete="off" />
    112   <div><p>This is a proxified and sanitized view of the page,<br />visit <a href="%s">original site</a>.</p><div><p><label for="mortytoggle">hide</label></p></div></div>
     112  <div><p>This is a proxified and sanitized view of the page,<br />visit <a href="%s" rel="noreferrer">original site</a>.</p><p><label for="mortytoggle">hide</label></p></div>
    113113</div>
    114114<style>
    115 #mortyheader { position: fixed; top: 15%%; left: 0; max-width: 10em; color: #444; overflow: hidden; z-index: 110000; font-size: 0.9em; padding: 1em 1em 1em 0; margin: 0; }
    116 #mortyheader a { color: #3498db; }
    117 #mortyheader p { padding: 0; margin: 0; }
    118 #mortyheader > div { padding: 8px; font-size: 0.9em; border-width: 4px 4px 4px 0; border-style: solid; border-color: #1abc9c; background: #FFF; line-height: 1em; }
     115#mortyheader { position: fixed; padding: 12px 12px 12px 0; margin: 0; box-sizing: content-box; top: 15%%; left: 0; max-width: 140px; color: #444; overflow: hidden; z-index: 110000; font-size: 12px; line-height: normal; }
     116#mortyheader a { color: #3498db; font-weight: bold; }
     117#mortyheader p { padding: 0 0 0.7em 0; margin: 0; }
     118#mortyheader > div { padding: 8px; font-size: 12px !important; font-family: sans !important; border-width: 4px 4px 4px 0; border-style: solid; border-color: #1abc9c; background: #FFF; line-height: 1em; }
    119119#mortyheader label { text-align: right; cursor: pointer; display: block; color: #444; padding: 0; margin: 0; }
    120120input[type=checkbox]#mortytoggle { display: none; }
     
    492492        if bytes.Equal(http_equiv, []byte("refresh")) && urlIndex != -1 {
    493493                contentUrl := content[urlIndex+4:]
    494                 // special case of <meta http-equiv="refresh" content="0; url='example.com/url.with.quote.outside'">
    495                 if len(contentUrl)>=2 && (contentUrl[0] == byte('\'') || contentUrl[0] == byte('"')) {
    496                         if contentUrl[0] == contentUrl[len(contentUrl)-1] {
    497                                 contentUrl=contentUrl[1:len(contentUrl)-1]
    498                         }
    499                 }
    500                 // output proxify result
    501494                if uri, err := rc.ProxifyURI(string(contentUrl)); err == nil {
    502495                        fmt.Fprintf(out, ` http-equiv="refresh" content="%surl=%s"`, content[:urlIndex], uri)
     
    533526}
    534527
    535 func mergeURIs(u1, u2 *url.URL) (*url.URL) {
     528func mergeURIs(u1, u2 *url.URL) *url.URL {
    536529        return u1.ResolveReference(u2)
    537530}
     
    597590<head>
    598591<title>MortyProxy</title>
     592<meta name="viewport" content="width=device-width, initial-scale=1 , maximum-scale=1.0, user-scalable=1" />
    599593<style>
    600 body { font-family: 'Garamond', 'Georgia', serif; text-align: center; color: #444; background: #FAFAFA; margin: 0; padding: 0; font-size: 1.1em; }
     594html { height: 100%; }
     595body { min-height : 100%; display: flex; flex-direction:column; font-family: 'Garamond', 'Georgia', serif; text-align: center; color: #444; background: #FAFAFA; margin: 0; padding: 0; font-size: 1.1em; }
    601596input { border: 1px solid #888; padding: 0.3em; color: #444; background: #FFF; font-size: 1.1em; }
     597input[placeholder] { width:80%; }
    602598a { text-decoration: none; #2980b9; }
    603599h1, h2 { font-weight: 200; margin-bottom: 2rem; }
    604600h1 { font-size: 3em; }
    605 .footer { position: absolute; bottom: 2em; width: 100%; }
     601.container { flex:1; min-height: 100%; margin-bottom: 1em; }
     602.footer { margin: 1em; }
    606603.footer p { font-size: 0.8em; }
    607 
    608604</style>
    609605</head>
    610606<body>
    611         <h1>MortyProxy</h1>`))
     607        <div class="container">
     608                <h1>MortyProxy</h1>
     609`))
    612610        if err != nil {
    613611                ctx.SetStatusCode(404)
     
    621619        if p.Key == nil {
    622620                ctx.Write([]byte(`
    623 <form action="post">
    624         Visit url: <input placeholder="https://url.." name="mortyurl" />
    625         <input type="submit" value="go" />
    626 </form>`))
     621                <form action="post">
     622                Visit url: <input placeholder="https://url.." name="mortyurl" autofocus />
     623                <input type="submit" value="go" />
     624                </form>`))
    627625        } else {
    628626                ctx.Write([]byte(`<h3>Warning! This instance does not support direct URL opening.</h3>`))
    629627        }
    630628        ctx.Write([]byte(`
    631 <div class="footer">
    632         <p>Morty rewrites web pages to exclude malicious HTML tags and CSS/HTML attributes. It also replaces external resource references to prevent third-party information leaks.<br />
    633         <a href="https://github.com/asciimoo/morty">view on github</a>
    634         </p>
    635 </div>
     629        </div>
     630        <div class="footer">
     631                <p>Morty rewrites web pages to exclude malicious HTML tags and CSS/HTML attributes. It also replaces external resource references to prevent third-party information leaks.<br />
     632                <a href="https://github.com/asciimoo/morty">view on github</a>
     633                </p>
     634        </div>
    636635</body>
    637636</html>`))
Note: See TracChangeset for help on using the changeset viewer.