]> git.ktnx.net Git - lsl.git/commitdiff
first ugly attempts at the web app
authorDamyan Ivanov <dmn@debian.org>
Thu, 10 Feb 2022 20:50:45 +0000 (20:50 +0000)
committerDamyan Ivanov <dmn@debian.org>
Thu, 10 Feb 2022 20:50:45 +0000 (20:50 +0000)
public/css/jquery-ui [new symlink]
public/css/style.css
public/javascripts/jquery-ui.min.js [new symlink]
public/javascripts/lsl.js [new file with mode: 0644]
views/index.tt
views/layouts/main.tt

diff --git a/public/css/jquery-ui b/public/css/jquery-ui
new file mode 120000 (symlink)
index 0000000..450af20
--- /dev/null
@@ -0,0 +1 @@
+/usr/share/javascript/jquery-ui/css
\ No newline at end of file
index 80f94ebef34ae7d7469ebb32f8007a982ad9946c..80f143517cdcec139021d4754db533654ae2240c 100644 (file)
@@ -4,17 +4,17 @@ margin: 0;
 margin-bottom: 25px;
 padding: 0;
 background-color: #ddd;
-background-image: url("/images/perldancer-bg.jpg");
-background-repeat: no-repeat;
-background-position: top left;
-
-font-family: "Lucida Grande", "Bitstream Vera Sans", "Verdana";
-font-size: 13px;
+font-family: "Bitstream Vera Sans", sans-serif;
+font-size: 12pt;
 color: #333;
 }
 
+input {
+    font-size: 12pt;
+}
+
 h1 {
-font-size: 28px;
+font-size: 200%;
 color: #000;
 }
 
@@ -47,106 +47,25 @@ float: right;
 width: 175px;
 }
 
-#header, #about, #getting-started {
+#about, #getting-started {
 padding-left: 75px;
 padding-right: 30px;
 }
 
 
-#header {
-background-image: url("/images/perldancer.jpg");
-background-repeat: no-repeat;
-background-position: top left;
-height: 64px;
-}
 #header h1, #header h2 {margin: 0}
+#header { font-weight: bold; }
 #header h2 {
 color: #888;
 font-weight: normal;
-font-size: 16px;
+font-size: 133%;
 }
 
 #about h3 {
 margin: 0;
 margin-bottom: 10px;
-font-size: 14px;
-}
-
-#about-content {
-background-color: #ffd;
-border: 1px solid #fc0;
-margin-left: -11px;
-}
-#about-content table {
-margin-top: 10px;
-margin-bottom: 10px;
-font-size: 11px;
-border-collapse: collapse;
-}
-#about-content td {
-padding: 10px;
-padding-top: 3px;
-padding-bottom: 3px;
-}
-#about-content td.name  {color: #555}
-#about-content td.value {color: #000}
-
-#about-content.failure {
-background-color: #fcc;
-border: 1px solid #f00;
-}
-#about-content.failure p {
-margin: 0;
-padding: 10px;
-}
-
-#getting-started {
-border-top: 1px solid #ccc;
-margin-top: 25px;
-padding-top: 15px;
-}
-#getting-started h1 {
-margin: 0;
-font-size: 20px;
-}
-#getting-started h2 {
-margin: 0;
-font-size: 14px;
-font-weight: normal;
-color: #333;
-margin-bottom: 25px;
-}
-#getting-started ol {
-margin-left: 0;
-padding-left: 0;
-}
-#getting-started li {
-font-size: 18px;
-color: #888;
-margin-bottom: 25px;
-}
-#getting-started li h2 {
-margin: 0;
-font-weight: normal;
-font-size: 18px;
-color: #333;
-}
-#getting-started li p {
-color: #555;
-font-size: 13px;
-}
-
-#search {
-margin: 0;
-padding-top: 10px;
-padding-bottom: 10px;
-font-size: 11px;
+font-size: 120%;
 }
