mamemose 0.4.0.2 → 0.4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +5 -6
- data/lib/mamemose/html.rb +221 -0
- data/lib/mamemose/version.rb +1 -1
- data/lib/mamemose.rb +2 -220
- metadata +15 -24
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 545fbe99d10fb35061bbfec50f5aefd514599e70
         | 
| 4 | 
            +
              data.tar.gz: a25605115077b430b9edbad9ed152f054abea889
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 5c7416e49f4fe27d1675e227092003fa9af7de3bd3545518de4bb32c747d5fd0634a548ba74d85a998e5e44b481765862690e48395d5c6ddeb71fe6507ed8cd5
         | 
| 7 | 
            +
              data.tar.gz: 4f41615561ed6da7426a403bbc400e0bad18e4851c18208a0e65e40fa7a3377d84176592b214f66f3d26340d1cee86cae67af37e29b9517ea45a4492673a2b72
         | 
    
        data/README.md
    CHANGED
    
    | @@ -182,18 +182,17 @@ RECENT_NUM = 0 | |
| 182 182 |  | 
| 183 183 | 
             
            # すべてのページで MathJax が使えるように
         | 
| 184 184 | 
             
            CUSTOM_HEADER = <<HEADER
         | 
| 185 | 
            -
            <script  | 
| 186 | 
            -
              src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
         | 
| 185 | 
            +
            <script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
         | 
| 187 186 | 
             
            </script>
         | 
| 188 187 | 
             
            HEADER
         | 
| 189 188 |  | 
| 190 189 | 
             
            # すべてのページで SyntaxHighlighter が使えるように
         | 
| 191 190 | 
             
            host = "http://alexgorbatchev.com/pub/sh/current" # 変数も使えます
         | 
| 192 191 | 
             
            CUSTOM_FOOTER = <<FOOTER
         | 
| 193 | 
            -
            <link href="#{host}/styles/shCoreDefault.css" rel="stylesheet"  | 
| 194 | 
            -
            <script src="#{host}/scripts/shCore.js" | 
| 195 | 
            -
            <script src="#{host}/scripts/shAutoloader.js" | 
| 196 | 
            -
            <script | 
| 192 | 
            +
            <link href="#{host}/styles/shCoreDefault.css" rel="stylesheet" />
         | 
| 193 | 
            +
            <script src="#{host}/scripts/shCore.js"></script>
         | 
| 194 | 
            +
            <script src="#{host}/scripts/shAutoloader.js"></script>
         | 
| 195 | 
            +
            <script>
         | 
