Giantpaper.org

Category: Information Station

It may not be in huge numbers. But by golly, if you need information, you’re gonna get information. 😤

(YMMV on whether or not you found it informative…)

  • Giantpaper.org…Federated!!

    Giantpaper.org…Federated!!

    I’ve finally done it. 😬 Ever since I heard that it was possible to federate WordPress blogs, I’ve been interested in having GPORG join the fediverse. For me, it wasn’t just plug ‘n play, because of my setup (Litespeed Web Server, with a cache plugin + Cloudflare). WordPress’s site health thing kept saying:

    Your author URL does not return valid JSON for application/activity+json. Please check if your hosting supports alternate Accept headers.

    Apparently, you can test whether or not these accept headers are working by entering in the command line:

    curl -I https://test.giantpaper.org/author/giantpaper/ -H "Accept: application/activity+json"

    With the https://test.giantpaper.org/author/giantpaper/ being the URL to your author page. It’s supposed to bring up a normal HTML page just as you designed it when viewed in the browser, but when entered in the command line with the accept header, it’s supposed to return JSON. For me, it was returning as text/html, which is what the problem was.

    Here’s what I did. Hopefully it’ll help someone else.

    Caches

    Every tutorial or fix I saw online was either for Apache or nginx, but I’m using Litespeed. Supposedly, caches aren’t supposed to butt heads with the Activitypub plugin, but there were some exceptions (some people found it started working after they disabled plugins like Jetpack). I figured out I could bypass the cache by adding https://test.giantpaper.org/author/giantpaper/ to the exclude list. Only problem is that the cache would also be bypassed if the page were accessed in browser which I didn’t want.

    There seems to be only other article I saw online about Litespeed + WP Activitypub issues. Fixing OpenLiteSpeed Caching for ActivityPub on WordPress [Archived] (you basically need to add a rewrite rule to your .htaccess file). I THINK this helped.

    index.php

    I’m using my own version of Sage and found that the accept header thing works if I had the default Twentytwentyfour theme activated. I found that the correct JSON code was returning with my own custom theme, but it had the surrounding <html> and <body> tags, as well as everything in the <head> tag everything outside the #app container, which what I have in my index.php file for the theme. I think it had something to do with all of this code being in the index.php file (normally this would be in the header.php and footer.php files). Wasn’t sure how to not make it do that other than:

    <?php
    if($_SERVER['HTTP_ACCEPT'] == 'application/activity+json' || preg_match("#^/(.+)/activitypub/?$#", $_SERVER['REQUEST_URI'])) {
    	header("Content-Type: application/activity+json; charset=UTF-8;");
    	echo view(app('sage.view'), app('sage.data'))->render();
    	die();
    }
    ?>

    (The $_SERVER['HTTP_ACCEPT'] == 'application/activity+json' tells the server to only bring up this code if the content-type is set to application/activity+json. Since the content-type of WordPress posts & pages are almost always text/html when viewed in a browser, you won’t be smacked with a big wall of weird-looking code when trying look at your own author page.)

    I put this at the very top of my index.php file. If you do:

    curl https://test.giantpaper.org/author/giantpaper/ -H "Accept: application/activity+json"

    You should see a big wall of confusing looking code (compressed JSON). This is what you want.

    Cloudflare (optional?)

    I’m not sure if this was necessary, because supposedly the rewrite rule from the Caches section would’ve taken care of this, but I did the previous two items and it still wasn’t working. So in Cloudflare, under Caching > Cache Rules, I added a new rule:

    • URI Path: Not sure if it really needed to be URI Path or if URI or URI Full would’ve sufficed. Obviously if you use URI Full, you need to include the domain name + protocol (https://…).
    • Request Headers: In the blank field after Request Headers, put content-type. Field #3, put as equals. Field #4 as application/activity+json

    Browser Cache TTL

    I found I had to leave the Browser TTL as 4 hours (which I think is the default):

    Disclaimer

    Earlier, whenever I clear the site cache, I notice I would get the same message in Site Health:

    Your author URL does not return valid JSON for application/activity+json. Please check if your hosting supports alternate Accept headers.

    And doing:

    curl https://test.giantpaper.org/author/giantpaper/ -H "Accept: application/activity+json"

    Followed by:

    curl -I https://test.giantpaper.org/author/giantpaper/ -H "Accept: application/activity+json"

    In this exact order fixes it. Why? I don’t know.

    Sidenote: I updated something on the site and cleared the cache. I don’t get this message anymore. Why? I don’t know.

    Sometimes you might notice that the error message won’t go away after doing any of the above. I THINK the Site Health checker just needs time to check again (a half an hour? An hour?). I’m not sure if it’s a cache problem.

    What it doesn’t do

    • If you have custom fields on your theme, you won’t be able to include them in fedi posts. Hopefully that will change in the future, because my linklog posts make so sense without the external URL.
    • This is completely separate from Lemmy or Mastodon, and there’s no way to connect your existing accounts with your newly federated WordPress site. It creates a completely separate profile on all supported fedinetworks.
    • Looks like it doesn’t support kbin yet. Kbin is still new and doesn’t have an API released at the moment (this is being worked on), so…yeah.
    • Any new posts you create will federate, but it won’t pull over pre-federation posts. It’s most like email than say RSS.

    Conclusion

    Aaaaaand I think that’s it. I think it still might be indexing everywhere, but you can search for giantpaper@giantpaper.org in your fedi instance (it’s definitely on mastodon.social*). Comments on GPORG are disabled, so I dunno what will happen if someone responds on Mastodon, but it won’t show up here (since comments aren’t even supported on this theme).

    *If you’re not signed into mastodon.social, it’ll just redirect to the author page on giantpaper.org.

  • Using a Computer Monitor as a TV (Breakdown)

    Using a Computer Monitor as a TV (Breakdown)

    Ok I did more looking up on the hurdles I was experiencing previously and read more about these. Here’s what I have going (and what I found):

    • Using this HDMI monitor. I think this setup will work with any monitor.
    • HDMI switcher plugged into one of the inputs with these two HDMI devices:
      • Nintendo Switch
      • Roku Streaming Stick 4K (with simple remote)

    There are two HDMI inputs on this monitor, and this monitor does not support CEC apparently, so changing inputs has to be done manually with the hardware toggle. Accessing the menu for this is a pain in the bum. You have to press on the toggle and wait for the circular menu to show up, so you can navigate to the input menu. I have a tendency to accidentally trigger the volume level, by navigating with the toggle instead of pressing on it and got really annoying. So HDMI switcher it is!

    Display

    Monitor stays in sleep mode 24/7.

    Roku

    This monitor does not seem to have any sort of CEC support, so instead of having it act like a TV, this is how I turn the player on and off:

    • “Turn on” by bringing it out of sleep mode (press the OK button on the remote’s “D-pad”)
    • “Turn off” by letting it go into sleep mode (I think the timer is set to 20 minutes. Not sure if it’s possible to change this)

    The power button doesn’t do anything in this case, FYI.

    HDMI input needs to be changed manually without CEC support.

    Nintendo Switch

    Using the Switch with a monitor is nothing new to me. When you’re not using it, you can just put it in sleep mode and wake it up with the joycons/Pro controller (just as if it were connected to a TV).

    Volume

    Using the monitor’s built-in speakers, so to adjust the volume or mute/unmute, I use the hardware toggle on the monitor. Whatever TVs have that let HDMI devices control the volume is non-existent in monitors, even ones with built-in speakers (since I’m assuming the manufacturers intended for people to use with a computer, which already their own volume control). And computer monitors almost never come with remotes of their own, sooo…

    Roku

    You can try to set this up in Settings > Remotes & devices > Remotes and select your remote, then go to Set up remote for TV control. The player will start playing music and if you’re lucky, one of the TV codes will turn the music off. For me, it went through all 7, without any luck. The only thing I could think of is the streaming stick was plugged in behind the monitor and the instructions say to make sure it’s not plugged in behind the display??? (I think this is exactly what it was made for?) But plugging in the HDMI switcher in the front also didn’t do anything either.


    Will update as soon as I find out more.

  • A Computer Monitor as a TV? 🤔

    A Computer Monitor as a TV? 🤔

    FYI, here’s a better breakdown of this post. Leaving this here for context.


    Sooo, I just got a 4K monitor to use as a dedicated display for my Nintendo Switch. Previously I had the console plugged into an HDMI switch, which also connected my laptop and Windows desktop to the same monitor.

    The display situation worked great for lazy people, but in order to have audio come from the Switch, I needed to manually plug speakers into the audio port (because, noooo my monitor does not have speakers. I get this question a lot for some reason). I have a Y-adapter that splits the audio cable between my desktop and laptop. And in order for my Switch to have sound, I would unplug the laptop audio cable into the Switch. And because the cable wasn’t long enough, I had to move the Switch dock onto the space where my desktop mouse lives. And would have to move it aside when I needed to use my desktop. So I decided it was time for an upgrade.

    This was the monitor I ended up getting. It supports up to 4K, and ironically the Switch doesn’t do 4K. 😀 But it’s working great so far! I finally get to have a “TV” in my room!

    Why a monitor and not a TV?

    I chose a monitor instead of a TV, because well…I don’t have a lot of space. And the only decent TVs I could find where the giant 55in displays. The space I had planned only had room for 32in.

    Also, I learned that there are no “dumb TVs” anymore. All TVs made these days come with its own built-in OS and media player. I never use the built-in media player on my parents’ smart TV because quite frankly, it sucks really bad. The Crunchyroll app is pretty garbage (to be fair, the Crunchyroll app on PS4 is also garbage). And the general consensus is to never use the built-in media player on smart TVs, because eventually the hardware will show its age and no longer be able to support the newer OS versions. And then what? Get rid of the entire TV for a new one because it can’t run the latest OS? It’s easier and cheaper to just upgrade your Fire TV or Chromecast than the whole TV. So why have something installed if I’m never going to use it?

    And then came the Roku

    And then I decided “I wonder if I could make it more TV-like. 🤔” I settled on Roku players, because:

    • They’re pretty mobile OS agnostic, but support iDevices pretty darn well.
    • I have a laptop made by Apple, a phone made by Apple and 2 tablets made by Apple. Music streaming service is also from Apple, so I think it’s not a bad idea to have a little brand name variety. (Smart speakers aren’t made by Apple btw, but had to feed money to Bezos to get them. But they work well with Rokus 👍).

    I went with the Streaming Stick 4K. The monitor I just bought has 2 HDMI ports, which is great because I put my spare HDMI switch down somewhere and it disappeared. D: And here is where the fun starts.

    Things I learned

    When I first tried turning off the streaming stick with the remote, it said something about enabling CEC on the “TV” with instructions to go to a help article on their site. (So when powered off, the TV would also turn off along with the Roku. And if you turned on the Roku, the HDMI input would automatically change over to the port the Roku was plugged into.) So this was enabled by going into the TV settings (in the TV’s OS). I thought I would find this under the monitor settings, but no dice.

    And also, it wanted me to turn on ARC, which lets the player control the speakers. But uhhh….yeah, found no such thing. So, the sound comes through the speakers quite well. I just can’t control the volume with the remote. I have to adjust it with the monitor’s built-in toggle. (Luckily, I’m sitting right in front of it whenever I use it, because bed is too faraway, so reaching over to adjust it isn’t the worst.)

    Because there is no CEC support, I can’t actually turn off the Roku. I found that I can just let it go to sleep. Eventually, the monitor goes to sleep as well and when I want to watch something, I just need to press the OK button (right in the middle of the D-pad on the remote) to wake it up. The power button will just be ignored.

    You know, most modern game consoles have media players built right in?

    The only game console I have is the Switch (and before that, I was 100% a PC gamer). And it’s like I can find a PS5 or XBOX Series S/X right now. :/

    TL;DR

    So yes, this is possible. But here are some things to think about first:

    If you want sound, either:

    • find a monitor with built-in speakers (with fancy ARC support, if you want to control the volume through your HDMI device)
    • use a media player with a built-in speaker (ex. Roku Streambar). Someone did just that and found it worked great.
    • get an audio extractor, which is like a splitter but for HDMI and audio ports, and then plug the speakers of your choice into the audio ports

    If you want your media player to control HDMI on your monitor, look for a monitor with CEC support. Apparently, they exist(ed–post was 3 years ago, so dunno if they still do). Otherwise, when you’re not using the media player, let it (and the monitor go to sleep) and when you want to use it, press OK on the remote. If you want it to turn off right away (because let’s say, the monitor is in your room and you want to sleep without this bright-ass display glaring at you for ~10 minutes), you can just physically turn off the monitor itself.

    (Sidenote: A lot of HDMI monitors support DDC/CI as an alternative. It’s what makes the monitor plug and play, instead of the user having to install drivers. The monitor supports it, but apparently neither the Nintendo Switch nor Roku devices know what to do with it.)

    [EDIT: 2021/11/27] Updated to mention that fancy ARC support (or whatever it’s called) is needed if you want to control the volume with your HDMI device (Switch or media player). Barebones ARC support is what lets HDMI send audio signals to the display. (source: Wikipedia)

  • From Mac OS Big Sur to Monterey: The Saga

    From Mac OS Big Sur to Monterey: The Saga

    So my big, super amazing plans for GPORG that I’m been working at furiously behind the scenes (locally) at had to be put on hold.

    Apple decided to release Monterey around Halloween. And I upgraded, after reading that there’s not much of a difference between it and Big Sur (because apparently, Monterey is based of Big Sur, code-wise).

    The biggest difference I noticed is that Apple decided to remove the built-in PHP in Monterey. And to be fair, they did warn about this in Big Sur (labeling it as deprecated), but I completely forgot about this. (And honestly, having a third party PHP install means you could update it whenever you want. If you were using Mac OS’s PHP, you were at the mercy of Apple, whenever they realized PHP needs to be updated. Which was almost never.)

    After doing some searching online, I decided to install PHP from Homebrew. I ran into some 403 (Forbidden) error issues, and one of the suggestions I found online was to upgrade Apache. Except you can’t upgrade the OS’s built-in Apache for some reason. And the solution to that was to install Apache from Homebrew instead.

    I’ve been using Homebrew for about a few years now, so it wasn’t anything new to me. I already had PHP 8 installed through Homebrew. And I already knew what was involved in setting up Apache, because for some reason, whenever people upgraded between Mac OS versions (from Catalina to Big Sur, etc), the OS would completely reset your Apache settings. 🤨 I think in newer Mac OS versions, they’ve been backing up the config files, by changing the old files to something like httpd.conf__BACKUP or something (which was better than completely removing them). But even so, I needed a tutorial to figure out how to set up this install of Apache.

    I don’t remember which tutorial I followed, but I did everything by the letter, and whenever I visited 127.0.0.1, I got a “could not connect to server” error, and after tweaking the config file a little later, it turned into a 403 error. Like, wut.

    Nothing I did fixed it. For a while, I thought it was being literal and there was a problem with folder permissions. And then after reading online, someone on StackOverflow suggested it was a PHP problem. Like maybe there was a problem with the PHP install. I couldn’t tell if that was it. apachectl configtest said “Syntax OK”! And brew doctor kept giving unrelated warnings about other brew packages (and no, fixing them did not fix the problem).

    OpenLitespeed???

    At one point, I tried ditching Apache for OpenLitespeed! Because my host uses the enterprise version, I’m already pretty familiar with Litespeed servers in general, right???

    And installing it on Mac OS only gives you two options: you could either build it from source or install it through Docker. I tried it from source, because I didn’t want to go the Docker route. I barely understand Docker or its purpose, and while Docker!OLS comes with its own MySQL/MariaDB and PHP installs, I wanted to use whatever I already had installed from Homebrew, and not savvy enough to know how to get Docker!OLS to recognize the Homebrew installs, instead of the Docker versions (or if it was even possible).

    Installing from source did not work. I think I got part of it running, but 127.0.0.1 still gave the “could not connect to server” error. And didn’t know how to fix that.

    So I tried that Docker route, and while I got it running successfully, I didn’t know how to get it to recognize the folders I set up for each virtual host. And I looking through the OLS folder, I found a .env file that covered the entire server. One of the settings was for WordPress (URL specifically). So I need to have one WordPress install per server only?? Searching online for “multiple wordpress installs on openlitespeed” only brought up one page on this, and it didn’t talk about setting up multiple WordPresses on one OpenLitespeed server. 😐

    Back to Apache

    After this point, I decided that as a user, I’m pretty familiar with Litespeed. But as a server admin, I’m more familiar with Apache, and while I’m not an expert at debugging either, I’m better at debugging Apache.

    So I was back to trying the usual stuff before I even though about OpenLitespeed. Googling “mac os apache 403 forbidden” (or any combination of) showed me all search results with purple links. 😬 (As in I already visited them before, probably several times).

    I also tried uninstalling and reinstalling Apache, as suggested by someone on StackOverflow. It didn’t fix the problem, but before I uninstalled, I renamed the httpd folder to httpd_old, so I would get the default config files. However it’s set up, I wanted to see if changing as few settings as possible would fix things.

    Eventually I found this article. And it looked like the other 50 articles I read about the topic, and it’s for the built-in Apache rather than the Homebrew version, but Ctrl/Cmd+F for the heading “Losing Localhost”.

    Instructions for fixing the 403 error on Mac OS Apache.
    Screenshotted, because Gutenberg kept messing up the formatting.

    So I have at the top of my httpd-vhosts.conf file:

    Screenshot of a portion of my httpd-vhosts.conf file

    /usr/local/var/www is the default DocumentRoot for Homebrew Apache, BTW. It already has a index.html with “It Works!” text, so 🤷‍♀️.

    Another thing I did that wasn’t done after I reinstalled Apache: uncomment this line in httpd.conf:

    LoadModule userdir_module lib/httpd/modules/mod_userdir.so

    If you’re getting errors when restarting Apache (for me, it was about not finding the public_html folder), in your httpd-userdir.conf, look for this line:

    UserDir public_html

    If you try to access localhost/~username from your browser, Apache will try to look for a public_html folder in your user folder. You can either create a public_html folder in your user folder, or just change it to:

    UserDir Sites

    Since I already had ~/Sites set up from the old Apache install (pre-Monterey), I just changed it to Sites. But it can be wherever you’re keeping your local sites files on your computer.

    sudo apachectl restart

    …and Apache works again. 🥳

    Now gotta fix this huge number of PHP errors on my local sites, after jumping from PHP 7 to 8. 🙈