Rewriting LazyWP: Lessons from the First Overhaul

A couple of weeks ago, I embarked on a journey to develop LazyWP, a tool that leverages curses and Python to create a terminal user interface for WordPress users. As any developer knows, the first iteration of a software project is rarely perfect, and mine was no exception. After some initial development, I found myself at a crossroads that many developers face: it was time for a rewrite.

This rewrite was a profound learning experience. I quickly discovered the importance of starting on a smaller scale before diving into full-scale implementation of features. By focusing on creating a solid foundation, I ensured that the core functionalities were robust and maintainable. This approach not only made the development process smoother but also enhanced my understanding of curses and object-oriented programming in Python.

To be more specific, I restructured the entire codebase and created methods that are much more logical and organized. Now, the code is (more or less) fully documented—a step I initially underestimated but found immensely helpful in the development process. Additionally, I implemented a pseudo-MVC pattern, which gathers all the necessary information and content beforehand, then efficiently displays it.

One of the key points in rewriting the code was the implementation of commands. It’s possible to develop dynamic imports for packages and call methods within those packages. This makes it surprisingly easy to create new implementations of wpcli commands, as seen in the plugins implementation. I aimed to make everything as clean and understandable as possible so others could adapt and contribute. However, I’m not entirely sure if my approach to dynamic package loading is correct. It seems straightforward, but Python’s intricacies can be tricky, and I’m still learning. Nonetheless, these lines of code are the core of the magic:

commands_path = self.lazywp_path + '/src/commands/'
commands = [name for _, name, _ in pkgutil.iter_modules([commands_path])]
for command in commands:
    self.log.debug(f" - {command}")
    command_package = importlib.import_module('src.commands.'+command)
    self.commands_modules[command] = command_package
    command_config = command_package.config()
    self.commands[command] = command_config

Anyway, I can now check off some items on my to-do list for this project:

  • Display help which aggregates the infos from the commands (press [?])
  • Methods to make usage of curses easier within the project
    • Tables
    • Modals
    • Confirmation Boxes
    • Alerts
  • Code comments (I am proud!)
  • Plugins
    • toggle auto update
    • installation of new plugins
  • Themes
    • update
    • update all
    • activate
    • deactivate
    • toggle auto update
    • install
    • remove

I’ve put together a small video of the current state:

lazywp demonstration

When I installed the “default” theme, LazyWP stopped working because wpcli threw numerous PHP Fatal Errors that weren’t caught anywhere. So, my next task is to check the health of the underlying WordPress installation before starting up LazyWP. I believe this will also create synergies with wpcli, as I’ve identified some related issues.

Unfortunately, I won’t have much time to work on the project in the coming months due to my upcoming bachelor thesis. If anyone is interested in contributing, please reach out! 🙂

Posted in lazywp | Tagged , , | Leave a comment

Message boxes in lazywp

I pushed my current state into the main branch of lazywp. It doesn’t seem like much but I can now trigger a message box with a simple command and have an option to answer yes and no questions.

Messagebox in lazywp with a yes / no option
Messagebox in lazywp with a yes / no option

It’s not much, but I am a step closer to more implementations. Currently it’s possible to toggle activation, updating and deleting plugins. The next step is to create an installation prompt for new plugins. I think after that I will implement the help page which dynamically fetches the information from the commands.

Posted in lazywp | Tagged , , | Leave a comment

lazywp – A terminal user interface for wpcli

I am using the terminal quite a lot. Lately I moved to neovim as my IDE of choice because it’s fast, comfortable (after some time settling in ofc) and portable. With switching my IDE to the terminal I wanted to discover other tools which could help me with my daily workflow. So I found layzgit and lazydocker, both developed by Jesse Duffield. I don’t want to miss both in my system.

As a WordPress developer I use wpcli a lot. I mean, how can I not? It’s one of the most useful tools for automation within the WordPress universe. But I also use it to manage some WordPress instances by hand. And I usually forget the commands and their operators. This is why I am building lazywp.