| 197 196 | 
             
            SyntaxHighlighter.autoloader(
         | 
| 198 197 | 
             
            'AS3 as3 #{host}/scripts/shBrushAS3.js',
         | 
| 199 198 | 
             
            'AppleScript applescript #{host}/scripts/shBrushAppleScript.js',
         | 
| @@ -0,0 +1,221 @@ | |
| 1 | 
            +
            module Mamemose::HTML
         | 
| 2 | 
            +
              def header_html(title, fullpath)
         | 
| 3 | 
            +
                html = <<HTML
         | 
| 4 | 
            +
            <!DOCTYPE HTML>
         | 
| 5 | 
            +
            <html>
         | 
| 6 | 
            +
            <head>
         | 
| 7 | 
            +
            <meta http-equiv="Content-Type" content="#{CONTENT_TYPE}" />
         | 
| 8 | 
            +
            <title>#{title}</title>
         | 
| 9 | 
            +
            <style><!--
         | 
| 10 | 
            +
            body {
         | 
| 11 | 
            +
                margin: auto;
         | 
| 12 | 
            +
                padding: 0 2em;
         | 
| 13 | 
            +
                max-width: 80%;
         | 
| 14 | 
            +
                border-left: 1px solid black;
         | 
| 15 | 
            +
                border-right: 1px solid black;
         | 
| 16 | 
            +
                font-size: 100%;
         | 
| 17 | 
            +
                line-height: 140%;
         | 
| 18 | 
            +
            }
         | 
| 19 | 
            +
            pre {
         | 
| 20 | 
            +
                border: 1px solid #090909;
         | 
| 21 | 
            +
                background-color: #f8f8f8;
         | 
| 22 | 
            +
                padding: 0.5em;
         | 
| 23 | 
            +
                margin: 0.5em 1em;
         | 
| 24 | 
            +
            }
         | 
| 25 | 
            +
            code {
         | 
| 26 | 
            +
                border: 1px solid #cccccc;
         | 
| 27 | 
            +
                background-color: #f8f8f8;
         | 
| 28 | 
            +
                padding: 2px 0.5em;
         | 
| 29 | 
            +
                margin: 0 0.5em;
         | 
| 30 | 
            +
            }
         | 
| 31 | 
            +
            a {
         | 
| 32 | 
            +
                text-decoration: none;
         | 
| 33 | 
            +
            }
         | 
| 34 | 
            +
            a:link, a:visited, a:hover {
         | 
| 35 | 
            +
                color: #4444cc;
         | 
| 36 | 
            +
            }
         | 
| 37 | 
            +
            a:hover {
         | 
| 38 | 
            +
                text-decoration: underline;
         | 
| 39 | 
            +
            }
         | 
| 40 | 
            +
            h1, h2, h3 {
         | 
| 41 | 
            +
                font-weight: bold;
         | 
| 42 | 
            +
                color: #2f4f4f;
         | 
| 43 | 
            +
            }
         | 
| 44 | 
            +
            h1 {
         | 
| 45 | 
            +
                font-size: 200%;
         | 
| 46 | 
            +
                line-height: 100%;
         | 
| 47 | 
            +
                margin: 1em 0;
         | 
| 48 | 
            +
                border-bottom: 1px solid #2f4f4f;
         | 
| 49 | 
            +
            }
         | 
| 50 | 
            +
            h2 {
         | 
| 51 | 
            +
                font-size: 175%;
         | 
| 52 | 
            +
                line-height: 100%;
         | 
| 53 | 
            +
                margin: 1em 0;
         | 
| 54 | 
            +
                padding-left: 0.5em;
         | 
| 55 | 
            +
                border-left: 0.5em solid #2f4f4f;
         | 
| 56 | 
            +
            }
         | 
| 57 | 
            +
            h3 {
         | 
| 58 | 
            +
                font-size: 150%;
         | 
| 59 | 
            +
                line-height: 100%;
         | 
| 60 | 
            +
                margin: 1em 0;
         | 
| 61 | 
            +
            }
         | 
| 62 | 
            +
            h4, h5 {
         | 
| 63 | 
            +
                font-weight: bold;
         | 
| 64 | 
            +
                color: #000000;
         | 
| 65 | 
            +
                margin: 1em 0 0.5em;
         | 
| 66 | 
            +
            }
         | 
| 67 | 
            +
            h4 { font-size: 125% }
         | 
| 68 | 
            +
            h5 { font-size: 100% }
         | 
| 69 | 
            +
            p {
         | 
| 70 | 
            +
                margin: 0.7em 1em;
         | 
| 71 | 
            +
                text-indent: 1em;
         | 
| 72 | 
            +
            }
         | 
| 73 | 
            +
            div.footnotes {
         | 
| 74 | 
            +
                padding-top: 1em;
         | 
| 75 | 
            +
                color: #090909;
         | 
| 76 | 
            +
            }
         | 
| 77 | 
            +
            div#header {
         | 
| 78 | 
            +
                margin-top: 1em;
         | 
| 79 | 
            +
                padding-bottom: 1em;
         | 
| 80 | 
            +
                border-bottom: 1px dotted black;
         | 
| 81 | 
            +
            }
         | 
| 82 | 
            +
            div#header > form {
         | 
| 83 | 
            +
                display: float;
         | 
| 84 | 
            +
                float: right;
         | 
| 85 | 
            +
                text-align: right;
         | 
| 86 | 
            +
            }
         | 
| 87 | 
            +
            a.filename {
         | 
| 88 | 
            +
                color: #666666;
         | 
| 89 | 
            +
            }
         | 
| 90 | 
            +
            footer {
         | 
| 91 | 
            +
                border-top: 1px dotted black;
         | 
| 92 | 
            +
                padding: 0.5em;
         | 
| 93 | 
            +
                font-size: 80%;
         | 
| 94 | 
            +
                text-align: right;
         | 
| 95 | 
            +
                margin: 5em 0 1em;
         | 
| 96 | 
            +
            }
         | 
| 97 | 
            +
            blockquote {
         | 
| 98 | 
            +
                margin: 1em 3em;
         | 
| 99 | 
            +
                border: 2px solid #999;
         | 
| 100 | 
            +
                padding: 0.3em 0;
         | 
| 101 | 
            +
                background-color: #f3fff3;
         | 
| 102 | 
            +
            }
         | 
| 103 | 
            +
            hr {
         | 
| 104 | 
            +
                height: 1px;
         | 
| 105 | 
            +
                border: none;
         | 
| 106 | 
            +
                border-top: 1px solid black;
         | 
| 107 | 
            +
            }
         | 
| 108 | 
            +
            table {
         | 
| 109 | 
            +
                padding: 0;
         | 
| 110 | 
            +
                margin: 1em 2em;
         | 
| 111 | 
            +
                border-spacing: 0;
         | 
| 112 | 
            +
                border-collapse: collapse;
         | 
| 113 | 
            +
            }
         | 