-#search input {
-font-size: 11px;
-margin: 2px;
-}
-#search-text {width: 170px}
 
 #sidebar ul {
 margin-left: 0;
@@ -187,3 +106,54 @@ padding-right: 160px;
 font-family: sans-serif;
 font-size: 10px;
 }
+
+#lists-sidebar-item, .have-lists #no-lists-sidebar-item {
+    display: none;
+}
+.have-lists #lists-sidebar-item { display: block; }
+.table-2-col {
+  display: grid;
+  grid-template-columns: auto auto;
+  column-gap: 1em;
+}
+.table-2-col > .arrow {
+  align-self: center;
+}
+#list-contents { display: none; }
+.have-list #list-contents {
+    display: block;
+}
+#new-list-sidebar-item > div {
+    display: grid;
+    grid-template-columns: auto auto;
+    column-gap: 1ex;
+}
+
+#busy-screen {
+    display: none;
+    opacity: 0;
+    transition: 1s;
+    width: 100%;
+    height: 100%;
+    position: fixed;
+    top: 0;
+    left: 0;
+    background: hsla(0, 0%, 50%, 50%);
+    z-index: 800;
+}
+.blocked #busy-screen {
+    display: block;
+}
+.busy #busy-screen {
+    opacity: 1;
+}
+#busy-screen > div {
+    position: fixed;
+    top: 1ex;
+    right: 1ex;
+    padding: 1em;
+    display: inline-block;
+    background: hsla(0, 0%, 100%, 75%);
+    border-radius: 1ex;
+}
+
diff --git a/public/javascripts/jquery-ui.min.js b/public/javascripts/jquery-ui.min.js
new file mode 120000 (symlink)
index 0000000..5c053ba
--- /dev/null
@@ -0,0 +1 @@
+/usr/share/javascript/jquery-ui/jquery-ui.min.js
\ No newline at end of file
diff --git a/public/javascripts/lsl.js b/public/javascripts/lsl.js
new file mode 100644 (file)
index 0000000..8ecf08e
--- /dev/null
@@ -0,0 +1,54 @@
+"use strict";
+(function(){
+var ui_icon_class_re = new RegExp('\\bui-icon-\\S+\\b');
+var uri_base;
+var lists_version;
+var lists = [];
+var current_list;
+
+function load_lists() {
+    console.log('TODO');
+}
+function handle_new_list_submission(){
+    $.post(uri_base + '/api/v1/list',
+        JSON.stringify({name:$('input[name="list_name"]').val()}))
+    .done(load_lists);
+    return false;
+}
+$(function(){
+    uri_base = $('#page').attr('lsl-uri-base');
+    $(document).ajaxStart(function(){
+        $(document).addClass('blocked');
+        window.setTimeout(
+            function() {
+                $(document).addClass('busy');
+            }
+        );
+    });
+    $(document).ajaxStop(function(){
+        $(document).removeClass('busy');
+        window.setTimeout(
+            function() {
+                $(document).removeClass('blocked');
+            },
+            1000 );
+    });
+    $.ajaxSetup({contentType: 'application/json'});
+    $('button, input[type="submit"], input[type="reset"]').each(function(){
+        var class_prop = $(this).prop('class');
+        var icon_classes = class_prop.match(ui_icon_class_re);
+        $(this).button({icon: icon_classes?icon_classes[0]:null});
+    });
+
+    $('#new-list-sidebar-item button').on('click', handle_new_list_submission);
+    $('#new-list-sidebar-item input').on('keypress', function(ev) {
+        if (13 == ev.keyCode) {
+            handle_new_list_submission();
+            return false;
+        }
+
+        return true;
+    });
+    load_lists();
+});
+})();
index 7b8eb8e0df6b20de433e1a18d0a66e2f81dee877..6f32f0c189b70a91defbb1aa24cbf7cc346f2465 100644 (file)
-
-<!--
-    Credit goes to the Ruby on Rails team for this page
-    has been heavily based on the default Rails page that is
-    built with a scaffolded application.
-
-    Thanks a lot to them for their work.
-
-    See Ruby on Rails if you want a kickass framework in Ruby:
-    http://www.rubyonrails.org/
--->
-
-<div id="page">
-      <div id="sidebar">
-        <ul id="sidebar-items">
-          <li>
-            <h3>Join the community</h3>
-            <ul class="links">
-
-              <li><a href="https://perldancer.org/">PerlDancer Website</a></li>
-              <li><a href="https://twitter.com/PerlDancer/">Official Twitter</a></li>
-              <li><a href="https://github.com/PerlDancer/Dancer2/">GitHub Community</a></li>
-              <li><a href="https://lists.perldancer.org/mailman/listinfo/dancer-users">Mailing List</a></li>
-              <li><a href="irc://irc.perl.org/dancer">IRC</a></li>
-            </ul>
-          </li>
-
-          <li>
-            <h3>Browse the documentation</h3>
-
-            <ul class="links">
-              <li><a
-              href="https://metacpan.org/pod/Dancer2::Manual">Introduction</a></li>
-              <li><a href="https://metacpan.org/pod/Dancer2::Cookbook">Cookbook</a></li>
-              <li><a
-              href="https://metacpan.org/pod/Dancer2::Tutorial"
-              title="a tutorial to build a small blog engine with Dancer">Tutorial</a></li>
-              <li><a href="https://metacpan.org/pod/Dancer2::Manual::Deployment">Deployment</a></li>
-            </ul>
-          </li>
-
-          <li>
-            <h3>Your application's environment</h3>
-
-            <ul>
-                <li>Location: <span class="filepath">/btrfs/home/dam/w/lsl/tmp/App::REST::LazyShoppingList</span></li>
-                <li>Template engine: <span class="app-info"><% settings.template %></span></li>
-                <li>Logger: <span class="app-info"><% settings.logger %></span></li>
-                <li>Environment: <span class="app-info"><% settings.environment %></span></li>
-            </ul>
-
-          </li>
+<div id="page" class="loading-lists" lsl-uri-base="<% request.uri_base %>">
+  <div id="sidebar">
+    <ul id="sidebar-items">
+      <li id="lists-sidebar-item">
+        <h3>Shopping lists</h3>
+        <ul class="lists">
         </ul>
