Aug 14 2008

Testing demo insertion

Tag: Web Design, jQueryDanny @ 9:00 pm

I added some potentially dangerous code to automatically turn code examples (things in <code> elements with class demo into actual HTML or javascript that are added to the post. The javascript part works; I used it in the last post; here's testing the HTML insertion:


  <div style="background: purple; margin: 2px">This is a test</div>

And more testing:


  <div style="background: #080; margin: 2px">This is a test</div>

Aug 10 2008

Testing Chili

Tag: Web Design, jQueryDanny @ 7:59 pm

I like the idea of syntax coloring, so let's see if Chili works:


alert('Hello, world');

and another: <div>Hello, <em>world</em></div>

I'm trying to be as HTML5-compliant as possible, at least in the sense of using their standards rather than making up my own, so the Chili setup I'm using is:


    $.extend(ChiliBook, {
        automatic: false,
        codeLanguage: function(el){
            // use the HTML5 language class
            var recipeName = /language-(\S+)/.exec(el.className);
            return recipeName ? recipeName[1] : '';
        }
    });
    $(function(){
        $('code[class*=language-]').not($('pre code')).chili({lineNumbers: false})
                                  .otherwise().chili({lineNumbers: true});
    });

 

Sweet! The idea of the above code is to look for a class that starts with "language-" and use that as the recipe for Chili (rather than Chili's built-in way of taking the entire className). It also assumes that any code in a pre element should have line numbers, and anything else should not. It uses the cute and brilliant otherwise plugin from http://groups.google.com/group/jquery-en/browse_thread/thread/6be2a127822a108d.

Update: It looks like line numbering works only intermittently. Oh well; I won't fix it.


Aug 03 2008

Formatting in Internet Explorer

Tag: Web Designadmin @ 8:47 pm
I just looked at the blog in IE, and it looks like my <pre> elements mess everything up. They have the CSS set as scroll: auto, but IE doesn't care. Honestly, at this point, I don't care either. This blog is for me to document my thoughts on creating the Young Israel website and anyone is welcome to listen in, but you're far better off in Firefox or Safari anyway.

Aug 03 2008

A jQuery Wordpress plugin

Tag: Web Design, jQueryDanny @ 8:25 pm

The Using Javascript page in the Codex says to include common javascript files in your header.php file, but that means re-writing it whenever you change themes. I created a simple plugin that includes jQuery and ui.jquery on each page; it's

<?php
/*
Plugin Name: jQuery
Plugin URI: http://youngisrael-stl.org/wordpress/
Description: Includes the jQuery javascript framework (and the ui.jquery plugins) in your page, with some styling for <pre> elements
Author: Daniel Wachsstock
Version: 1.0
Author URI: http://youngisrael-stl.org/wordpress/
*/ 

function jQuery(){
echo '
   <script type="text/javascript" src="http://www.google.com/jsapi?key=apikey"></script>
   <script type="text/javascript">google.load("jquery","1");</script>
   <script type="text/javascript" src="http://ui.jquery.com/js/ui.js" ></script>
   <style>
      pre {
        background: #F4F4F4;
        border: 1px solid #B2B2B2;
        overflow: scroll;
      }
    </style>';
}

add_action('wp_head', 'jQuery');

?>

Replace apikey with your own Google API key.


Aug 03 2008

Organizing the Shiur Archives

Tag: Web Designadmin @ 6:53 am
I was trying to figure out how to organize the shiurim in a way that allowed for "AND" filters; something like author=shulman&tag=audio&tanach. Regular expressions won't work; but PHP allows you to use [] after a name and it automatically creates an array, so author=shulman&tag[]=audio&tag[]=tanach works (tag=audio&tag=tanach just overwrites the first tag).
The archive filter is now basically:
function shiurquery($get){
  $ret = '1';
  foreach($get as $query=>$item) $ret .= shiurquerystring($item, $query." REGEXP");
  return $ret;
}

function shiurquerystring ($item, $query){
  if (is_array($item))
    return join (' AND ', array_map ('shiurquerystring', $item, array_fill(0, count($item), $query)));
  return "$query\"$item\"";
}
Where shiurquerystring uses array_map to recursively analyze each element of the array. It's a bit obscure but works, and tighter than a for-each loop.
So shiurquerystring("shulman", "author REGEXP",) returns 'author REGEXP "shulman"' and
shiurquerystring(array("Tanach", "Audio"), "tag REGEXP")
returns 'tag REGEXP "Tanach" AND tag REGEXP "Audio"',
just as we wanted,
and shuirquery(parse_str("author=shulman&tag[]=Audio&tag[]=Tanach") returns
'1 AND author REGEXP "shulman" AND tag REGEXP "Audio" AND tag REGEXP "Tanach'.
Perfect!
The "1 AND" at the beginning makes the coding easier. The actual code is a bit more involved, to prevent cross-site scripting and to limit the filters to specific items.

Dec 08 2007

The new Young Israel site

Tag: Web Designadmin @ 8:15 pm

It’s finally live: the redesigned Young Israel site. So far, the feedback has been all positive, and I figured I’d have more free time once it was done. But nooooooo: I’m going to have to reorganize the shiur archives; with Rabbi Shulman adding 2+ a week, it’s going to add up fast. I like the idea of organizing with tags, but right now the search is with regular expressions. Expressing ‘or’ is easy: tanach|kohelet. But is there a way to do ‘and’ with RE’s? Something like tanach&audio ? I don’t think so. So it’s back to the drawing board.


Nov 06 2007

Maintaining this site, in pictures

Tag: Web DesignDanny @ 8:28 am

’nuff said.

http://irregularwebcomic.net/1736.html


Oct 02 2007

Ajax, Style elements and Safari

Tag: Web DesignDanny @ 12:42 am
As I mentioned before, I don't have access to a modern version of Safari and when I pass an Apple store, I try to play with it and the site. Something always pops up to bite me. This time it was an improved version of my Hebrew keyboard, that I made into a popup, absolutely-positioned <div> instead of a separate page, using sprites for the keyboard button rollovers. Nice and elegant, but it means loading the <style> element with all those a:hover {background: 0 -150px}'s via Ajax as well. Just putting a <style> element in the loaded <div> worked fine in IE and Firefox, but today Safari wouldn't show any styles. Turns out Safari is technically right; <style>'s go in the <head>, not the middle of the <body>. That's a rule that doesn't make any sense, any more than requiring <script> elements to be limited to the <head> would. But such are the rules. I looked up a few ways to include a <style> element, but realized there's an easier way; I split the style into its own stylesheet and added a line to Javascript: $('head').append('<link type="text/css" href="/css/kb.css" rel="stylesheet" >'); before the $('<div id="keyboard-holder">').insertAfter('#q').load('/inc/keyboard.html'); // load via Ajax and now the style loads dynamically and easily. Luckily, jQuery handles identifying and executing <script> elements in Ajax'ed code, so I don't have to pull that out.

Aug 15 2007

Redesign meeting

Tag: Web DesignDanny @ 9:31 pm
Just completed a long meeting about the website, which will be undergoing a major redesign, hopefully before the yomim tovim. The Lubchansky's think we should roll it out all at once, completed, rather than redesign and then recompose, to maximize the impact. So the site will stay as it is. Watch this space for more info!

Aug 09 2007

Redesign!

Tag: Web DesignDanny @ 12:28 pm
I can't claim any talent at design; I just used the old design when I made the YI website. I have help now! A few people who want to remain nameless are helping remake the site into something both more modern-looking and more streamlined, easier to use. As Cameron Moll said, Good Designers Redesign, Great Designers Realign and I certainly think we need a complete realignment, to put the important stuff on the home page and other things back behind (we don't need a list of officers on the front page, and the map, while incredibly cool, slows the initial load time immensely). The plan now is to make it more Wordpress-y (fixed width, site navigation across the top), based on a design by Jenna Smith.

Next Page »