github.com/machinebox/remoto@v0.1.2-0.20191024144331-eff21a7d321f/console/www/templates/definition.plush.html (about) 1 <% contentFor("body") { %> 2 <div class='container'> 3 <div class='row'> 4 <div class='col col-8'> 5 <%= contentOf("docs") %> 6 </div> 7 <div class='col col-4'> 8 <ul class='list-group'> 9 <%= for (template) in templates { %> 10 <%= if (!template.Experimental) { %> 11 <li class='list-group-item'> 12 <form method='post' action='/api/templates/<%= template.Name %>?dl=1'> 13 <input type='hidden' name='definition' value="<%= htmlEscape(source) %>"> 14 <%= for (dir) in template.Dirs { %> 15 <span class='badge badge-secondary text-uppercase'><%= dir %></span> 16 <% } %> 17 <button class='btn btn-link'><%= def.PackageName %>.<%= template.Label %></button> 18 </form> 19 </li> 20 <% } %> 21 <% } %> 22 <li class='active list-group-item'> 23 <form method='post' action='/api/all.zip'> 24 <input type='hidden' name='definition' value="<%= htmlEscape(source) %>"> 25 <button class='btn'><%= def.PackageName %>.remoto.zip</button> 26 </form> 27 </li> 28 </ul> 29 <hr> 30 <strong>Experimental</strong> 31 <%= for (template) in templates { %> 32 <%= if (template.Experimental) { %> 33 <form method='post' action='/api/templates/<%= template.Name %>?dl=1'> 34 <input type='hidden' name='definition' value="<%= htmlEscape(source) %>"> 35 <button class='btn btn-link'><%= template.Name %></button> 36 </form> 37 <% } %> 38 <% } %> 39 40 </div> 41 </div> 42 </div> 43 <% } %> 44 <% contentFor("head") { %> 45 <title><%= def.PackageName %> on Remoto - The simplest RPC ecosystem built for right now</title> 46 <meta itemprop="name" content="<%= def.PackageName %> on Remoto"> 47 <meta name="og:title" content="<%= def.PackageName %> on Remoto"> 48 <meta name="twitter:title" content="<%= def.PackageName %> on Remoto"> 49 <style> 50 .content { 51 padding: 20px; 52 } 53 .page { 54 padding-top: 10px; 55 padding-bottom: 10px; 56 } 57 .highlightable { 58 border-left: 10px white solid; 59 transition: border-left 1s; 60 padding-left: 10px; 61 margin-left: -10px; 62 } 63 .highlightable.highlight { 64 border-left: 10px #f8f9fa solid; 65 transition: border-left 1s; 66 } 67 .anchor-container .anchor { 68 opacity: 0; 69 color: #ddd; 70 font-weight: 200; 71 } 72 .anchor-container:hover .anchor { 73 opacity: 1; 74 text-decoration: none; 75 transition: color .16s linear; 76 } 77 .anchor:hover { 78 color: #f08da9; 79 } 80 ::selection { 81 color: #fff; 82 background: #f08da9; 83 } 84 .heading { 85 font-weight: 300; 86 } 87 .heading .text-muted { 88 opacity: 0.5; 89 font-weight: 100; 90 } 91 pre.code { 92 background-color: #f8f9fa; 93 padding: 10px; 94 overflow-y: scroll; 95 max-height: 600px; 96 } 97 .list-group-item .btn-link { 98 padding: 0; 99 } 100 </style> 101 <% } %> 102 <% contentFor("navbar") { %> 103 <div class='form-inline'> 104 <input id='jump-to' list='symbols' type='text' class='form-control' placeholder='Jump to…'> 105 </div> 106 <% } %> 107 <% contentFor("scripts") { %> 108 <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script> 109 <script> 110 $(function(){ 111 112 $.fn.hide = function(){ 113 $(this).addClass('d-none') 114 } 115 $.fn.show = function(){ 116 $(this).removeClass('d-none') 117 } 118 119 function checkJumpTo(){ 120 var val = $(this).val().replace('.','_') 121 var hit = null 122 var hash = '<%= def.PackageName %>_' + val 123 hash = hash.replace('.','_').replace(' ','_') 124 try{ hit = $('#'+hash) }catch{} 125 if (hit && hit.length > 0) { 126 $(this).val('') 127 hit.niceScroll() 128 location.hash = hash 129 } 130 } 131 $('#jump-to').keyup(debounce(checkJumpTo, 500)).keyup(function(e){ 132 if (e.keyCode == 10 || e.keyCode == 13) { 133 checkJumpTo.apply(this, arguments) 134 } 135 }) 136 $('#jump-to').change(function(){ 137 checkJumpTo.apply(this, arguments) 138 }) 139 140 $(window).keypress(function(e){ 141 if (e.target.tagName != "BODY") { return } 142 if (e.key.length > 1) { return } 143 e.preventDefault() 144 $('#jump-to').val(e.key).focus() 145 }) 146 147 // niceScroll gently scrolls the page to this element. 148 $.fn.niceScroll = function(noanimate){ 149 console.info('niceScroll') 150 if ($(this).length === 0) { return } 151 noanimate = noanimate || false 152 var x = $(this).offset().top - $.fn.niceScroll.topMargin 153 if (noanimate) { 154 return $('html,body').css({ 155 scrollTop: x 156 }) 157 } 158 return $('html,body').animate({ 159 scrollTop: x 160 }, 'slow') 161 } 162 $.fn.niceScroll.topMargin = 60 163 164 function changeRoute(route, noanimate) { 165 if (route == "#") { return } 166 if (!route) { return } 167 $('.page.highlight').removeClass('highlight') 168 var target = $(route).addClass('highlight') 169 if (location.hash != route) { 170 history.pushState(null, null, route) 171 } 172 target.niceScroll(noanimate) 173 } 174 $(window).bind('hashchange', function() { 175 changeRoute(location.hash) 176 }) 177 var hash = location.hash 178 if (hash.length > 0) { 179 changeRoute(hash, true) 180 } 181 182 // $.scrollToTop scrolls the page to the top. 183 $.scrollToTop = function(){ 184 $('html,body').animate({ 185 scrollTop: 0 186 }, 'slow') 187 } 188 189 $('a[href^="#"]').click(function(e){ 190 e.preventDefault() 191 var $this = $(this) 192 changeRoute($this.attr('href')) 193 }) 194 195 // from https://davidwalsh.name/javascript-debounce-function 196 // Returns a function, that, as long as it continues to be invoked, will not 197 // be triggered. The function will be called after it stops being called for 198 // N milliseconds. If `immediate` is passed, trigger the function on the 199 // leading edge, instead of the trailing. 200 function debounce(func, wait, immediate) { 201 var timeout 202 return function() { 203 var context = this, args = arguments; 204 var later = function() { 205 timeout = null 206 if (!immediate) func.apply(context, args) 207 }; 208 var callNow = immediate && !timeout 209 clearTimeout(timeout) 210 timeout = setTimeout(later, wait) 211 if (callNow) func.apply(context, args) 212 } 213 } 214 215 $('[data-action="download-source"]').click(function(e){ 216 e.preventDefault() 217 $.download('<%= def.PackageName %>.remoto.go', $('.source.code code').text()) 218 }) 219 220 $.download = function(filename, text) { 221 var element = document.createElement('a'); 222 element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); 223 element.setAttribute('download', filename); 224 element.style.display = 'none'; 225 document.body.appendChild(element); 226 element.click(); 227 document.body.removeChild(element); 228 } 229 230 }) 231 </script> 232 <datalist id='symbols'> 233 <%= for (service) in def.Services { %> 234 <option value='<%= service.Name %>'> 235 <%= for (method) in service.Methods { %> 236 <option value='<%= service.Name %>.<%= method.Name %>'> 237 <% } %> 238 <%= for (structure) in unique_structures(def) { %> 239 <option value='<%= structure.Name %>'> 240 <% } %> 241 <% } %> 242 <option value='Special types'> 243 <option value='Definition'> 244 </datalist> 245 <% } %> 246 <% contentFor("docs") { %> 247 <div class='content'> 248 <%= if (len(def.Services) > 1) { %> 249 <ul class='nav justify-content-end'> 250 <%= for (service) in def.Services { %> 251 <li class='nav=item'> 252 <a class='nav-link' href='#<%= def.PackageName %>_<%= service.Name %>'><%= service.Name %></a> 253 </li> 254 <% } %> 255 </ul> 256 <hr> 257 <% } %> 258 <%= for (service) in def.Services { %> 259 <section id='<%= def.PackageName %>_<%= service.Name %>'> 260 <h2 class='display-4'> 261 <%= service.Name %> 262 </h2> 263 <p class='lead'> 264 <%= service.Comment %> 265 </p> 266 <div class='row'> 267 <div class='col col-auto'> 268 <strong>Methods</strong> 269 <ul class='list-unstyled'> 270 <%= for (method) in service.Methods { %> 271 <li> 272 <a href='#<%= def.PackageName %>_<%= service.Name %>_<%= method.Name %>'><%= method.Name %></a> 273 </li> 274 <% } %> 275 </ul> 276 </div> 277 <div class='col col-auto'> 278 <strong>Objects</strong> 279 <ul class='list-unstyled'> 280 <%= for (structure) in service.Structures { %> 281 <%= if (!structure.IsRequestObject && !structure.IsResponseObject) { %> 282 <li> 283 <a href='#<%= def.PackageName %>_<%= structure.Name %>'><%= structure.Name %></a> 284 </li> 285 <% } %> 286 <% } %> 287 <li> 288 <a href='#Objects'>All objects</a> 289 </li> 290 </ul> 291 </div> 292 <div class='col col-auto'> 293 <strong>More</strong> 294 <ul class='list-unstyled'> 295 <li> 296 <a href='#<%= def.PackageName %>_Special_types'>Special types</a> 297 </li> 298 <li> </li> 299 <li> 300 <a href='#<%= def.PackageName %>_Definition'>Definition</a> 301 </li> 302 </ul> 303 </div> 304 </div> 305 <hr> 306 <%= for (method) in service.Methods { %> 307 <section class='page highlightable' id='<%= def.PackageName %>_<%= service.Name %>_<%= method.Name %>'> 308 <%= contentOf("heading", {"text": method.Name, "id": def.PackageName+"_"+service.Name+"_"+method.Name, "tag": "h4", "type": "Method"}) %> 309 <p> 310 <%= method.Comment %> 311 </p> 312 <div class='row'> 313 <div class='col'> 314 <p> 315 <%= contentOf("structure-link", {"name":method.RequestStructure.Name}) %> 316 </p> 317 <%= contentOf("describe-fields", {"fields": method.RequestStructure.Fields}) %> 318 </div> 319 <div class='col'> 320 <p> 321 <%= contentOf("structure-link", {"name":method.ResponseStructure.Name}) %> 322 </p> 323 <%= if (method.ResponseStructure.Name == "remototypes.FileResponse") { %> 324 <ul> 325 <li>File</li> 326 </ul> 327 <% } else { %> 328 <%= contentOf("describe-fields", {"fields": method.ResponseStructure.Fields}) %> 329 <% } %> 330 </div> 331 </div> 332 </section> 333 <hr> 334 <% } %> 335 </section> 336 <% } %> 337 <h3 id='Objects' class='display-5'>Objects</h3> 338 <p class='lead'> 339 This section describes all the objects (structures) that are used in the <strong><%= def.PackageName %></strong> service. 340 </p> 341 <ul class='list-unstyled'> 342 <%= for (structure) in unique_structures(def) { %> 343 <li> 344 <a href='#<%= def.PackageName %>_<%= structure.Name %>'><%= structure.Name %></a> 345 </li> 346 <% } %> 347 </ul> 348 <%= for (structure) in unique_structures(def) { %> 349 <section class='page highlightable' id='<%= def.PackageName %>_<%= structure.Name %>'> 350 <%= contentOf("describe-structure", {"structure": structure, "id": def.PackageName+"_"+structure.Name}) %> 351 </section> 352 <hr> 353 <% } %> 354 <h2 id='<%= def.PackageName %>_Special_types' class='display-5'>Special types</h2> 355 <p class='lead'> 356 This section describes specially handled types for situations 357 more complex than simple key/value. 358 </p> 359 <section class='page highlightable' id='<%= def.PackageName %>_remototypes_FileResponse'> 360 <%= contentOf("heading", {"text": "remototypes.FileResponse", "id": def.PackageName+"_remototypes_FileResponse", "tag": "h4", "type": "Object"}) %> 361 <p> 362 <code>remototypes.FileResponse</code> is used by methods that return a single 363 file as its result. 364 </p> 365 <p> 366 Client libraries will provide a way to access the returned file. 367 </p> 368 </section> 369 <section class='page highlightable' id='<%= def.PackageName %>_remototypes_File'> 370 <%= contentOf("heading", {"text": "remototypes.File", "id": def.PackageName+"_remototypes_File", "tag": "h4", "type": "Object"}) %> 371 <p> 372 <code>remototypes.File</code> represents a binary file. Client libraries will each have their 373 own special way of submitting the files. 374 </p> 375 </section> 376 <h2 id='<%= def.PackageName %>_Definition' class='display-5'>Definition</h2> 377 <p class='lead'> 378 Here is the <a href='https://github.com/machinebox/remoto'>Remoto</a> definition for this service, which is also available to <a href='#' data-action='download-source'>download</a>. 379 </p> 380 <pre class='source code'><code><%= def.Source() %></code></pre> 381 </div> 382 <% } %> 383 <% contentFor("describe-field") { %> 384 <code><%= underscore(field.Name) %></code> 385 <%= if (field.Type.IsMultiple) { %> 386 Array of 387 <% } %> 388 <%= if (field.Type.IsStruct) { %> 389 <%= contentOf("structure-link", {"name":field.Type.Name}) %> 390 <% } else { %> 391 <%= field.Type.Name %> 392 <% } %> 393 <%= if (field.Comment != "") { %><span class='text-muted'>—<%= field.Comment %></span><% } %> 394 <% } %> 395 <% contentFor("describe-structure") { %> 396 <%= contentOf("heading", {"text": structure.Name, "id": id, "tag": "h4", "type": "Object"}) %> 397 <p><%= structure.Comment %></p> 398 <%= contentOf("describe-fields", {"fields": structure.Fields}) %> 399 <% } %> 400 <% contentFor("describe-fields") { %> 401 <ul> 402 <%= if (len(fields) == 0) { %> 403 <li class='text-muted'> 404 No fields —An empty object. 405 </li> 406 <% } else { %> 407 <%= for (field) in fields { %> 408 <li> 409 <%= contentOf("describe-field", {"field": field}) %> 410 </li> 411 <% } %> 412 <% } %> 413 </ul> 414 <% } %> 415 <% contentFor("structure-link") { %><a href='#<%= def.PackageName %>_<%= replace(name, ".", "_") %>'><%= name %></a><% } %> 416 <% contentFor("heading") { %><<%= tag %> class='heading anchor-container'><%= text %> <span class='text-muted'><%= type %></span> <a href='#<%= id %>' class='anchor'>#</a><a href='#top' class='float-right anchor'>top</a></<%= tag %>><% } %>