Giantpaper.org

Category: The Paper

  • Animated Hamburger Menu Icon

    Animated Hamburger Menu Icon

    This icon animates into an x (for a close button) when clicked on, using only CSS (errr…well, SCSS compiled into CSS).

  • Dear everyone, please stop asking me to link to your content

    Dear everyone, please stop asking me to link to your content

    I’m not sure how common this is, and I don’t get this myself too often. But I got at least two emails from other sites and companies if I would link to their content.

    Giantpaper.org is just a personal blog, which exists for my own pleasure and to sharpen my skillz0r. I don’t do it for internet popularity or to make money. I post whatever I want, even if no one cares about it. Half of the time, the site experiences slows (due to me experimenting on it) and errors (ditto), so I most certainly don’t expect people to stick around. I don’t really have a loyal readership or anything like that. I don’t have an entire team helping me manage this site. It’s just me, some nerd with a computer who decided to run a personal blog.

    If I link to something somewhere on this site, it’ll be because I tried it out either on my own or through work and liked it enough to link to it on there. I’m not to put something on that page and tell people I like it if I never even tried it!!!! Simple. C:

    (Second of all, I have no idea how these people are getting my email address. I used to have a contact page with a form and link to my email, but not anymore.)

    About Plugin Credit…

    Edited to add: Some WP plugins (not mentioning any names), if you express interest in linking to their site on your WP blog, they’ll choose how you get to link to them. NO NO NO, my site, I choose how I get to link to you. It was fairly good plugin, I wouldn’t link to them with negative feedback. (I ended up switching it out for another plugin that seems to do a better job, based on my web server.)

  • Demonstrating GeSHi using GeSHi

    Demonstrating GeSHi using GeSHi

    How I added GeSHi to GPORG. Here I will demonstrate using GeSHi (for prettification purposes).

    <?php
    
    function sexy_code ($a, $content) {
    	$attr = shortcode_atts(array(				// sets the defaults for each attribute so we don't run into errors if we're missing any
    		'lang' => 'html',						// default language is HTML
    		'start' => '1'							// which line num to start on
    	), $a);
    	
    	$content = strip_tags($content);			// remove wpautop() formatting from the snippet
    	
    	$array = explode("\n", $content);
    	$tab = null;
    	$t = 0;
    	$pos = null;
    	
    	foreach ($array as $i => $line) {
    		$code = $line;
    		if (strpos($line, '//') !== false) {
    			list($code, $comment) = explode('//', $line);
    		}
    			if (preg_match("#\{|\($#", $code)) {
    			$pos = 'after';
    			$t++;
    		}
    		elseif (preg_match("#\}|\)$#", $code)) {
    			$pos = 'before';
    			$t--;
    		}
    		$tab = ($t > 0 ? implode("", array_fill(0, $t, "    ")) : null);
    		$line = ($pos == 'before' ? $tab : null).$line.( $pos == 'after' ? $tab : null);
    		$array[$i] = $line;
    	}
    	$content = implode("\n", $array);
    	$content = preg_replace("#(    +)(\n)#", "\\2\\1", $content);
    	$content = str_replace("    }", "}", $content);
    	
    	$content = preg_replace("#\&amp;([a-z0-9]+);#", "&\\1;", $content);
    	$content = str_replace('&lt;', '<', $content);
    	$content = str_replace('&gt;', '>', $content);
    	
    	//echo secret_output ('test HTML',$content);
    	
    	$lang = $attr['lang'];
    	$geshi = new GeSHi($content, $lang);
    	$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);	// type of line numbers
    	$geshi->enable_classes();					// turns on classes so we can prettify thru CSS
    		if ($attr['start'] != 1)				// if you specifically mentioned which line number you want the snippet to start on
    	$geshi->start_line_numbers_at($attr['start']);		// ...set it here
    	
    	$r = $geshi->parse_code();
    	
    	$r = str_replace('<ol>', '<ol class="no-custom">', $r);
    	$r = preg_replace("#^<pre>#", '<pre class="wp-block-code">', $r);
    	
    	return $r;
    }
    add_shortcode( 'code', 'sexy_code' );			// shortcodify!
    
    ?>

    (See the doc on WordPress’s shortcode API if you haven’t already.)

    To use in a post…

    [code lang="php" start="2"]<?php echo $fun; ?>[/code]

    …will get you…

    <?php echo $fun; ?>
  • Changelog || v2017.06.10

    Changelog || v2017.06.10

    Bug Fixes

    • Some of the post/page body text and the sidebar on the static pages were creeping under the left/right-aligned images.

    Improvements

    • The browser’s default tooltips were replaced with swanky-looking custom ones. ^_^ Some Javascript magic had to be involved (in order to remove the default ones, otherwise you would get the default ones along with the stylized ones and that would not be cool!). But the new tooltips themselves are 100% CSS black magic.*
    • Some of the posts and pages have subtitles. I redid said subtitles so they look cooler, after seeing how a lot of news sites format their articles now (trying to get away from the blocky look of the text basically).

    *On that note, I was on r/TheSliphRoad when I noticed that the upvote/downvote buttons on topics showed a Pokemon icon (whichever ‘mon starred in the most recent PoGo event) flying away and fading when clicked. Looking at the source code, I noticed that there was a new property transition that I never seen before. So that’s what’s powering the fading and moving part of the tooltips. Stuff like this reminds me that CSS is like the zerg–always changing and evolving. 🤓