| 114 | 
            +
            table tr {
         | 
| 115 | 
            +
                border-top: 1px solid #cccccc;
         | 
| 116 | 
            +
                background-color: white;
         | 
| 117 | 
            +
                margin: 0;
         | 
| 118 | 
            +
                padding: 0;
         | 
| 119 | 
            +
            }
         | 
| 120 | 
            +
            table tr:nth-child(2n) {
         | 
| 121 | 
            +
                background-color: #f8f8f8;
         | 
| 122 | 
            +
            }
         | 
| 123 | 
            +
            table tr th {
         | 
| 124 | 
            +
                font-weight: bold;
         | 
| 125 | 
            +
                border: 1px solid #cccccc;
         | 
| 126 | 
            +
                text-align: left;
         | 
| 127 | 
            +
                margin: 0;
         | 
| 128 | 
            +
                padding: 6px 13px;
         | 
| 129 | 
            +
            }
         | 
| 130 | 
            +
            table tr td {
         | 
| 131 | 
            +
                border: 1px solid #cccccc;
         | 
| 132 | 
            +
                text-align: left;
         | 
| 133 | 
            +
                margin: 0;
         | 
| 134 | 
            +
                padding: 6px 13px;
         | 
| 135 | 
            +
            }
         | 
| 136 | 
            +
            table tr th :first-child, table tr td :first-child {
         | 
| 137 | 
            +
                margin-top: 0;
         | 
| 138 | 
            +
            }
         | 
| 139 | 
            +
            table tr th :last-child, table tr td :last-child {
         | 
| 140 | 
            +
                margin-bottom: 0;
         | 
| 141 | 
            +
            }
         | 
| 142 | 
            +
            --></style>
         | 
| 143 | 
            +
            <script>
         | 
| 144 | 
            +
            function copy(text) {
         | 
| 145 | 
            +
              prompt("Copy filepath below:", text);
         | 
| 146 | 
            +
            }
         | 
| 147 | 
            +
            </script>
         | 
| 148 | 
            +
            <script>
         | 
| 149 | 
            +
            (function(){
         | 
| 150 | 
            +
              var fullpath = "#{fullpath}";
         | 
| 151 | 
            +
              ws = new WebSocket("ws://#{HOST}:#{WS_PORT}");
         | 
| 152 | 
            +
              ws.onopen = function() {
         | 
| 153 | 
            +
                console.log("WebSocket (port=#{WS_PORT}) connected: " + fullpath);
         | 
| 154 | 
            +
                ws.send(fullpath);
         | 
| 155 | 
            +
              };
         | 
| 156 | 
            +
              ws.onmessage = function(evt) {
         | 
| 157 | 
            +
                console.log("received: " + evt.data);
         | 
| 158 | 
            +
                if (evt.data == "updated") {
         | 
| 159 | 
            +
                  console.log("update detected. reloading...");
         | 
| 160 | 
            +
                  location.reload();
         | 
| 161 | 
            +
                }
         | 
| 162 | 
            +
              };
         | 
| 163 | 
            +
            })();
         | 
| 164 | 
            +
            </script>
         | 
| 165 | 
            +
            #{CUSTOM_HEADER}
         | 
| 166 | 
            +
            </head>
         | 
| 167 | 
            +
            <body id="body">
         | 
| 168 | 
            +
            #{CUSTOM_BODY}
         | 
| 169 | 
            +
            HTML
         | 
| 170 | 
            +
                return html
         | 
| 171 | 
            +
              end
         | 
| 172 | 
            +
             | 
| 173 | 
            +
              def search_form(path, q="")
         | 
| 174 | 
            +
                link_str = ""
         | 
| 175 | 
            +
                uri = ""
         | 
| 176 | 
            +
                path.split('/').each do |s|
         | 
| 177 | 
            +
                  next if s == ''
         | 
| 178 | 
            +
                  uri += "/" + s
         | 
| 179 | 
            +
                  link_str += File::SEPARATOR + "<a href='#{uri}'>#{s}</a>"
         | 
| 180 | 
            +
                end
         | 
| 181 | 
            +
                link_str +=  " <a class='filename' href=\"javascript:copy('#{docpath(uri)}');\">[copy]</a>"
         | 
| 182 | 
            +
                uri.gsub!('/'+File::basename(uri), "") if File.file?(fullpath(uri))
         | 
| 183 | 
            +
                link_str = "<a href='/'>#{DOCUMENT_ROOT}</a>" + link_str
         | 
| 184 | 
            +
                search_form = <<HTML
         | 
| 185 | 
            +
            <form action="/search" method="get">
         | 
| 186 | 
            +
            <input name="path" type="hidden" value="#{uri}" />
         | 
| 187 | 
            +
            <input name="q" type="text" value="#{q}" size="24" />
         | 
| 188 | 
            +
            <input type="submit" value="search" />
         | 
