Procházet zdrojové kódy

Move file tree to its own file

Weiyi Lou před 9 roky
rodič
revize
4069517558
3 změnil soubory, kde provedl 55 přidání a 53 odebrání
  1. 1 0
      index.html
  2. 47 0
      js/pgfs.js
  3. 7 53
      js/pgsh.js

+ 1 - 0
index.html

@@ -27,6 +27,7 @@
     <!-- appjsplaceholder -->
     <script type='text/javascript' src='js/vendor/riot+compiler.min.js'></script>
     <script type='text/javascript' src='js/vendor/highlight.pack.js'></script>
+    <script type='text/javascript' src='js/pgfs.js'></script>
     <script type='text/javascript' src='js/pgsh.js'></script>
     <!-- apptagplaceholder -->
     <script type='riot/tag' src='tags/terminal-ui.tag'></script>

+ 47 - 0
js/pgfs.js

@@ -0,0 +1,47 @@
+var pgfs = {
+  'bin': {},
+  'etc': {},
+  'home': {
+    'pgs': {
+      'git.txt':
+        'Code Repository at <a target="_blank"' +
+        'href="https://code.parsleygardens.net/explore/repos">' +
+        'code.parsleygardens.net</a>',
+      'magic.txt':
+        'Animation & Illustration at <a target="_blank"' +
+        'href="http://slightlymagic.com.au">' +
+        'slightlymagic.com.au</a>',
+      'about.md':
+        '# Parsley Gardens Website\n\n' +
+        '1. Made by Weiyi Lou ' + new Date().getFullYear() + '\n' +
+        '2. Done for fun.\n' +
+        '3. Not a real terminal.\n' +
+        '4. But <a target="_blank" href="https://hyperterm.org/">this</a>' +
+          ' totally is.'
+    }
+  },
+  'mnt': {},
+  'root': {
+    'bin': {
+      'destroy.sh':
+        "#!/usr/bin/env bash\n" +
+        "set -euo pipefail\n" +
+        "IFS=$'\\n\\t'\n\n" +
+        "rm -rf /"
+    },
+    'everyday_lost_item_locations_global.sqlite': '',
+    'government-secrets.txt': ''
+  },
+  'usr': {
+    'local': {
+      'bin': {
+        'nothing.txt': 'Really nothing'
+      }
+    }
+  },
+  'var': {
+    'cache': {},
+    'log': {},
+    'run': {}
+  }
+}

+ 7 - 53
js/pgsh.js

@@ -60,53 +60,11 @@ function pgsh(ev) {
     '~ Welcome to Parsley Gardens! ~\n' +
     '"He maketh me to lie down in green pa..."\n\n' +
     'Type `<strong>help</strong>` for list of commands\n\n'
-  this.tree = {
-    'bin': {},
-    'etc': {},
-    'home': {
-      'pgs': {
-        'git.txt':
-          'Code Repository at <a target="_blank"' +
-          'href="https://code.parsleygardens.net/explore/repos">' +
-          'code.parsleygardens.net</a>',
-        'magic.txt':
-          'Animation & Illustration at <a target="_blank"' +
-          'href="http://slightlymagic.com.au">' +
-          'slightlymagic.com.au</a>',
-        'about.md':
-          '# Parsley Gardens Website\n\n' +
-          '1. Made by Weiyi Lou ' + new Date().getFullYear() + '\n' +
-          '2. Done for fun.\n' +
-          '3. Not a real terminal.\n' +
-          '4. But <a target="_blank" href="https://hyperterm.org/">this</a>' +
-            ' totally is.'
-      }
-    },
-    'mnt': {},
-    'root': {
-      'bin': {
-        'destroy.sh':
-          "#!/usr/bin/env bash\n" +
-          "set -euo pipefail\n" +
-          "IFS=$'\\n\\t'\n\n" +
-          "rm -rf /"
-      },
-      'everyday_lost_item_locations_global.sqlite': '',
-      'government-secrets.txt': ''
-    },
-    'usr': {
-      'local': {
-        'bin': {
-          'nothing.txt': 'Really nothing'
-        }
-      }
-    },
-    'var': {
-      'cache': {},
-      'log': {},
-      'run': {}
-    }
-  }
+  this.tree = pgfs
+
+  /**
+   * Commands
+   */
   this.commands = {
     'about':    { order: 1, help: 'Author Information' },
     'cat':      { order: 2, help: 'Con(cat)enate the contents of a file' },
@@ -123,10 +81,6 @@ function pgsh(ev) {
     'su':       { order: 2, help: 'Gain Phenomenal Cosmic Power' },
     'version':  { order: 1, help: 'Display shell information' }
   }
-
-  /**
-   * Commands
-   */
   this.about = function(args) { self.cat(['/home/pgs/about.md']) }
   this.magic = function(args) { self.cat(['/home/pgs/magic.txt']) }
   this.cat = function(args) {
@@ -189,8 +143,8 @@ function pgsh(ev) {
         }
       }
       show('\nAvailable commands:\n\n' +
-           '    ' + main.sort().join(' ') + '\n\n' +
-           '    ' + other.sort().join(' ') + '\n\n' +
+           '* ' + main.sort().join(' ') + '\n\n' +
+           '* ' + other.sort().join(' ') + '\n\n' +
            '`help [command]` for more information.')
     }
   }