lazywp - a tui for wpcli
lazywp – a tui for wpli

Since I am doing this in my freetime the development of this project will take some time. As for now I am concentrating on the python module curses and get everything stable. The next steps I can identify are:

  • Creating a flexible modal for some feedback messages
  • A flexible modal with yes/no as selectable options
  • A user input modal for installing plugins

With that I have a basic system which can handle plugins. It’s something. I’ll keep track of the development in this blog.

Posted in lazywp | Tagged , , | Leave a comment

Where did all the blogrolls go? #reviveBlogrolls

Writing this makes me feel like a boomer. Working on this blog made me realize how much the self-publishing evolved over time. This is my first blog since 2018 and it seems like that since this time the “internet” moved more and more to apps and platforms where content creators don’t own their content anymore. And I realize that I am also part of this development. Creating this blog means that I want to change this. I want to give the web back to me. I want to own my content. And I want to enable others how to do this. That’s basically the goal of this blog; writing about technology.

Apparently I wrote something relevant about WordCamps I wanted to preserve here from 2018. And I imported my writings about Universum Tonal. In the sidebar you find stuff to navigate through the blog, links to my projects and something apparently outdated: a blogroll. Even Matthias wrote about this reviewing his blog journey.

So I want to introduce a hashtag #reviveBlogrolls

Posted in Misc | Tagged , | Leave a comment

# universum tonal – .wav

Coming back to my image to midi experiment I wanted to go a step further because I see several flaws with this midi-stuff. It’s neat to have midi files with what you can play with but there are flaws in my script. First of all there is the loss of information. A pixel on the y-axis with a fixed x value with identical properties of another pixel on the same axis will be ignored with my script. I don’t like this but with the limited capabilities of midi-files I am bound to certain decisions. Looking at the wave format I can do a lot more with overlapping frequencies, velocities, wave-forms, shapes and whatnot.

Continue reading
Posted in Universum Tonal | Tagged , | Leave a comment

# universum tonal – .midi

Ya, okay, I got sidetracked. Actually I got some drafts laying around with topics about other stuff but I can’t really bother myself now to examine and plan the todos and stuff for this. Currently I am browsing a lot within the topic of sonification. There’s a really cool book I found and there’s so much stuff going on in the astronomy world (like EHT) that I really can’t keep track with everything – especially not with my own project. But with the new image of Sagittarius A* I got some inspiration on experimenting on stuff.

Continue reading
Posted in Universum Tonal | Tagged , | Leave a comment

# universum tonal – .init

This is the very first entry in the blog for an project currently called “Universum Tonal”. This repository is an experiment to document the development of a concept album with music made from the sounds of the universe. The goal is to extract the radio waves of certain celestial objects convert them into sounds, wave tables and samples which will be used in samplers, mixers and synthesizers to create an eight-track album.

Continue reading
Posted in Universum Tonal | Tagged , | Leave a comment

[Update] WordCamp „Roots“

Dieses Jahr gab es ja schon einige Kracher in der WordPress-Community: das großartige WordCamp Retreat in Soltau und das WordCamp Europe in Belgrad (bei welchem ich leider nicht dabei war). Bei Letzterem wurde unter anderem bekannt gegeben, dass das nächste WordCamp Europe in Berlin 2019 statt finden wird. Eine ziemlich große Sache, welche zumindest in der deutschen Szene kaum Platz bietet, andere Camps zu organisieren, da wohl die meiste Kraft dort investiert wird – zu Recht.

Aus der Community hatte ich von ein paar wenigen Stellen gehört, dass man vielleicht auch mal wieder kleinere Camps organisieren könnte, so ala ein Tag, ein Track, 50 Leute, Beamer, Kaffeemaschine, fertig. Ich finde diese Idee sympathisch, könnte so ein kleines Camp die Lücke zwischen den größeren Camps und den Meetups füllen.