| 189 | 
            +
            </form>
         | 
| 190 | 
            +
            HTML
         | 
| 191 | 
            +
                return "<div id=\"header\">#{link_str}#{search_form}</div>"
         | 
| 192 | 
            +
              end
         | 
| 193 | 
            +
             | 
| 194 | 
            +
              def footer_html(filepath=nil)
         | 
| 195 | 
            +
                if filepath
         | 
| 196 | 
            +
                  updated = File.basename(filepath)\
         | 
| 197 | 
            +
                          + " [#{filesize(filepath)}]"\
         | 
| 198 | 
            +
                          + " / Last Updated: "\
         | 
| 199 | 
            +
                          + File.mtime(filepath).strftime("%Y-%m-%d %H:%M:%S")\
         | 
| 200 | 
            +
                          + " / "
         | 
| 201 | 
            +
                else
         | 
| 202 | 
            +
                  updated = ""
         | 
| 203 | 
            +
                end
         | 
| 204 | 
            +
                html = <<HTML
         | 
| 205 | 
            +
            #{CUSTOM_FOOTER}
         | 
| 206 | 
            +
            <footer id="footer">
         | 
| 207 | 
            +
            #{updated}
         | 
| 208 | 
            +
            <a href="https://github.com/daimatz/mamemose">mamemose: Markdown memo server</a>
         | 
| 209 | 
            +
            </footer>
         | 
| 210 | 
            +
            </body>
         | 
| 211 | 
            +
            </html>
         | 
| 212 | 
            +
            HTML
         | 
| 213 | 
            +
                return html
         | 
| 214 | 
            +
              end
         | 
| 215 | 
            +
             | 
| 216 | 
            +
              def link_list(title, link)
         | 
| 217 | 
            +
                file = fullpath(link)
         | 
| 218 | 
            +
                str = filesize(file)
         | 
| 219 | 
            +
                return "- [#{title}](#{link}) <a class='filename' href=\"javascript:copy('#{docpath(link)}');\">[#{escaped_basename(link)}, #{str}]</a>\n"
         | 
| 220 | 
            +
              end
         | 
| 221 | 
            +
            end
         | 
    
        data/lib/mamemose/version.rb
    CHANGED
    
    
    
        data/lib/mamemose.rb
    CHANGED
    
    | @@ -7,6 +7,7 @@ require 'htmlentities' | |
| 7 7 |  | 
| 8 8 | 
             
            require 'mamemose/version'
         | 
| 9 9 |  | 
| 10 | 
            +
            require 'mamemose/html'
         | 
| 10 11 | 
             
            require 'mamemose/path'
         | 
| 11 12 |  | 
| 12 13 | 
             
            require 'mamemose/env'
         | 
| @@ -21,6 +22,7 @@ end | |
| 21 22 |  | 
| 22 23 | 
             
            class Mamemose::Server
         | 
| 23 24 | 
             
              include Mamemose::Path
         | 
| 25 | 
            +
              include Mamemose::HTML
         | 
| 24 26 |  | 
| 25 27 | 
             
              def initialize(port)
         | 
| 26 28 | 
             
                @mamemose = WEBrick::HTTPServer.new({ :Port => port ? port.to_i : PORT })
         | 
| @@ -70,220 +72,6 @@ private | |
| 70 72 | 
             
                @mamemose.shutdown
         | 
| 71 73 | 
             
              end
         | 
| 72 74 |  | 
| 73 | 
            -
              def header_html(title, fullpath)
         | 
| 74 | 
            -
                html = <<HTML
         | 
| 75 | 
            -
            <!DOCTYPE HTML>
         | 
| 76 | 
            -
            <html>
         | 
| 77 | 
            -
            <head>
         | 
| 78 | 
            -
            <meta http-equiv="Content-Type" content="#{CONTENT_TYPE}" />
         | 
| 79 | 
            -
            <title>#{title}</title>
         | 
| 80 | 
            -
            <style type="text/css"><!--
         | 
| 81 | 
            -
            body {
         | 
| 82 | 
            -
                margin: auto;
         | 
| 83 | 
            -
                padding: 0 2em;
         | 
| 84 | 
            -
                max-width: 80%;
         | 
| 85 | 
            -
                border-left: 1px solid black;
         | 
| 86 | 
            -
                border-right: 1px solid black;
         | 
| 87 | 
            -
                font-size: 100%;
         | 
| 88 | 
            -
                line-height: 140%;
         | 
| 89 | 
            -
            }
         | 
| 90 | 
            -
            pre {
         | 
| 91 | 
            -
                border: 1px solid #090909;
         | 
| 92 | 
            -
                background-color: #f8f8f8;
         | 
| 93 | 
            -
                padding: 0.5em;
         | 
| 94 | 
            -
                margin: 0.5em 1em;
         | 
| 95 | 
            -
            }
         | 
