Notes about open source software, computers, other stuff.

Tag: Wordpress

Add horizontal scroll bars to the WordPress Hemingway theme

For this blog, I use the Hemingway theme by Anders Norén. I really like it, but while writing a post with some long terminal outputs earlier today, I noticed that the <pre> blocks, in which code and terminal outputs are wrapped (by Org2Blog) get line-wrapped. This makes it difficult for the reader to interpret the blocks, especially when the block contents is e.g. an ASCII art-like table.

So I wanted to see if I could somehow fix this with some CSS. And it turns out you can! In the WordPress admin screen, go to “Appearance”, then “Additional CSS”. There I added the following and clicked on “Publish”:

.post-content pre {
  word-wrap: normal;
  overflow-x: auto;
  white-space: pre;
}

This pice of code overwrites part of the theme’s CSS and makes sure the <pre> blocks get a horizontal scroll bar.

Related Images:

Configuring Org2blog

Yesterday I installed Org2blog, which allows me to write my blog posts in Emacs org-mode and push them to my WordPress blog from within Emacs. So far I like it a lot! One less reason to leave Emacs :-), and hopefully also a reason to blog more often. Other good things about keeping your blog posts in Emacs are:

  • You can simply export them to e.g. PDF. In my current setup it’s a easy as adding the line

    #+LATEX_CLASS: lckartcl
    

    somewhere at the top of the file (before the actual text of the post starts) to tell org-mode that it should use my personal LaTeX export style, followed by C-c C-e l o and a nicely formatted PDF of my blog post pops up.

  • You keep all your blog posts in plain text format, so if you would decide to change to a different blogging platform, uploading the old posts should be fairly easy.

Org2blog’s GitHub page mentions C-c p as prefix key for Org2blog’s functions, but in my case this prefix is already used by Projectile, and looking in Org2blog’s Customize Group I noticed that C-c M-p is an alternative prefix, so I’m using that to get the following functionality:

C-c M-p p publish buffer
C-c M-p P post buffer as page and publish
C-c M-p d post buffer as draft
C-c M-p D post buffer as page draft
C-c M-p t complete category

This is the Org2blog configuration in my .emacs file (note that I’m using John Wiegley’s use-package macro):

;;;;;;;;;;;;;;;;;;;;
;; Configure Org2blog, which allows me to write blog posts in org-mode
;; and then push them to my WordPress blog.
(use-package org2blog
  :config
  (require 'org2blog-autoloads)
  (setq org2blog/wp-blog-alist
        '(("blog.karssen.org"
           :url "https://blog.karssen.org/xmlrpc.php"
           :username "xxxxxx"
           :default-title "New blog post"
           :default-categories "Linux"
           :tags-as-categories nil)))
  )

Related Images:

Experimenting with Google’s AdSense

I don’t think this blog has any regular readers (especially since I’m not posting very regularly), but if they would exist they would have noticed two prominent changes in the last two days:

  1. the WordPress theme for the site has changed, and
  2. this blog now has several advertisements from Google’s AdSense programme.

Obviously, the two changes are tied together. From almost the first day of this blog’s existence I had been using the Carrington theme, and although I still like it a lot (including the fact that it has two columns on the left), its appearance on mobile devices was sub-par. To fix this I looked around for a theme with “responsive design” and the current one looks quite nice both on my desktop machines and on my phone.

Changing themes had been on my list for quite some time, but the reason that I took the time to actually do it was because of my idea to play around a bit with Google’s AdSense program. Apparently, Google likes it if a site looks well on all platforms. The main reason to add ads to this blog was to experiment a bit and simply to see if this is a viable way of recouping (some of) the costs associated with hosting this blog. I’ve got a decent number of monthly views (at least I think it’s decent 🙂 and it’s definitely more than I expected when I started out) so why not give it a try. Moreover, since this is my personal, low profile site, it can also give me an idea if it’s worth having advertisements on some of the community sites that I run.

So, all in all, I think the theme change is definitely a good one, and about the ads, we’ll see. Maybe it works out, maybe it doesn’t. All in all I hope they don’t interfere too much with normal reading of the site.

Related Images:

Using SSH for WordPress updates via the web interface

Note to self: if you want to be able to upgrade WordPress via the web interface using SSH, you need to have the libssh2-php package installed on Debian/Ubuntu Linux.

Don’t forget to restart Apache after installing the package. Reload the WordPress admin pages and you’ll see the SSH option added.

Related Images:

© 2024 Lennart's weblog

Theme by Anders NorénUp ↑