about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-08-08 11:15:22 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-08-08 11:15:22 -0700
commit7784855c18d55026dd841454dd89db03370680e1 (patch)
treee3b91fb1088a53c49ee57fc59ac57df51a91068e
parentb67270e171f1adaa7940ed0249eef4f4c5813ae5 (diff)
downloadmu-7784855c18d55026dd841454dd89db03370680e1.tar.gz
.
-rw-r--r--browse_slack/README.md16
-rw-r--r--browse_slack/convert_slack.py (renamed from convert_slack.py)13
-rw-r--r--browse_slack/main.mu4
3 files changed, 28 insertions, 5 deletions
diff --git a/browse_slack/README.md b/browse_slack/README.md
new file mode 100644
index 00000000..ba0df896
--- /dev/null
+++ b/browse_slack/README.md
@@ -0,0 +1,16 @@
+To try it out:
+
+1. Import a Slack archive into the data disk by following the instructions at
+   the top of `browse_slack/convert_slack.py`.
+
+2. Build the code disk.
+
+```
+./translate browse_slack/*.mu
+```
+
+3. Run the code and data disks:
+
+```
+qemu-system-i386 -m 2G -hda code.img -hdb path/to/data.img
+```
diff --git a/convert_slack.py b/browse_slack/convert_slack.py
index 882cc71b..1b7b39cc 100644
--- a/convert_slack.py
+++ b/browse_slack/convert_slack.py
@@ -2,7 +2,11 @@
 #
 # Dependencies: python, netpbm
 #
-# Images downloaded as follows:
+# Step 1: download a Slack archive
+#
+# Step 2: download user avatars to subdirectory images/ and convert them to PPM in subdirectory images/ppm/
+#   mkdir images
+#   cd images
 #   grep image_72 . -r |grep -v users.json |awk '{print $3}' |sort |uniq |sed 's/?.*//' |sed 's,\\,,g' |sed 's/"//' |sed 's/",$//' > images.list
 #   wget -i images.list --wait=0.1
 #   # fix some lying images
@@ -12,9 +16,10 @@
 #   for f in *.jpg; do jpegtopnm $f |pnmtopnm -plain > ppm/$(echo $f |sed 's/\.jpg$//').ppm; done
 #   for f in *.png; do png2pnm -n $f > ppm/$(echo $f |sed 's/\.png$//').ppm; done
 #
-# To construct the disk image:
+# Step 3: construct a disk image out of the archives and avatars
+#   cd ../..  # go back to parent of images/
 #   dd if=/dev/zero of=data.img count=201600  # 100MB
-#   python convert_slack.py |dd of=data.img conv=notrunc
+#   python path/to/convert_slack.py |dd of=data.img conv=notrunc
 # Currently this process yields errors for ~70 items on the Future of Software
 # group. We fail to load those.
 #
@@ -65,7 +70,7 @@ def filenames(dir):
 
 def look_up_ppm_image(url):
     file_root = splitext(basename(urlparse(url).path))[0]
-    filename = f"images2/ppm/{file_root}.ppm"
+    filename = f"images/ppm/{file_root}.ppm"
     if isfile(filename):
         with open(filename) as f:
             return f.read()
diff --git a/browse_slack/main.mu b/browse_slack/main.mu
index e3c5affd..6948665f 100644
--- a/browse_slack/main.mu
+++ b/browse_slack/main.mu
@@ -79,5 +79,7 @@ fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk)
   }
 }
 
-fn parse s: (addr stream byte), users: (addr array user), channels: (addr array channel), items: (addr array item) {
+fn parse in: (addr stream byte), users: (addr array user), channels: (addr array channel), items: (addr array item) {
+  var line-storage: (stream byte 0x18000)
+  var line/ecx: (addr stream byte) <- address line-storage
 }