| 96 | 
            -
            code {
         | 
| 97 | 
            -
                border: 1px solid #cccccc;
         | 
| 98 | 
            -
                background-color: #f8f8f8;
         | 
| 99 | 
            -
                padding: 2px 0.5em;
         | 
| 100 | 
            -
                margin: 0 0.5em;
         | 
| 101 | 
            -
            }
         | 
| 102 | 
            -
            a {
         | 
| 103 | 
            -
                text-decoration: none;
         | 
| 104 | 
            -
            }
         | 
| 105 | 
            -
            a:link, a:visited, a:hover {
         | 
| 106 | 
            -
                color: #4444cc;
         | 
| 107 | 
            -
            }
         | 
| 108 | 
            -
            a:hover {
         | 
| 109 | 
            -
                text-decoration: underline;
         | 
| 110 | 
            -
            }
         | 
| 111 | 
            -
            h1, h2, h3 {
         | 
| 112 | 
            -
                font-weight: bold;
         | 
| 113 | 
            -
                color: #2f4f4f;
         | 
| 114 | 
            -
            }
         | 
| 115 | 
            -
            h1 {
         | 
| 116 | 
            -
                font-size: 200%;
         | 
| 117 | 
            -
                line-height: 100%;
         | 
| 118 | 
            -
                margin: 1em 0;
         | 
| 119 | 
            -
                border-bottom: 1px solid #2f4f4f;
         | 
| 120 | 
            -
            }
         | 
| 121 | 
            -
            h2 {
         | 
| 122 | 
            -
                font-size: 175%;
         | 
| 123 | 
            -
                line-height: 100%;
         | 
| 124 | 
            -
                margin: 1em 0;
         | 
| 125 | 
            -
                padding-left: 0.5em;
         | 
| 126 | 
            -
                border-left: 0.5em solid #2f4f4f;
         | 
| 127 | 
            -
            }
         | 
| 128 | 
            -
            h3 {
         | 
| 129 | 
            -
                font-size: 150%;
         | 
| 130 | 
            -
                line-height: 100%;
         | 
| 131 | 
            -
                margin: 1em 0;
         | 
| 132 | 
            -
            }
         | 
| 133 | 
            -
            h4, h5 {
         | 
| 134 | 
            -
                font-weight: bold;
         | 
| 135 | 
            -
                color: #000000;
         | 
| 136 | 
            -
                margin: 1em 0 0.5em;
         | 
| 137 | 
            -
            }
         | 
| 138 | 
            -
            h4 { font-size: 125% }
         | 
| 139 | 
            -
            h5 { font-size: 100% }
         | 
| 140 | 
            -
            p {
         | 
| 141 | 
            -
                margin: 0.7em 1em;
         | 
| 142 | 
            -
                text-indent: 1em;
         | 
| 143 | 
            -
            }
         | 
| 144 | 
            -
            div.footnotes {
         | 
| 145 | 
            -
                padding-top: 1em;
         | 
| 146 | 
            -
                color: #090909;
         | 
| 147 | 
            -
            }
         | 
| 148 | 
            -
            div#header {
         | 
| 149 | 
            -
                margin-top: 1em;
         | 
| 150 | 
            -
                padding-bottom: 1em;
         | 
| 151 | 
            -
                border-bottom: 1px dotted black;
         | 
| 152 | 
            -
            }
         | 
| 153 | 
            -
            div#header > form {
         | 
| 154 | 
            -
                display: float;
         | 
| 155 | 
            -
                float: right;
         | 
| 156 | 
            -
                text-align: right;
         | 
| 157 | 
            -
            }
         | 
| 158 | 
            -
            a.filename {
         | 
| 159 | 
            -
                color: #666666;
         | 
| 160 | 
            -
            }
         | 
| 161 | 
            -
            footer {
         | 
| 162 | 
            -
                border-top: 1px dotted black;
         | 
| 163 | 
            -
                padding: 0.5em;
         | 
| 164 | 
            -
                font-size: 80%;
         | 
| 165 | 
            -
                text-align: right;
         | 
| 166 | 
            -
                margin: 5em 0 1em;
         | 
| 167 | 
            -
            }
         | 
| 168 | 
            -
            blockquote {
         | 
| 169 | 
            -
                margin: 1em 3em;
         | 
| 170 | 
            -
                border: 2px solid #999;
         | 
| 171 | 
            -
                padding: 0.3em 0;
         | 
| 172 | 
            -
                background-color: #f3fff3;
         | 
| 173 | 
            -
            }
         | 
| 174 | 
            -
            hr {
         | 
| 175 | 
            -
                height: 1px;
         | 
| 176 | 
            -
                border: none;
         | 
| 177 | 
            -
                border-top: 1px solid black;
         | 
| 178 | 
            -
            }
         | 