+      </li>
 
-      </div>
+      <li id="no-lists-sidebar-item">
+        <h3>No shopping lists</h3>
+      </li>
 
-      <div id="content">
-        <div id="header">
-          <h1>Perl is dancing</h1>
-          <h2>You&rsquo;ve joined the dance floor!</h2>
+      <li id="new-list-sidebar-item">
+        <h3>New shopping list</h3>
+        <div>
+          <input name="list_name" size="20" maxlength="60" />
+          <button class="ui-icon-plusthick"></button>
         </div>
+      </li>
+    </ul>
+  </div>
+
+  <div id="content">
+    <div id="header">
+      <h1 id="selected-list-name" class="have-lists"></h1>
+      <div class="have-no-lists">
+        <div class="table-2-col">
+          <h1>First create a shopping list</h1><div class="arrow">→</div>
+        </div>
+      </div>
+    </div>
 
-        <div id="getting-started">
-          <h1>Getting started</h1>
-          <h2>Here&rsquo;s how to get dancing:</h2>
-
-          <h3><a href="#" id="about_env_link">About your application's environment</a></h3>
-
-          <div id="about-content" style="display: none;">
-            <table>
-                <tbody>
-                <tr>
-                    <td>Perl version</td>
-                    <td><span class="app-info"><% perl_version %></span></td>
-                </tr>
-                <tr>
-                    <td>Dancer2 version</td>
-                    <td><span class="app-info"><% dancer_version %></span></td>
-                </tr>
-                <tr>
-                    <td>Backend</td>
-                    <td><span class="app-info"><% settings.apphandler %></span></td>
-                </tr>
-                <tr>
-                    <td>Appdir</td>
-                    <td><span class="filepath">/btrfs/home/dam/w/lsl/tmp/App::REST::LazyShoppingList</span></td>
-                </tr>
-                <tr>
-                    <td>Template engine</td>
-                    <td><span class="app-info"><% settings.template %></span></td>
-                </tr>
-                <tr>
-                    <td>Logger engine</td>
-                    <td><span class="app-info"><% settings.logger %></span></td>
-                </tr>
-                <tr>
-                    <td>Running environment</td>
-                    <td><span class="app-info"><% settings.environment %></span></td>
-                </tr>
-                </tbody>
-            </table>
-          </div>
-
-    <script type="text/javascript">
-    $('#about_env_link').click(function() {
-        $('#about-content').slideToggle('fast', function() {
-            // ok
-        });
-        return false;
-    });
-    </script>
-
-
-          <ol>
-            <li>
-              <h2>Tune your application</h2>
-
-              <p>
-              Your application is configured via a global configuration file,
-              <span class="filepath">config.yml</span> and an "environment" configuration file,
-              <span class="filepath">environments/development.yml</span>. Edit those files if you
-              want to change the settings of your application.
-              </p>
-            </li>
-
-            <li>
-              <h2>Add your own routes</h2>
-
-              <p>
-              The default route that displays this page can be removed,
-              it's just here to help you get started. The template used to
-              generate this content is located in
-              <span class="filepath">views/index.tt</span>.
-              You can add some routes to <span class="filepath">lib/App/REST/LazyShoppingList.pm lib/App/REST/LazyShoppingList.pm</span>.
-              </p>
-            </li>
-
-            <li>
-              <h2>Enjoy web development again</h2>
-
-              <p>
-              Once you've made your changes, restart your standalone server
-              <span class="filepath">(bin/app.psgi)</span> and you're ready
-              to test your web application.
-              </p>
-            </li>
 
