From 8fe95c88b65122f3ee691d23dd7ed6677a566677 Mon Sep 17 00:00:00 2001
From: peteyboy
Date: Wed, 16 Feb 2022 08:35:53 +0000
Subject: [PATCH] -Added regexs for High Contrast
-Fixed regext for black & white text squares (so it actually works out of Discord, _ not -)
-Updated html template, fixing textareas so 2nd one didn't get squished for unknown reason.
-Updated text in Template, still too wordy!
-Fixed RLE to end on ! instead of $ which is why the next item wasn't working
-Added a [[..]] section to end of generated RLE file to set generations per second, zoom, and colors to
custom values to generally be better defaults.
---
wordle-life.cgi | 65 +++++++++++++++++++++++++++++++++++++------------
1 file changed, 49 insertions(+), 16 deletions(-)
diff --git a/wordle-life.cgi b/wordle-life.cgi
index 43d280d..8fa0b82 100755
--- a/wordle-life.cgi
+++ b/wordle-life.cgi
@@ -1,7 +1,9 @@
#!/usr/pkg/bin/perl
+#Above is the particular location for system binaries in SDF's metaarray, not the usual spot
use strict;
use warnings;
use utf8;
+#add my user perl library path, this is particular to each person's setup
use lib qw( /usr/pkg/lib/perl5/5.24.0 /meta/p/peteyboy/perl5/lib/perl5 );
#make request for all of the following
use CGI::Tiny;
@@ -15,7 +17,7 @@ use Readonly;
#
#===
my $ORIGIN_PAGE = "/wordle-life.cgi";
- my $defaulttext = "Paste your wordle share here";
+ my $defaulttext = "Paste your wordle share here (replace this text)";
cgi {
@@ -88,7 +90,8 @@ sub generate_rle {
Readonly my $headline_prefix => "#C "; #Part of RLE spec https://conwaylife.com/wiki/Run_Length_Encoded
Readonly my $row_prefix => "x = 5"; #for wordle always 5
Readonly my $col_prefix => ",y = ";
-
+ Readonly my $lifeviewer_settings => "\n[[\n GPS 3\n ZOOM 23\n COLOR ALIVE LIME\n COLOR BACKGROUND BLUE\n STOP 100\n GRID\n]]"; #Part of Viewer Spec
+
my $wordle = shift; # this is how you get variables in your function call!
$rowcount = 0;
@@ -99,16 +102,26 @@ sub generate_rle {
$headline = $headline_prefix . $myline;
}else{
- #in case of text mode
+ #remove all line endings with magic perl identifier R
$myline =~ s/\R//;
$myline =~ s/^(.*)$/$1\$/;
+ #these replaces are logicless, so they need to be done in this order!
+
+ #in case of text mode (Discord)
$myline =~ s/:yellow_square:/o/g;
$myline =~ s/:green_square:/o/g;
- $myline =~ s/:[a-z-]*square:/b/g;
- # for normal unicode
- $myline =~ s/\N{U+1f7e8}/o/g; #yellow
- $myline =~ s/\N{U+1f7e9}/o/g; #green
+ $myline =~ s/:blue_square:/o/g; #HC equiv yellow
+ $myline =~ s/:orange_square:/o/g; #HC equiv green
+
+ $myline =~ s/:[a-z_]*square:/b/g;
+ # for normal unicode
+ $myline =~ s/\N{U+1f7e8}/o/g; #yellow hit
+ $myline =~ s/\N{U+1f7e9}/o/g; #green hit
+ $myline =~ s/\N{U+1F7E6}/o/g; #blue
+ $myline =~ s/\N{U+1F7E7}/o/g; #orange
+
+
$myline =~ s/\N{U+2B1B}/b/g; #black
$myline =~ s/\N{U+2B1C}/b/g; #white
@@ -117,6 +130,9 @@ sub generate_rle {
$myline =~ s/white_large_square/b/g;
$myline =~ s/yellow_square/o/g;
$myline =~ s/green_square/o/g;
+ $myline =~ s/blue_square/o/g;
+ $myline =~ s/orange_square/o/g;
+
#skip blank lines, count rows added
@@ -127,7 +143,8 @@ sub generate_rle {
}
}
#this is the format with b,o, and $. Done lazily because I don't compress the repeated b or o.
- return "$headline\n$row_prefix$col_prefix$rowcount\n$rleline";
+ $rleline =~ s/\$$/\!/; #Correct termination of last line of RLE is !, not $, so replace it.
+ return "$headline\n$row_prefix$col_prefix$rowcount\n$rleline\n$lifeviewer_settings";
}
@@ -140,7 +157,11 @@ __DATA__
-
+
@@ -161,31 +182,32 @@ __DATA__
-
Click "Submit" and and RLE format file for Conway's Game of Life will appear in the box below and get loaded into the Life Viewer.
+
Click "Submit" and an RLE format file made for Conway's Game of Life will appear in the box below and get loaded into the Life Viewer.