| 179 | 
            -
            table {
         | 
| 180 | 
            -
                padding: 0;
         | 
| 181 | 
            -
                margin: 1em 2em;
         | 
| 182 | 
            -
                border-spacing: 0;
         | 
| 183 | 
            -
                border-collapse: collapse;
         | 
| 184 | 
            -
            }
         | 
| 185 | 
            -
            table tr {
         | 
| 186 | 
            -
                border-top: 1px solid #cccccc;
         | 
| 187 | 
            -
                background-color: white;
         | 
| 188 | 
            -
                margin: 0;
         | 
| 189 | 
            -
                padding: 0;
         | 
| 190 | 
            -
            }
         | 
| 191 | 
            -
            table tr:nth-child(2n) {
         | 
| 192 | 
            -
                background-color: #f8f8f8;
         | 
| 193 | 
            -
            }
         | 
| 194 | 
            -
            table tr th {
         | 
| 195 | 
            -
                font-weight: bold;
         | 
| 196 | 
            -
                border: 1px solid #cccccc;
         | 
| 197 | 
            -
                text-align: left;
         | 
| 198 | 
            -
                margin: 0;
         | 
| 199 | 
            -
                padding: 6px 13px;
         | 
| 200 | 
            -
            }
         | 
| 201 | 
            -
            table tr td {
         | 
| 202 | 
            -
                border: 1px solid #cccccc;
         | 
| 203 | 
            -
                text-align: left;
         | 
| 204 | 
            -
                margin: 0;
         | 
| 205 | 
            -
                padding: 6px 13px;
         | 
| 206 | 
            -
            }
         | 
| 207 | 
            -
            table tr th :first-child, table tr td :first-child {
         | 
| 208 | 
            -
                margin-top: 0;
         | 
| 209 | 
            -
            }
         | 
| 210 | 
            -
            table tr th :last-child, table tr td :last-child {
         | 
| 211 | 
            -
                margin-bottom: 0;
         | 
| 212 | 
            -
            }
         | 
| 213 | 
            -
            --></style>
         | 
| 214 | 
            -
            <script>
         | 
| 215 | 
            -
            function copy(text) {
         | 
| 216 | 
            -
              prompt("Copy filepath below:", text);
         | 
| 217 | 
            -
            }
         | 
| 218 | 
            -
            </script>
         | 
| 219 | 
            -
            <script>
         | 
| 220 | 
            -
            (function(){
         | 
| 221 | 
            -
              var fullpath = "#{fullpath}";
         | 
| 222 | 
            -
              ws = new WebSocket("ws://#{HOST}:#{WS_PORT}");
         | 
| 223 | 
            -
              ws.onopen = function() {
         | 
| 224 | 
            -
                console.log("WebSocket (port=#{WS_PORT}) connected: " + fullpath);
         | 
| 225 | 
            -
                ws.send(fullpath);
         | 
| 226 | 
            -
              };
         | 
| 227 | 
            -
              ws.onmessage = function(evt) {
         | 
| 228 | 
            -
                console.log("received: " + evt.data);
         | 
| 229 | 
            -
                if (evt.data == "updated") {
         | 
| 230 | 
            -
                  console.log("update detected. reloading...");
         | 
| 231 | 
            -
                  location.reload();
         | 
| 232 | 
            -
                }
         | 
| 233 | 
            -
              };
         | 
| 234 | 
            -
            })();
         | 
| 235 | 
            -
            </script>
         | 
| 236 | 
            -
            #{CUSTOM_HEADER}
         | 
| 237 | 
            -
            </head>
         | 
| 238 | 
            -
            <body>
         | 
| 239 | 
            -
            #{CUSTOM_BODY}
         | 
| 240 | 
            -
            HTML
         | 
| 241 | 
            -
                return html
         | 
| 242 | 
            -
              end
         | 
| 243 | 
            -
             | 
| 244 | 
            -
              def search_form(path, q="")
         | 
| 245 | 
            -
                link_str = ""
         | 
| 246 | 
            -
                uri = ""
         | 
| 247 | 
            -
                path.split('/').each do |s|
         | 
| 248 | 
            -
                  next if s == ''
         | 
| 249 | 
            -
                  uri += "/" + s
         | 
| 250 | 
            -
                  link_str += File::SEPARATOR + "<a href='#{uri}'>#{s}</a>"
         | 
| 251 | 
            -
                end
         | 
| 252 | 
            -
                link_str +=  " <a class='filename' href=\"javascript:copy('#{docpath(uri)}');\">[copy]</a>"
         | 
| 253 | 
            -
                uri.gsub!('/'+File::basename(uri), "") if File.file?(fullpath(uri))
         | 
