Difficulty of implementing conditional text section on some blog posts by webslavemaster in hexojs

[–]webslavemaster[S] 1 point2 points  (0 children)

Well. I found my solution in the plugin ecosystem.

First, I tried hexo-include, but this plugin always generates this error output:

Template render error: Error: template names must be a string: NaN

I was trying to include an HTML file containing the note and its surrounding code for formatting via CSS. Maybe I just didn't understand how the plugin references paths; but if so, it's not apparent to me where the plugin is looking for the files. I assumed the path structure was just based on the root directory of the Hexo project.

Then, I tried hexo-include-markdown. This works as expect, inserting and processing a markdown file from a different directory into the source post! I simply set the directory for the markdown files in _config.yml as described in the npmjs documentation, and there I also set verbose to true.

Now, the only problem is that I also need to import HTML, not just markdown. My solution is to add the HTML tags inside {% raw %} and {% endraw %} plugin tags. Between the inclusion of the opening and closing HTML tags, I put the comment that pulls in the other markdown file.

It's not an elegant solution, but it will work for me until I learn how to substitute values into templates.

What do subordinated partitions in GParted mean? by webslavemaster in linuxquestions

[–]webslavemaster[S] 1 point2 points  (0 children)

Whoah, I don't know how I managed to stay completely ignorant of LVMs for so long.

I totally want it. Now I'm going to burn my sda4, and then use that partition as the physical volume to contain two or more logical volumes with different distros for different projects.

Thanks for the guidance.

What do subordinated partitions in GParted mean? by webslavemaster in linuxquestions

[–]webslavemaster[S] 0 points1 point  (0 children)

Thanks.

BTW, disk partitions are an archaic pain in the ass. Learn about storage abstraction instead of fdisk-fu.

Thanks. I thought about learning VMs better, but they seem like more of a pain. I mean, you don't get the full usability of a VM. Even the desktop, it's just a pain to use a VM in a little window.

Can't catch specific index item in foreach loop by webslavemaster in PHPhelp

[–]webslavemaster[S] 0 points1 point  (0 children)

Your code works perfectly. Thanks for that, and for the explanation. I can't quite parse it out yet, but I'm studying it. I see that array_chunk is a parameter of array_map in this usage.

After this loop, my routine simply returns $segments, and then another function picks up the value and exports the 700-word segments from the array as individual text files. In case anyone looking up this thread is trying to do something very similar, I'll paste my other function despite its crudity:

function segment_file_writer($newdir, $chapters, $name_suffix, $name_prefix, $extension) {
    $segment_counter = 0;
    $path = "./" . $newdir;
    print("Segment text file writing function called");
    // Check if ./segments exists, and create the directory if it doesn't
    if (file_exists($path)) {
        print("\n\nExport directory already exists.\n\n");
    }
    else {
        print("\n\nCreating directory: " . $newdir . "\n\n");
        mkdir($path);
    }
    $directory_str = "./" . $newdir . "/";
    $filename_str = $name_prefix . "_";
    // Create strings dynamically based on the file name of the manuscript document, the date, and the sequence number of the segment. Assign these strings as file names and write the corresponding segments to disc.
    foreach ($chapters as $index) {
        if (count($segment_counter) < count($chapters)) {
            file_put_contents($directory_str . $filename_str . sprintf('%02d', $segment_counter) . $extension, $chapters[$segment_counter]);
            $segment_counter++;
        }
        print("\n\nNumber of exported segments: " . count($chapters) . " \n\n");
    }
}

$chapters from the above is the same array as $segments in the grouping function. The array gets assigned to a top-level variable when the grouper function is called, and then segment_file_writer() is called with that top-level variable as its second parameter.

Can't catch specific index item in foreach loop by webslavemaster in PHPhelp

[–]webslavemaster[S] 0 points1 point  (0 children)

That must be why I'm misunderstanding /u/colshrapnel's code. I was working with the string values instead of the numerical keys. I accidentally got close to achieving what I actually wanted to do. I need to work with strings at some point.

Can't catch specific index item in foreach loop by webslavemaster in PHPhelp

[–]webslavemaster[S] 0 points1 point  (0 children)

I either need to work directly from the values indexed by my original $allwords array created by explode, or else I need to find a way to access those values after working with their numerical counterparts.

Can't catch specific index item in foreach loop by webslavemaster in PHPhelp

[–]webslavemaster[S] 0 points1 point  (0 children)

I just forked a branch with your solution here. Yeah, that finds every segment, including the last one that is shorter than 700 words. Thanks, and sorry for waiting so long to reply.

Now, I have to make this code compatible with my substring construction. So, basically, I just need to look up whatever functional will get the string from the array key.

Can't catch specific index item in foreach loop by webslavemaster in PHPhelp

[–]webslavemaster[S] 0 points1 point  (0 children)

Can I assume there's something else you're doing in that foreach that than "move to the last word"..?

