Half-Elf on Tech

Thoughts From a Professional Lesbian

Tag: failure

  • Accepting Failure

    Accepting Failure

    This is a difficult thing to do, so let me share some briefs of recent failures.

    Failure To Launch

    I recently retired a plugin. It’s a good plugin, complex and clever and does things in a wickedly smart way. And its an absolute failure because it lacked the ability to solve one problem, perhaps the biggest problem it was intended to solve.

    The plugin was more complex in ways that it didn’t need to be. I spent a lot of time thinking about one use case, and I never looked far enough to think about the real world, which ended with this plugin only being used by 600 or so people, and most of them grumblingly.

    Accepting my loss, I recognized that I’d coded myself into a hole, wrote uninstall code, and apologized. A lot.

    Failure to Maintain

    I closed my ebook store recently. Quietly. Because it was so much work to update and maintain, and it was draining me. I kept all my books on Amazon, where they sell much better with much less work, and redirected everything.

    The problem was I wasn’t making enough money on it to justify it. While I had intelligently made changes to inspire people to purchase instead of download for free, and I strongly believe in letting them be free when they need to be, it’s just a lot of work. A lot. I was spending time I wasn’t earning on. Nor enjoying.

    Failure to Communicate

    There’s someone who hates me right now. They think I’m a terrible person, that I hate them, that I want them to fail. Because I was unable to explain sufficiently why what they were doing was wrong. I’ve tried appealing to them, offering them more exceptions and time than I usually do (ever) for a fix that should be simple.

    For some reason, we just can’t bridge the gap. They won’t listen. And no matter what I say, they only see hatred in it. I can’t convince them otherwise. And yes, that smarts. It’s a terrible feeling to not have failed myself, but to have failed someone else, to the point they feel they have no recourse.

    Accepting Failure

    Accepting you’ve failed at something is hard. Thankfully in all three cases, I feel like I’ve learned something from them. I learned how to control my temper, how to watch the weight of my words. I’ve learned how to properly write and run an ebusiness, and why I don’t want to. I’ve learned how to gracefully degrade a plugin.

    But knowing I failed still does hurt.

    So all I can do is learn from it and move on.

  • WP JSON API Challenges

    WP JSON API Challenges

    In my frustration of my static process, I ripped everything out by it’s roots and decided to take things in a strict order.

    Decision: All-In-One or Separate?

    The first question was do I want to download everything as one big JSON file and split it out later, or do I want to, from the start, download each post as it’s own file? The time to download shouldn’t change, and if I do it right, I could script it to check if the date stamp on my downloaded file was older than the post date in WP. That means I could have this logic:

    if ( ! post file exists || post file date < post datestamp ) {
        download JSON for this post
    }
    

    That made it an easy win. Let’s split away from the original plan. Now my goal is to extract all the posts from my WP site in JSON format.

    Remember the goal here is to run a static website with WP. There are plugins that convert WP to static HTML, which you can then use to power a site, and this isn’t a bad idea.

    How To: Get all the posts from a WP site via the JSON API?

    This sounded easy. http://local.wordpress.dev//wp-json/wp/v2/posts listed posts, and the v1 comparison chart says that you can list all posts, it stands to reason that I can easily get all my posts.

    In a way, this is a WordPress problem. WP doesn’t want you to show all posts. It would make your site very slow if you had, say, 10,000 posts. Which means that the claim that the JSON API can lists all posts is true, it just doesn’t do them all at once.

    I happen to have 40 published posts on my test site, so when I GET with this URL, it loads all of them: http://local.wordpress.dev//wp-json/wp/v2/posts?per_page=100

    But that isn’t sustainable. And the old trick of making per_page equal to -1 didn’t work.

    I did determine that the JSON API actually knows what the amount of posts is!

    JSON reports X-WP-Total which, in my case is 40

    The header “X-WP-Total: 40” is what I needed. Of course, that is rather weird to get. It means to get all the files, I have to write ‘something’ that does this:

    1. Get http://local.wordpress.dev//wp-json/wp/v2/posts and parse it to get the value of X-WP-Total
    2. Get http://local.wordpress.dev//wp-json/wp/v2/posts?per_page=X-WP-Total

    Okay. So how?

    Well remember how I mentioned a plugin that made a static site already? I was talking about things like Really Static. Save a post, it saves the JSON file! Why not write this plugin?

    Why not use “Really Static”? Well I don’t want to have WP doing more than be my content generator. I want to separate content (the blog) from WP. And that means I will end up writing a plugin…

    Am I In Too Deep? Or Am I Over My Head?

    So far, this has been an incredible amount of work. It’s been a lot of two steps forward and three steps back, over and over and over. And yes, it’s been very frustrating. I’ve given up many times and, if my posts about multiple approaches are any indication, I’ve deleted and restarted many, many times.

    And I have to be honest here… I’m giving up on this overly ambitious plan right now.

    This marks two major failures (three if I could how insane the entire ‘use Jekyll/Hugo to run a gallery’ was). First, I’ve failed to sensibly convert JSON files to MD in a scriptable and reproducible way. Second, I’ve failed to export JSON from WordPress in a simple way. Both those failures can be worked around. I can build a plugin that exports the JSON. It’s not trivial, but having done similar things I’m sure I can do it. The issue is ‘is it worth it’? And right now I think the answer is no.

    I’m back to the drawing board right now, sketching up new plans and ideas. I want to eliminate as many steps as possible. I’d like to leave WordPress alone, let it be WordPress, and similarly let my static generator be static. These failures have taught me more about the interdependencies than I expected, and I’ve learned more from them than I may have if I’d had outright success from the start.

    While I’m starting over, again, I feel hopeful and less ‘I hate you, JSON’ than I thought I would. I now understand things more clearly and I see how I made things far, far more complicated for myself.

    The future of this project is, weirdly, bright.