| 254 | 
            -
                link_str = "<a href='/'>#{DOCUMENT_ROOT}</a>" + link_str
         | 
| 255 | 
            -
                search_form = <<HTML
         | 
| 256 | 
            -
            <form action="/search" method="get">
         | 
| 257 | 
            -
            <input name="path" type="hidden" value="#{uri}" />
         | 
| 258 | 
            -
            <input name="q" type="text" value="#{q}" size="24" />
         | 
| 259 | 
            -
            <input type="submit" value="search" />
         | 
| 260 | 
            -
            </form>
         | 
| 261 | 
            -
            HTML
         | 
| 262 | 
            -
                return "<div id=\"header\">#{link_str}#{search_form}</div>"
         | 
| 263 | 
            -
              end
         | 
| 264 | 
            -
             | 
| 265 | 
            -
              def footer_html(filepath=nil)
         | 
| 266 | 
            -
                if filepath
         | 
| 267 | 
            -
                  updated = File.basename(filepath)\
         | 
| 268 | 
            -
                          + " [#{filesize(filepath)}]"\
         | 
| 269 | 
            -
                          + " / Last Updated: "\
         | 
| 270 | 
            -
                          + File.mtime(filepath).strftime("%Y-%m-%d %H:%M:%S")\
         | 
| 271 | 
            -
                          + " / "
         | 
| 272 | 
            -
                else
         | 
| 273 | 
            -
                  updated = ""
         | 
| 274 | 
            -
                end
         | 
| 275 | 
            -
                html = <<HTML
         | 
| 276 | 
            -
            #{CUSTOM_FOOTER}
         | 
| 277 | 
            -
            <footer>
         | 
| 278 | 
            -
            #{updated}
         | 
| 279 | 
            -
            <a href="https://github.com/daimatz/mamemose">mamemose: Markdown memo server</a>
         | 
| 280 | 
            -
            </footer>
         | 
| 281 | 
            -
            </body>
         | 
| 282 | 
            -
            </html>
         | 
| 283 | 
            -
            HTML
         | 
| 284 | 
            -
                return html
         | 
| 285 | 
            -
              end
         | 
| 286 | 
            -
             | 
| 287 75 | 
             
              def req_search(req, res)
         | 
| 288 76 | 
             
                query = req.query
         | 
| 289 77 | 
             
                path = fullpath(query["path"])
         | 
| @@ -419,12 +207,6 @@ HTML | |
| 419 207 | 
             
                return {:dirs=>dirs, :markdowns=>markdowns, :others=>others}
         | 
| 420 208 | 
             
              end
         | 
| 421 209 |  | 
| 422 | 
            -
              def link_list(title, link)
         | 
| 423 | 
            -
                file = fullpath(link)
         | 
| 424 | 
            -
                str = filesize(file)
         | 
| 425 | 
            -
                return "- [#{title}](#{link}) <a class='filename' href=\"javascript:copy('#{docpath(link)}');\">[#{escaped_basename(link)}, #{str}]</a>\n"
         | 
| 426 | 
            -
              end
         | 
| 427 | 
            -
             | 
| 428 210 | 
             
              def filesize(file)
         | 
| 429 211 | 
             
                File.file?(file) ? sprintf("%.1fKB", File.size(file) / 1024.0) : "dir"
         | 
| 430 212 | 
             
              end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,8 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: mamemose
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.4.0. | 
| 5 | 
            -
              prerelease: 
         | 
| 4 | 
            +
              version: 0.4.0.3
         | 
| 6 5 | 
             
            platform: ruby
         | 
| 7 6 | 
             
            authors:
         | 
| 8 7 | 
             
            - daimatz
         | 
| @@ -14,65 +13,57 @@ dependencies: | |
| 14 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 14 | 
             
              name: redcarpet
         | 
| 16 15 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 17 | 
            -
                none: false
         | 
| 18 16 | 
             
                requirements:
         | 
| 19 | 
            -
                - -  | 
| 17 | 
            +
                - - '>='
         | 
| 20 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 21 19 | 
             
                    version: 2.2.0
         | 
| 22 20 | 
             
              type: :runtime
         | 
| 23 21 | 
             
              prerelease: false
         | 
| 24 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 25 | 
            -
                none: false
         | 
| 26 23 | 
             
                requirements:
         | 
| 27 | 
            -
                - -  | 
| 24 | 
            +
                - - '>='
         | 
| 28 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 29 26 | 
             
                    version: 2.2.0
         | 
| 30 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 31 28 | 
             
              name: htmlentities
         | 
| 32 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 33 | 
            -
                none: false
         | 
| 34 30 | 
             
                requirements:
         | 
| 35 | 
            -
                - -  | 
| 31 | 
            +
                - - '>='
         | 
