From 243a6c2f3b81cab949244ac7cf85662c7283082a Mon Sep 17 00:00:00 2001 From: Gabriel Dunne Date: Tue, 22 Jun 2010 23:15:38 -0700 Subject: [PATCH] static generator --- .htaccess | 2 +- css/style.css | 21 ++++---- js/js.js | 0 js/prettify/prettify.css | 18 +++---- lib/data.php | 5 +- lib/init.php | 15 ++++-- lib/output.php | 21 ++++++++ lib/scripts/log | 3 ++ lib/static.php | 107 +++++++++++++++++++++++++++++++++++++++ templates/about.html | 2 +- templates/index.html | 4 +- templates/links.html | 2 +- templates/log.html | 6 +-- templates/nav.html | 5 +- 14 files changed, 175 insertions(+), 36 deletions(-) create mode 100644 js/js.js create mode 100755 lib/scripts/log create mode 100644 lib/static.php diff --git a/.htaccess b/.htaccess index bef083f..a57877b 100644 --- a/.htaccess +++ b/.htaccess @@ -4,6 +4,6 @@ RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f -#RewriteCond %{REQUEST_FILENAME} !-d +RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php [L] diff --git a/css/style.css b/css/style.css index 677585e..f84fab6 100644 --- a/css/style.css +++ b/css/style.css @@ -1,5 +1,6 @@ body { margin:80px 100px 50px 40px; } -html, body, table { font-family: times, helvetica, sans; font-size:15px; line-height:1.3em; color:#999; } +html, body, table { font-family: monaco, monospace; font-size:12px; line-height:1.6em; color:#444; } + .nav { position:absolute; z-index:1; top:20px; left:20px; } .nav ul { margin-left:1em; } @@ -12,18 +13,20 @@ html, body, table { font-family: times, helvetica, sans; font-size:15px; line-he ::selection {background: #08f !important; color:#fff;} /*links*/ -a { color:#555; border:0; padding:0.2em 0.1em 0.1em 0em; font-weight:bold; text-decoration:none; } +a { color:#555; border:0; padding:0.2em 0.1em 0 0; font-weight:bold; } a img { border:0; } -a.mute { } -a:hover, a.mute:hover { color:#d15; border-bottom:2px solid #d15; text-decoration:none; } +a.mute { text-decoration:none !important; } +a:hover, a.mute:hover { color:#d15; } /*headings*/ -h1, h2, h3, h4, h5, h6 { font-size:1.3em; } +h1, h2, h3, h4, h5, h6 { font-size:1.2em; } h1 a, h2 a, h3 a, h4 a, h5 a, h6 a { text-decoration:none; } h1 { margin:0 0 3em 0; font-size:2em;} h2 { margin:4em 0 0.5em 0; } h3 { margin:0 0 0 0; } +ol li { list-style-type:decimal; } + blockquote { font-family:times; background:#000; color:#aaa; margin:0; font-size:15px; line-height:1.4em; padding:2em 4em; font-style:italic; line-height:1.45em; max-width:600px;} @@ -52,7 +55,7 @@ table .reader li, table .bookmarks li { margin-bottom:1em; padding-bottom:1em; ul.inline_content {} ul.inline_content li .content { } ul.inline_content li { margin:0 0 150px 0; } - ul.inline_content li h3 { border-bottom:2px solid #ddd; } + ul.inline_content li h3 { margin-bottom:1em; border-bottom:1px solid #ddd; padding-bottom:4px; } ul.inline_content ol li { margin:0; padding:0; border:0;} ul.thumbnails { } ul.thumbnails li { display:inline-block; margin: 0px 60px 60px 0px; } @@ -67,8 +70,8 @@ table .reader li, table .bookmarks li { margin-bottom:1em; padding-bottom:1em; ul.thumbnails .title { } .date { color:#ccc;} - .func { margin-bottom:2em; } - .func a { background:#daa; padding:0.2em 1em 0.02em 1em; font-size:9px; text-transform:uppercase;} + .func { margin-bottom:2em; } + .func a { background:#daa; padding:0.2em 1em 0.02em 1em; font-size:9px; text-transform:uppercase;} .text { font-family:serif; font-size:15px; line-height:2.2em; margin-top:80px;} .indent { text-indent:3em; } @@ -83,5 +86,3 @@ table .reader li, table .bookmarks li { margin-bottom:1em; padding-bottom:1em; #footer { margin-top:120px; } #footer .copy a { text-decoration:none; } - - diff --git a/js/js.js b/js/js.js new file mode 100644 index 0000000..e69de29 diff --git a/js/prettify/prettify.css b/js/prettify/prettify.css index 87ec1af..f38550c 100755 --- a/js/prettify/prettify.css +++ b/js/prettify/prettify.css @@ -1,21 +1,21 @@ /* Pretty printing styles. Used with prettify.js. */ .str { color: #f26; } -.kwd { color: #444; font-weight:bold; } +.kwd { color: #99f; font-weight:bold; } .com { color: #888; font-style:italic; } -.typ { color: #606; } -.lit { color: #066; } -.pun { color: #660; } -.pln { color: #444; } +.typ { color: #f0f; } +.lit { color: #099; } +.pun { color: #66d; } +.pln { color: #ffd; } .tag { color: #008; } .atn { color: #606; } .atv { color: #080; } .dec { color: #606; } -pre.prettyprint, code.prettyprint { font-family:monaco, "Lucida Console", monospace; font-size:11px; line-height:1.6em; padding:0.3em 0.5em; background:#e9e9e9; --moz-border-radius: 4px; --webkit-border-radius: 4px; +pre.prettyprint, code.prettyprint { font-family:monaco, "Lucida Console", monospace; font-size:12px; line-height:2em; padding:0.4em 0.6em; background:#322323; +-moz-border-radius: 8px; +-webkit-border-radius: 8px; } -pre.prettyprint { padding:20px; } +pre.prettyprint { padding:20px; line-height:1.4em; } @media print { .str { color: #060; } diff --git a/lib/data.php b/lib/data.php index 6d0f23d..df82852 100644 --- a/lib/data.php +++ b/lib/data.php @@ -20,15 +20,16 @@ $content = array(); $glob = glob( CONTENT_DIR . $path . '/*' ); + foreach ($glob as $c) { if (is_file($c . $config) || is_dir($c . $config)) { $config_array = parse_config($c . $config); if ($config_array['title'] && $config_array['hide'] != "true") { $content[] = $config_array; - } + } } - } + } return array(array_reverse($content), count($content)); } diff --git a/lib/init.php b/lib/init.php index b7599d4..7807a17 100644 --- a/lib/init.php +++ b/lib/init.php @@ -1,9 +1,18 @@ [\w+\.\-]+?)\s*=\s*(?P.+?)\s*$/", $line, $match ); + if( $statement ) { + $key = $match[ 'key' ]; + $value = $match[ 'value' ]; + # Remove quote + if( preg_match( "/^\".*\"$/", $value ) || preg_match( "/^'.*'$/", $value ) ) { + $value = mb_substr( $value, 1, mb_strlen( $value ) - 2 ); + } + $array[ $key ] = $value; + } + } + return $array; + } + } function get_url_parts() diff --git a/lib/scripts/log b/lib/scripts/log new file mode 100755 index 0000000..d3f5eb2 --- /dev/null +++ b/lib/scripts/log @@ -0,0 +1,3 @@ +FILE=$(date +%Y"-"%m"-"%d_$1) +echo -e "title = $1\ndate = `date +%Y"-"%m"-"%d`\nhide = true\n--\n\n" > $FILE +emacs $FILE \ No newline at end of file diff --git a/lib/static.php b/lib/static.php new file mode 100644 index 0000000..efb18fa --- /dev/null +++ b/lib/static.php @@ -0,0 +1,107 @@ +'; + foreach ($entries as $e) + { + echo '
  • '.$e['title'].' - '.$e['date'].'
  • '; + } + echo ''; + + + # parse inline content + function get_inline_entries( $sources ) + { + $result = array(); + $result_total = 0; + foreach ($sources as $dir) { + $contents = glob(LOCAL_ROOT . CONTENT_DIR . $dir . '/*'); + foreach ($contents as $f) { + if (!is_dir($f)) { + $file_contents = explode("\n", file_get_contents($f, FILE_USE_INCLUDE_PATH)); + $cc = ""; + $content = ""; + $conf = true; + foreach ( $file_contents as $fc ) { + if ($fc == CONFIG_DELIMITER) { + $conf = false; + continue; + } + if ($conf) $cc .= $fc . "\n"; + else $content .= $fc . "\n"; + } + $config = parse_ini_string($cc); + + $config['url'] = WEB_ROOT . $dir . DIRECTORY_SEPARATOR . basename($f); + $config['timestamp'] = mktime($config['date']); + $config['category'] = $dir; + $config['content'] = $content; + $config['tags'] = explode(' ', $config['tags']); + + $result[] = $config; + $result_total++; + } + } + } + + // order by date + foreach ($result as $key => $row) { + $time[$key] = $row['date']; + } + array_multisort($time, SORT_DESC, $result); + + return array($result, $result_total); + } + + + + $files = glob('../content/log/*'); + + $result = array(); + $result['count'] = 0; + foreach ($files as $f) + { + if (!is_dir($f)) { + + $config_settings = explode("\n", file_get_contents($f, FILE_USE_INCLUDE_PATH)); + + $cc = ""; + $content = ""; + $past_conf = false; + foreach ( $config_settings as $c ) { + if ($c == CONFIG_DELIMITER) { + $past_conf = true; + continue; + } + if ($past_conf) $content .= $c . "\n"; + else $cc .= $c . "\n"; + } + $config = parse_ini_string($cc); + $config['content'] = $content; + + if ($config['hide'] == 'true') + continue; + + $result['count'] += 1; + $result['entries'][] = $config; + +// print_r($cc); +// echo "content: " . $content; + +// echo $config; +// echo "\n"; + } + } + +// echo json_encode($result); + +// print_r($entries); + + + + + +?> \ No newline at end of file diff --git a/templates/about.html b/templates/about.html index e58377b..21784ec 100644 --- a/templates/about.html +++ b/templates/about.html @@ -18,7 +18,7 @@

    - quilime is a continually growing codification of exploration, resource, and creativity. + quilime is a codification of exploration, resources, and creativity.

    author: gabriel dunne (email, www) diff --git a/templates/index.html b/templates/index.html index 100c4a0..07d581d 100644 --- a/templates/index.html +++ b/templates/index.html @@ -13,8 +13,6 @@

    - <--- navigation -
    - +<--- nav diff --git a/templates/links.html b/templates/links.html index 50f7b45..55a769d 100644 --- a/templates/links.html +++ b/templates/links.html @@ -25,7 +25,7 @@ function linklist($links) { ?> -
  • +
  • - + - [] + []

    diff --git a/templates/nav.html b/templates/nav.html index 411f641..57688ba 100644 --- a/templates/nav.html +++ b/templates/nav.html @@ -1,9 +1,8 @@ -- 2.34.1