From de223c1efa58bf7be1953db3150ef3437073e4d9 Mon Sep 17 00:00:00 2001 From: Tyler Hallada Date: Fri, 24 Apr 2015 15:03:18 -0400 Subject: [PATCH 1/3] Update w3m-reddit post about new m.reddit.com --- _posts/2013-06-04-w3m-reddit.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/_posts/2013-06-04-w3m-reddit.md b/_posts/2013-06-04-w3m-reddit.md index 2213400..311fc5e 100644 --- a/_posts/2013-06-04-w3m-reddit.md +++ b/_posts/2013-06-04-w3m-reddit.md @@ -45,8 +45,8 @@ done args+=("$@") for arg in "${args[@]}" ; do # Switch to mobile reddit - url=${arg/http:\/\/reddit.com/http:\/\/m.reddit.com} - url=${url/http:\/\/www.reddit.com/http:\/\/m.reddit.com} + url=${arg/http:\/\/reddit.com/https:\/\/m.reddit.com} + url=${url/http:\/\/www.reddit.com/https:\/\/m.reddit.com} # Fix double backslash error in comment uri for mobile reddit url=${url/\/\/comments/\/comments} if [[ $t == "1" ]]; then @@ -93,3 +93,9 @@ scrapping the whole thing and starting over in Python instead. Stay tuned for more posts on how I view images and videos efficiently from the command-line. + +EDIT 04/25/2015: Reddit seems to have gotten rid of their old mobile reddit site +and replaced it with a more modern version that unfortunately doesn't look as +good in w3m. It still gets rid of a lot of header junk that is present in the +desktop version, though. It also doesn't work over http, so I edited the script +to always switch to https. From fd63ee7c695ae95c4ed2212e9bb249d81b499cd9 Mon Sep 17 00:00:00 2001 From: Tyler Hallada Date: Fri, 24 Apr 2015 16:11:50 -0400 Subject: [PATCH 2/3] Re-edit w3m-reddit script with .mobile fix --- _posts/2013-06-04-w3m-reddit.md | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/_posts/2013-06-04-w3m-reddit.md b/_posts/2013-06-04-w3m-reddit.md index 311fc5e..ac9f791 100644 --- a/_posts/2013-06-04-w3m-reddit.md +++ b/_posts/2013-06-04-w3m-reddit.md @@ -45,8 +45,17 @@ done args+=("$@") for arg in "${args[@]}" ; do # Switch to mobile reddit - url=${arg/http:\/\/reddit.com/https:\/\/m.reddit.com} - url=${url/http:\/\/www.reddit.com/https:\/\/m.reddit.com} + url=$arg + mobile='.mobile' + if [[ $url =~ http:\/\/www.reddit.com || $url =~ http:\/\/reddit.com ]] + then + if [[ $url =~ \/$ ]] + then + url=$url$mobile + else + url=$url'/'$mobile + fi + fi # Fix double backslash error in comment uri for mobile reddit url=${url/\/\/comments/\/comments} if [[ $t == "1" ]]; then @@ -96,6 +105,6 @@ command-line. EDIT 04/25/2015: Reddit seems to have gotten rid of their old mobile reddit site and replaced it with a more modern version that unfortunately doesn't look as -good in w3m. It still gets rid of a lot of header junk that is present in the -desktop version, though. It also doesn't work over http, so I edited the script -to always switch to https. +good in w3m. However, the old mobile site is still accessable by adding a +".mobile" to the end of urls. The script above has been edited to reflect this +change. From 495db4a81c548457cee848bfee651246ef140cdc Mon Sep 17 00:00:00 2001 From: Tyler Hallada Date: Fri, 24 Apr 2015 16:24:54 -0400 Subject: [PATCH 3/3] Change references of m.reddit.com to .mobile --- _posts/2013-06-04-w3m-reddit.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/_posts/2013-06-04-w3m-reddit.md b/_posts/2013-06-04-w3m-reddit.md index ac9f791..c21aab3 100644 --- a/_posts/2013-06-04-w3m-reddit.md +++ b/_posts/2013-06-04-w3m-reddit.md @@ -17,17 +17,17 @@ reddit. However, I kind of got tired of viewing reddit through w3m, the header alone is a few pages long to scroll through, and the CSS for the comments doesn't load so there isn't any sense of threading. But, then I discovered reddit's mobile -website: [http://m.reddit.com](http://m.reddit.com), and it looks absolutely +website: [http://reddit.com/.mobile](http://reddit.com/.mobile), and it looks absolutely beautiful in w3m. In fact, I think I prefer it to the normal website in any modern browser; there are no distractions, just pure content. m.reddit.com rendered in w3m In order to get cortex to open the mobile version of reddit, I made a bash -script wrapper around w3m that takes urls and replaces `"http://reddit.com"` and -`"http://www.reddit.com"` with `"http://m.reddit.com"` before passing them to -w3m (as well as fixing a double forward slash error in the comment uri cortex -outputs that desktop reddit accepts but mobile reddit 404s on). The script: +script wrapper around w3m that takes urls and appends `".mobile"` to the end of +reddit urls before passing them to w3m (as well as fixing a double forward slash +error in the comment uri cortex outputs that desktop reddit accepts but mobile +reddit 404s on). The script: ```bash #!/bin/bash