github.com/geniusesgroup/libgo@v0.0.0-20220713101832-828057a9d3d4/www/service-make-splash-screen.go (about)

     1  /* For license and copyright information please see LEGAL file in repository */
     2  
     3  package www
     4  
     5  import (
     6  	"bytes"
     7  	"text/template"
     8  
     9  	"../protocol"
    10  )
    11  
    12  // MakeSplashFiles make splash screen that use as landing page or first screen user see when open GUI app.
    13  func MakeSplashFiles(html, css, json protocol.File) (err error) {
    14  	html.Rename("splash.html")
    15  	var htmlBuf = new(bytes.Buffer)
    16  	if err = splashHTMLFileTemplate.Execute(htmlBuf, ""); err != nil {
    17  		return
    18  	}
    19  	html.Data().Unmarshal(htmlBuf.Bytes())
    20  
    21  	css.Rename("splash.css")
    22  	var cssBuf = new(bytes.Buffer)
    23  	if err = splashCSSFileTemplate.Execute(cssBuf, ""); err != nil {
    24  		return
    25  	}
    26  	css.Data().Unmarshal(cssBuf.Bytes())
    27  
    28  	json.Rename("splash.json")
    29  	var jsonBuf = new(bytes.Buffer)
    30  	if err = splashJSONFileTemplate.Execute(jsonBuf, ""); err != nil {
    31  		return
    32  	}
    33  	json.Data().Unmarshal(jsonBuf.Bytes())
    34  	return
    35  }
    36  
    37  var splashHTMLFileTemplate = template.Must(template.New("splashHTMLFile").Parse(`
    38  <!-- For license and copyright information please see LEGAL file in repository -->
    39  
    40  <main>
    41      <div>
    42          <img src="/images/app-icon-128x128.png" alt="Platform logo" />
    43          <p>
    44              POWERED BY <br />
    45              <a href="/cloud">SABZCITY PLATFORM</a>
    46          </p>
    47  
    48          <noscript>Please Enable Javascript to be able to use this web app.</noscript>
    49      </div>
    50  </main>
    51  `))
    52  
    53  var splashCSSFileTemplate = template.Must(template.New("splashCSSFile").Parse(`
    54  /* For license and copyright information please see LEGAL file in repository */
    55  
    56  main {
    57      position: fixed;
    58      width: 100%;
    59      height: 100%;
    60      top: 0;
    61      left: 0;
    62      background: rgba(0, 0, 0, 0.5)
    63  }
    64  
    65  div {
    66      position: absolute;
    67      height: 200px;
    68      max-width: 400px;
    69      top: 0;
    70      bottom: 0;
    71      right: 0;
    72      left: 0;
    73      margin: auto;
    74      text-align: center;
    75      background: #ffffff;
    76      box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.2), 0 4px 5px 0 rgba(0, 0, 0, 0.14), 0 1px 10px 0 rgba(0, 0, 0, 0.12);
    77  }
    78  
    79  /* img {} */
    80  
    81  p {
    82      color: #92989b;
    83      font-family: sans-serif;
    84      font-size: 9pt
    85  }
    86  
    87  a {
    88      color: #616161;
    89      text-decoration: none
    90  }
    91  `))
    92  
    93  var splashJSONFileTemplate = template.Must(template.New("splashJSONFile").Parse(`
    94  {
    95  	"en": []
    96  }
    97  `))