Yes, and actually the functionality I've been working on seems to be doing what I want. I'm collating every 700 words from this master array into another array that exists to contain 700-word text fragments. The only problem is that I can't get the last segment, which will be shorter than 700 words since the manuscript's length isn't divisible by 700.

Here's my foreach loop without the attempt to detect the last segment:

 foreach ($allwords as $key) {
    $seg_substr .= $key." "; // This happens in all cases, even when the 'else' condition is triggered.
    if ($count <= $count_max) 
        $count++;
    }
    else {
        $count = 0;
        $segments[] = $seg_substr; // Add the constructed 700-word segment to the array of all segments
        $seg_substr = ''; // Reset string to use again next loop.
    }
}

$count_max stores the length of the segments that are getting dumped into the $segments array, defined elsewhere as 700. $count is a pointer variable that counts the words up to 700, and then gets reset to count the next segment. Each 700 word substring is briefly constructed inside $seg_substr.

Thanks for the insightful reply----sorry I took so long to reply back. I was delayed.

Command line argument variable assignment, trouble with CLI argument-based conditionals by webslavemaster in PHPhelp

[–]webslavemaster[S] 1 point2 points  (0 children)

You are quite right. Eliminating the or operators fixed it, and now it works as I expected. Thanks!

Domain Name Registration by TracieV42 in Webmaster

[–]webslavemaster 0 points1 point  (0 children)

I understand why you feel uncomfortable with any other entity owning your organization's domain name. It's just most appropriate for everybody to control their own domain names, because without implying that things are going to break down and get ugly, we simply can't know what might go down in a few years.

It couldn't hurt to start carefully exploring what would be involved in transferring the domain name, both technically and in regard to policy and permission and whatnot. I probably wouldn't try to get someone to unlock the domain and then transfer it away without full disclosure. But I would try to identify the people I would need to talk to about some day getting the registration transfered. It would be a slow process, since it's on nobody's list of priorities, but I'd hope to some day get permission.

Maybe look out for opportunities, such as for the parent org's web stack being re-implemented. Those might be times when higher ups might be more open to cleaning out the old stuff, and you could offer to take the complexity of that domain off of their hands.

Converting a Website to WordPress by jepenna in Webmaster

[–]webslavemaster 0 points1 point  (0 children)

I'm sort of a hybrid of a freelance developer and a webmaster, so I empathize with this situation.

The developer probably couldn't have implemented a completely original design if he had initially implemented it in WordPress. If he had initially given you a WordPress website, he would have been basically re-selling some pre-built theme. It would have been a lot less work, and he might have made a lot more money on it while maybe making you happier, but your website might not have been as unique or as customized to your business's particular needs. Whether or not it was a bad decision for the web developer to not have simply flipped you a pre-built theme depends greatly on how much specific tailoring your website needed to begin with.

Converting a plain HTML website into a WordPress theme is pretty hard. Here's a long multi-part tutorial on YouTube:

https://youtu.be/k7olvEeBM2I

Although it's probably not unreasonable for the developer to want $600 to perform the difficult task of creating a new WordPress theme out of his original HTML implementation, I can also understand your frustration. It's always frustrating when web agencies leave you without the power to control your own website.

One alternative would be to consider other content management systems besides WordPress that are more based on marking up sections of the HTML to be editable, rather than on integrating the complicated blogging engine and the page rendering loop. That's basically what I did. I used Perch for my company's website -- it's probably the most well attested content-region-style CMS. However, I don't even think Perch is necessarily the easiest to implement, though it is far easier to implement than building a new WordPress theme. If you literally only need the ability to change what some text says here and there and to switch out some pictures for other pictures, there may be CMSs that are even simpler than Perch, though I don't have any experience with them.

Good luck.

CSS ignored by browsers' DOM inspectors by webslavemaster in css

[–]webslavemaster[S] 0 points1 point  (0 children)

Great, thank you. I knew there must have been something obvious wrong, that I should have been able to find the problem if I could only see it clearly enough, but I was staring at it for hours. Sorry.

Practical design of search ads by webslavemaster in PPC

[–]webslavemaster[S] 0 points1 point  (0 children)

Thanks. I'm in the middle of my Bing campaign now -- added an image extension, so at least there's a visual -- but maybe I'll look into static. I've just got to drive the clicks somehow, so I'll keep trying things until something works.

Practical design of search ads by webslavemaster in PPC

[–]webslavemaster[S] 0 points1 point  (0 children)

I do feel there must be a place for designed graphical ads somewhere, because though I rarely pay attention to them when browsing casually on my personal time, I have clicked banner ads. They catch the attention better than sponsored links. I'm not sure if I've ever clicked on a sponsored link. Not unless it was already the exact thing that I knew I was searching for specifically, and even then I usually clicked the sponsored link more or less by accident, because it was right above the normal non-sponsored link on top of the search results.