Hime-Works / Requests

Bug reports and requests that may require longer discussions and is not suitable to leave on the blog
http://himeworks.com/
GNU General Public License v2.0
7 stars 9 forks source link

Site maintenance #183

Closed HimeWorks closed 9 years ago

HimeWorks commented 10 years ago

Manually updating links is just too tedious, since I realized I have over 300 scripts. Going to do an XML dump and then just regex the thing and import everything...

But will need to test that it doesn't break permalinks.

Roguedeus commented 10 years ago

You're having a fun night... :)

HimeWorks commented 10 years ago

I just realized if I do a re-import I'd have to delete all posts/pages/etc. and then import it

HimeWorks commented 10 years ago

Doing a count of dropbox.com/sh occurrences in the XML showed 176, so...maybe I'll just manually do them...

Roguedeus commented 10 years ago

I know so little about database, php, html, etc... that its still intimidating for me to think about.

HimeWorks commented 10 years ago

If I had made it so that each page was just an HTML file I could probably have just done a regex find-and-replace across all documents.

I had considered doing a find-and-replace in the database, but then I realized regex wasn't something that was supported...

Roguedeus commented 10 years ago

When I initially started to teach myself about Regex, ruby seemed one of the most supported languages for it. Maybe its just the bias of my experience, but back when I was learning Java and C#, I hadn't a clue what Regex were.

HimeWorks commented 10 years ago

I think unless you're doing something like searching/parsing, you probably wouldn't come across regex very much in real-world applications.

When was the last time you needed regex outside of...string parsing?

Granted, I've written applications for business users where they type in regex as input, but that's mainly cause the tools they're using are parsers/searchers/matchers which naturally lends itself to these kinds of input.

HimeWorks commented 10 years ago

Page 6 out of 14...which means I only have 160 links left. There are likely a dozen or so scripts roaming around that isn't on my blog. They are mostly unsupported, which is why they don't have blog posts.

I probably won't be fixing those...

HimeWorks commented 10 years ago

Why did I write so many scripts lol At least I learned that I don't know how to maintain a blog.

Roguedeus commented 10 years ago

lol

HimeWorks commented 10 years ago

There are scripts I don't even remember writing

Roguedeus commented 10 years ago

Sometimes I think the same thing, and I am not even close to as prolific a script writer. ;)

I've started making personal notes as to why the hell I did things now.

HimeWorks commented 10 years ago

http://www.himeworks.com/2013/08/29/skill-type-groups/

This thing's pretty cool.

HimeWorks commented 10 years ago

Halfway through the edits, I realize that I should have first written some sort of redirect page that takes a string, looks up a table for the correct URL, and then redirects the user to that. That redirect page could have different uses as well, such as advertising.

Then I would never have to actually update my posts; if my link changes, I just need to update the table...

Roguedeus commented 10 years ago

Necessity is the mother of invention. :)

HimeWorks commented 10 years ago

Oh well might as well just fix the rest of the links...

HimeWorks commented 10 years ago

Actually what the heck PHP isn't hard to learn might as well put together something.

HimeWorks commented 10 years ago

Done. Simple redirect page.

http://himeworks.com/redirect.php?type=script&name=enemy_gold_formulas

Granted, there may be security holes that I'm unaware of.

<?php

$scripts = array(
    "enemy_gold_formulas" => "http://himeworks.com/files/rpgmaker/scripts/Enemy_Gold_Formulas.txt"
);

function redirect($url, $permanent = false)
{
    header('Location: ' . $url, true, $permanent ? 301 : 302);
    exit();
}

$redirectType = $_GET["type"];
$name = strtolower($_GET["name"]);
if ($redirectType == "script") {
    $url = $scripts[$name];
    if (strlen($url) > 0) {
        redirect($url);
    }
    else {
        echo "Unknown Script";
    }
}
?>
Roguedeus commented 10 years ago

See that is something that I hope I am able to do one day... Just throw things together at the drop of a hat. You make it look easy.

HimeWorks commented 10 years ago

For the most part if you know what your goal is and you can break it down into pieces, you should be able to find the relevant details anywhere on the internet.

I literally googled "how to redirect in PHP" and "how to get URL parameters in PHP" and "PHP hash map"

It may not be perfect or even aesthetically appealing for that matter but the details can be refined afterwards.

Roguedeus commented 10 years ago

Knowing what to look for is often 3/4ths of the challenge. At least in my experience. Ignorance compounds difficulty exponentially it seems.

I find that now that I have a fair knowledge of ruby and rgss3 and RMVXA my productivity has skyrocketed.

HimeWorks commented 10 years ago

That's true. That's usually when people just randomly go on a forum and throw out a broad question like "I want to do this. How to do it?" and then someone gives you an answer and it's like "OHHHHHHHH that was pretty simple if I knew what to type into the search engine"

Roguedeus commented 10 years ago

I find Stack Overflow to be highly useful when i have random code quandaries. (I use it much less these days) And luckily you for ruby and rgss. :)

HimeWorks commented 10 years ago

Hmm now I'm wondering whether the redirect API is enough. I plan to use it for libraries, demos, and scripts, so the type argument is provided. Then there's the name of the file.

HimeWorks commented 10 years ago

Frankly it took half the time to update each post after getting the redirect page since my file naming was rather consistent and it was easy to use regex to put together all of the links in a hash map.

HimeWorks commented 10 years ago

Ok so I finished the latter half. Will go and update the first half to use the new shiny redirect page. All links on the blog should be working now.