-          </ol>
-        </div>
+    <div id="list-contents" class="have-lists">
+      <ul id="list-items" class="have-list-items">
+      </ul>
+      <div id="new-list-item">
+        <input type="text" size="15" maxlength="80" name="new_list_item" />
+        <button id="add-list-item" class="ui-icon-plusthick">Add</button>
       </div>
     </div>
+  </div>
+</div>
+<!-- vim: set ft=html sw=2 :-->
index 0f3de6f24b61cf18b72486e2ea71fce151365802..74c055f75289e0a7c1634f8aff90f72f4e2dbdf1 100644 (file)
@@ -4,17 +4,15 @@
   <meta charset="<% settings.charset %>">
   <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
   <title><% title %></title>
+  <link rel="stylesheet" href="<% request.uri_base %>/css/jquery-ui/smoothness/jquery-ui.min.css">
   <link rel="stylesheet" href="<% request.uri_base %>/css/style.css">
 
-<!-- Grab jQuery from a CDN, fall back to local if necessary -->
-<script src="https://code.jquery.com/jquery-3.5.1.min.js" crossorigin="anonymous"
-    integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="></script>
-<script type="text/javascript">/* <![CDATA[ */
-    !window.jQuery && document.write('<script type="text/javascript" src="<% request.uri_base %>/javascripts/jquery.js"><\/script>')
-/* ]]> */</script>
-
+  <script type="text/javascript" src="<% request.uri_base %>/javascripts/jquery.js"></script>
+  <script type="text/javascript" src="<% request.uri_base %>/javascripts/jquery-ui.min.js"></script>
+  <script type="text/javascript" src="<% request.uri_base %>/javascripts/lsl.js"></script>
 </head>
 <body>
+    <div id="busy-screen"><div><span>Working…</span></div></div>
 <% content %>
 <div id="footer">
 Powered by <a href="http://perldancer.org/">Dancer2</a> <% dancer_version %>