summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--README.org76
-rwxr-xr-xdraco.pl8
2 files changed, 63 insertions, 21 deletions
diff --git a/README.org b/README.org
index 02ee195..62fb4eb 100644
--- a/README.org
+++ b/README.org
@@ -1,21 +1,23 @@
-#+SETUPFILE: ~/.emacs.d/org-templates/projects.org
-#+EXPORT_FILE_NAME: index
-#+OPTIONS: toc:1
-#+TITLE: Draco
+#+title: Draco
+#+setupfile: ~/.emacs.d/org-templates/projects.org
+#+export_file_name: index
 
 Draco is a script to convert reddit thread to Org document. It accepts a
 url & prints the Org document to STDOUT. It'll also print comments along
 with their replies.
 
-| Project Home    | [[https://andinus.nand.sh/draco/][Draco]]           |
-| Source Code     | [[https://git.tilde.institute/andinus/draco/][Andinus / Draco]] |
+| Project Home    | [[https://andinus.nand.sh/projects/draco/][Draco]]           |
+| Source Code     | [[https://git.unfla.me/draco/][Andinus / Draco]] |
 | GitHub (Mirror) | [[https://github.com/andinus/draco/][Draco - GitHub]]  |
 
 * Why?
+
 I reference things from the web in my Journal & don't want those links
 to break so I save them locally. Previously I used to manually archive
 the whole thread, this automates it.
+
 * Demo
+
 This was recorded with =asciinema(1)=.
 
 [[https://asciinema.org/a/373860][https://asciinema.org/a/373860.png]]
@@ -24,13 +26,17 @@ This was recorded with =asciinema(1)=.
 + Draco v0.1.2: https://asciinema.org/a/373860
 + Draco 2020-11-19: https://asciinema.org/a/373851
 + alt-link (download): https://andinus.nand.sh/static/draco/
+
 * Installation
+
 Follow these instructions to get draco & then install the dependencies,
 they're listed below. All dependencies are in Debian & Fedora
 repositories.
 
 Check the /News/ section before updating or downloading latest release.
+
 ** Release
+
 Release archives are generated by cgit/GitHub.
 
 1. Download the release:
@@ -40,10 +46,12 @@ Release archives are generated by cgit/GitHub.
 3. =cd= into the directory.
 4. Run =make install= as root.
 5. Install dependencies.
+
 ** From Source
+
 All commits will be signed by my [[https://andinus.nand.sh/static/D9AE4AEEE1F1B3598E81D9DFB67D55D482A799FD.asc][PGP Key]].
 
-#+BEGIN_SRC sh
+#+begin_src sh
 # Clone the project.
 git clone https://git.tilde.institute/andinus/draco
 cd draco
@@ -52,35 +60,63 @@ cd draco
 doas make install
 
 # Install dependencies. See the section below.
-#+END_SRC
+#+end_src
+
 * Dependencies
+
 ** OpenBSD
-#+BEGIN_SRC sh
-doas pkg_add p5-Unicode-LineBreak p5-JSON-MaybeXS
+
+#+begin_src sh
+doas pkg_add p5-Unicode-LineBreak p5-JSON-MaybeXS p5-IO-Socket-SSL
 cpan install HTTP::Tiny
-#+END_SRC
+#+end_src
+
 ** Debian (apt)
-#+BEGIN_SRC sh
+
+#+begin_src sh
 sudo apt install libunicode-linebreak-perl libjson-maybexs-perl \
-     libhttp-tiny-perl
-#+END_SRC
+     libhttp-tiny-perl libio-socket-ssl-perl
+#+end_src
+
 ** Fedora (dnf)
-#+BEGIN_SRC sh
-sudo dnf install perl-JSON-MaybeXS perl-HTTP-Tiny perl-Unicode-LineBreak
-#+END_SRC
+
+#+begin_src sh
+sudo dnf install perl-JSON-MaybeXS perl-HTTP-Tiny perl-Unicode-LineBreak \
+     perl-IO-Socket-SSL
+#+end_src
+
 * News
+
+** v0.3.3 - 2022-08-09
+
++ Add IO::Socket::SSL dependency.
+  Required for HTTPs support.
+
++ Print response 'contents' on errors.
+  From https://metacpan.org/pod/HTTP::Tiny,
+  #+begin_quote
+  Errors during request execution will result in a pseudo-HTTP status
+  code of 599 and a reason of "Internal Exception". The content field in
+  the response will contain the text of the error.
+  #+end_quote
+
 ** v0.3.2 - 2020-11-26
+
 + Add =author_flair_text= to properties section of each comment.
 + Keep each dot in a single line.
   This feature was added in v0.3.0 but each dot was printed in a new
   line. For huge posts this would be annoying so now dots are printed in
   a single line.
+
 ** v0.3.1 - 2020-11-25
+
 Minor improvement.
 
 + Put author name in code block if it begins & ends with "=_=".
   Org underlines headings that begin & end with "=_=".
+
 ** v0.3.0 - 2020-11-24
+
 This version adds code to fetch all the comments in a thread. Now users
 can archive the whole thread.
 
@@ -92,16 +128,22 @@ for small changes from the git history.
 + Add debug message for HTTP calls.
   It'll print a "." for every HTTP call. Users will be able to tell when
   the script is making HTTP calls.
+
 ** v0.2.2 - 2020-11-24
+
 This version is mostly structural changes, it'll now be easier to add
 code to fetch comments hidden behind "continue this thread".
 
 + Add more debug information.
+
 ** v0.2.1 - 2020-11-24
+
 + Previously fetching comments hidden under "load more comments" would
   fail if the url passed by user ends in "/". This has been fixed in
   this release.
+
 ** v0.2.0 - 2020-11-23
+
 This version makes the script lot more complex. If you download only
 small threads then this update is not required.
 
diff --git a/draco.pl b/draco.pl
index 37017f0..2107eaf 100755
--- a/draco.pl
+++ b/draco.pl
@@ -17,7 +17,7 @@ binmode(STDOUT, "encoding(UTF-8)");
 die "usage: draco [-dhv] <url>\n" unless scalar @ARGV;
 
 my $DEBUG;
-my $VERSION = "v0.3.2";
+my $VERSION = "v0.3.3";
 # Dispatch table to be parsed before url.
 my %dispatch = (
     '-v'  => sub { print "Draco $VERSION\n"; exit; },
@@ -152,7 +152,7 @@ sub get_response {
     print STDERR "." if $DEBUG and scalar @http_calls > 0;
     my $response = $http->get($url);
     push @http_calls, $url;
-    die "Unexpected response - $response->{status}: $response->{reason} : $url"
+    die "\nUnexpected response - $response->{status}: $response->{reason}\n$response->{content} : $url"
         unless $response->{success};
     return $response;
 }
@@ -372,11 +372,11 @@ sub print_comment_chain {
     }
     print ":END:\n";
 
-    print "\n#+BEGIN_SRC markdown\n",
+    print "\n#+begin_src markdown\n",
         # Break the text at 76 column & add 2 space before every new
         # line.
         "  ", $lb->break($comment_data->{body}) =~ s/\n/\n\ \ /gr, "\n",
-        "#+END_SRC\n";
+        "#+end_src\n\n";
 
     # If the comment has replies then iterate over those too.
     if (scalar $comment_data->{replies}) {