Dieses „Back To The Roots“-Format ist in Relation zu Standard-Camps, dem Europe-Camp und dem Retreat relativ einfach zu organisieren. Da hier aber die Zielgruppe recht klein ist, wäre ein Invest von Swag, Sponsoring etc. für nur ein Event zwar zu groß, als dass es sich lohnt, eventuell könnte man das lösen und den Aufwand verkleinern, wenn es eine kleine Tour von vielleicht vier Root-Camps geben würde: Norden, Süden, Osten und Westen. Die Verwaltung, Swag, Tickets und das alles könnte zentral erfolgen, um die Räumlichkeiten und lokale Volunteers könnten sich die lokale Meetup-Gruppen kümmern.

Meiner Meinung nach auf jeden Fall eine Idee, über die wir diskutieren könnten. Was meint ihr?

[Update] Da für 2019 schon zwei Camps in Osnabrück und Stuttgart in konkreter Planung sind, wäre dieses Roots-Thema ein eventuelles Thema für 2020, denn da wird es auch wieder etwas großes für die deutsche Community geben 😉

Posted in WordCamps | Tagged , , | 1 Comment

#WCRetreat – Die Zukunft muss sozial werden

Nachdem nun das erste Retreat ein kleines bisschen Geschichte innerhalb der Community geschrieben hat, muss natürlich auch die Aufarbeitung folgen – vor allem mit den negativen Aspekten. Letztendlich gibt es nur einen negativen Punkt, welcher aber ziemlich Gewicht hat: Geld.

Ich habe das Glück wahnsinnig privilegiert zu sein. Den ganzen Trip (bis auf die Spesen) bezahlt mir meine Firma. Insgesamt sind das folgende Kosten:

  • Hotel: 342,60 €
  • Benzin: 128,69 €
  • Gesamt: 471,29 €

Das ist ziemlich heftig für ein Community-Kuscheln. Aber genau dieses Community-Kuscheln ist für viele von uns wichtig. Die Reaktionen zeigen ganz klar, dass die geschaffenen Verbindungen uns Kraft geben, zusammen bringen und gegenseitig motivieren. Wir passen wohl mehr aufeinander auf und wissen letztendlich besser, mit wem wir eigentlich so immer schreiben oder zusammenarbeiten.

Nicht alle haben Privilegien. Manche Personen haben nur 416€ im Monat zur Verfügung (nicht wirklich, aber das ist ein anderes Papier der Ungerechtigkeiten). So viel Geld haben nicht alle. Aber letztendlich ist die Contribution von diesen Menschen abhängig und wir müssen das nicht nur anerkennen, sondern grundsätzlich auch dafür Sorgen, dass wir alle versuchen auf das nächste Retreat zu bekommen – auch die, die es sich nicht leisten können.

Was können wir also tun?

Viel. Sehr viel.

Yoast hat einen Diversity Fund. Dafür müssen wir Werbung innerhalb der Szene machen. 25k€ sind ordentlich. Yoast gehört auch ordentlich geliebt dafür. Andere Firmen könnten da nachziehen und auch einen Fund einrichten. Müssen ja nicht 25k€ sein, sondern vielleicht gezielte Kontaktformulare, wo sich Leute hinwenden und fragen können.

Die Sponsoren-Situation wird sich wahrscheinlich in Zukunft ändern, denn ich denke, dass das Retreat angenommen werden wird und es einfacher wird da Gelder zu akquirieren. Vielleicht sollten aber zusätzlich zu den Geldern noch Diversity- oder Social-Tickets gesponsert werden, welche die Kosten, wie Anfahrt und Hotel übernehmen.

Eventuell können wir auch mit der Foundation reden und schauen, was da geht.

Vielleicht wäre es auch möglich, dass wir eine Option beim Ticketkauf bieten, dass die, die können eine Patenschaft übernehmen und das Ticket inkl. Anfahrt und Hotel (je nachdem) einfach mit kaufen.

Wir sollten auf jeden Fall bis zur Organisation des nächsten WordCamp Retreats darüber reden und Modelle in den anderen WordCamps testen.

Posted in WordCamps | Tagged , | Leave a comment