| 36 32 | 
             
                  - !ruby/object:Gem::Version
         | 
| 37 33 | 
             
                    version: 4.3.0
         | 
| 38 34 | 
             
              type: :runtime
         | 
| 39 35 | 
             
              prerelease: false
         | 
| 40 36 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 41 | 
            -
                none: false
         | 
| 42 37 | 
             
                requirements:
         | 
| 43 | 
            -
                - -  | 
| 38 | 
            +
                - - '>='
         | 
| 44 39 | 
             
                  - !ruby/object:Gem::Version
         | 
| 45 40 | 
             
                    version: 4.3.0
         | 
| 46 41 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 47 42 | 
             
              name: thor
         | 
| 48 43 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 49 | 
            -
                none: false
         | 
| 50 44 | 
             
                requirements:
         | 
| 51 | 
            -
                - -  | 
| 45 | 
            +
                - - '>='
         | 
| 52 46 | 
             
                  - !ruby/object:Gem::Version
         | 
| 53 47 | 
             
                    version: 0.17.0
         | 
| 54 48 | 
             
              type: :runtime
         | 
| 55 49 | 
             
              prerelease: false
         | 
| 56 50 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 57 | 
            -
                none: false
         | 
| 58 51 | 
             
                requirements:
         | 
| 59 | 
            -
                - -  | 
| 52 | 
            +
                - - '>='
         | 
| 60 53 | 
             
                  - !ruby/object:Gem::Version
         | 
| 61 54 | 
             
                    version: 0.17.0
         | 
| 62 55 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 63 56 | 
             
              name: em-websocket
         | 
| 64 57 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 65 | 
            -
                none: false
         | 
| 66 58 | 
             
                requirements:
         | 
| 67 | 
            -
                - -  | 
| 59 | 
            +
                - - '>='
         | 
| 68 60 | 
             
                  - !ruby/object:Gem::Version
         | 
| 69 61 | 
             
                    version: 0.5.0
         | 
| 70 62 | 
             
              type: :runtime
         | 
| 71 63 | 
             
              prerelease: false
         | 
| 72 64 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 73 | 
            -
                none: false
         | 
| 74 65 | 
             
                requirements:
         | 
| 75 | 
            -
                - -  | 
| 66 | 
            +
                - - '>='
         | 
| 76 67 | 
             
                  - !ruby/object:Gem::Version
         | 
| 77 68 | 
             
                    version: 0.5.0
         | 
| 78 69 | 
             
            description: Markdown memo server
         | 
| @@ -94,6 +85,7 @@ files: | |
| 94 85 | 
             
            - index.png
         | 
| 95 86 | 
             
            - lib/mamemose.rb
         | 
| 96 87 | 
             
            - lib/mamemose/env.rb
         | 
| 88 | 
            +
            - lib/mamemose/html.rb
         | 
| 97 89 | 
             
            - lib/mamemose/path.rb
         | 
| 98 90 | 
             
            - lib/mamemose/util.rb
         | 
| 99 91 | 
             
            - lib/mamemose/version.rb
         | 
| @@ -102,26 +94,25 @@ files: | |
| 102 94 | 
             
            - sample.png
         | 
| 103 95 | 
             
            homepage: https://github.com/daimatz/mamemose
         | 
| 104 96 | 
             
            licenses: []
         | 
| 97 | 
            +
            metadata: {}
         | 
| 105 98 | 
             
            post_install_message: 
         | 
| 106 99 | 
             
            rdoc_options: []
         | 
| 107 100 | 
             
            require_paths:
         | 
| 108 101 | 
             
            - lib
         | 
| 109 102 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 110 | 
            -
              none: false
         | 
| 111 103 | 
             
              requirements:
         | 
| 112 | 
            -
              - -  | 
| 104 | 
            +
              - - '>='
         | 
| 113 105 | 
             
                - !ruby/object:Gem::Version
         | 
| 114 106 | 
             
                  version: '0'
         | 
| 115 107 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 116 | 
            -
              none: false
         | 
| 117 108 | 
             
              requirements:
         | 
| 118 | 
            -
              - -  | 
| 109 | 
            +
              - - '>='
         | 
| 119 110 | 
             
                - !ruby/object:Gem::Version
         | 
| 120 111 | 
             
                  version: '0'
         | 
| 121 112 | 
             
            requirements: []
         | 
| 122 113 | 
             
            rubyforge_project: 
         | 
| 123 | 
            -
            rubygems_version:  | 
| 114 | 
            +
            rubygems_version: 2.0.0
         | 
| 124 115 | 
             
            signing_key: 
         | 
| 125 | 
            -
            specification_version:  | 
| 116 | 
            +
            specification_version: 4
         | 
| 126 117 | 
             
            summary: Markdown memo server
         | 
| 127 118 | 
             
            test_files: []
         |