Permalink
Browse files

Intialize resources

  • Loading branch information...
1 parent c6db590 commit 7701c4a322d4f8c27bf51d7b94c49d610ad5a1ac @fredrick committed May 21, 2012
Showing with 108 additions and 2 deletions.
  1. +3 −0 .gitmodules
  2. +45 −0 roots-pjax.js
  3. +36 −0 roots-pjax.php
  4. +4 −2 style.css
  5. +20 −0 templates/page.php
View
@@ -0,0 +1,3 @@
+[submodule "pjax"]
+ path = pjax
+ url = git://github.com/defunkt/jquery-pjax.git
View
@@ -0,0 +1,45 @@
+(function($){
+ $(document).ready(function() {
+ /** Load PJAX on navigation interaction
+ */
+ $('.nav a').pjax('#wrap').click(function() {
+ $('.current-menu-item').removeClass('current-menu-item active');
+ $(this).parent().addClass('current-menu-item active');
+ });
+ /** Watch PJAX requests so metadata in document can be modified dynamically
+ */
+ $('body').bind('pjax:start', function() {
+ $(this).ajaxSuccess(function(event, request, settings) {
+ // CSS template
+ var classes = $(this).attr('class');
+ var template = request.getResponseHeader('X-Thematic-Template');
+ if (classes.indexOf(template) === -1) {
+ $(this).attr('class', classes.replace(/page-template-([^\s]+)/, template));
+ }
+ var link = {
+ canonical: request.getResponseHeader('X-Link-Canonical'),
+ previous: request.getResponseHeader('X-Link-Previous'),
+ next: request.getResponseHeader('X-Link-Next')
+ }
+ var title = {
+ previous: request.getResponseHeader('X-Title-Previous'),
+ next: request.getResponseHeader('X-Title-Next')
+ }
+ // Canonical link
+ $('link[rel="canonical"]').attr('href', link.canonical);
+ // Previous link
+ $('link[rel="prev"]').attr('href', link.previous);
+ $('link[rel="prev"]').attr('title', title.previous);
+ if ($('link[rel="prev"]').length === 0) {
+ $('head').append('<link rel="previous" title="' + title.previous + '" href="' + link.previous + '" />');
+ }
+ // Next link
+ $('link[rel="next"]').attr('href', link.next);
+ $('link[rel="next"]').attr('title', title.next);
+ if ($('link[rel="next"]').length === 0) {
+ $('head').append('<link rel="previous" title="' + title.next + '" href="' + link.next + '" />');
+ }
+ });
+ });
+ });
+})(jQuery);
View
@@ -0,0 +1,36 @@
+<?php
+/**
+ * Thematic PJAX
+ * A Thematic child theme made responsive
+ */
+
+define('ROOTSPJAX_URL', get_bloginfo('stylesheet_directory'));
+
+class ThematicPJAX {
+ public static function load() {
+ wp_enqueue_script('pjax', ROOTSPJAX_URL . '/pjax/jquery.pjax.js', array('jquery'));
+ wp_enqueue_script('thematic-pjax', ROOTSPJAX_URL . '/thematic-pjax.js', array('jquery', 'pjax'));
+ }
+
+ /**
+ * PJAX templates
+ */
+
+ public static function render() {
+ if (array_key_exists('HTTP_X_PJAX', $_SERVER) && $_SERVER['HTTP_X_PJAX']) {
+
+ // Load PJAX template conditionally based on post's template (as defined via Wordpress Administration)
+ global $wp_query;
+ $template_name = get_post_meta( $wp_query->post->ID, '_wp_page_template', true );
+
+ if ($template_name == 'default') {
+ include('templates/page.php');
+ exit;
+ } else {
+ include('templates/' . $template_name);
+ exit;
+ }
+ }
+ }
+}
+?>
View
@@ -5,5 +5,7 @@ Description: WordPress meets HTML5 Boilerplate, Bootstrap, and PJAX, a Roots
Author: Fredrick Galoso
Author URI: http://fredrickgaloso.me/
Template: roots
-Version: 0.1.0
-*/
+Version: 0.1
+*/
+
+@import url('../roots/style.css');
View
@@ -0,0 +1,20 @@
+<?php get_header(); ?>
+ <?php roots_content_before(); ?>
+ <div id="content" class="<?php echo CONTAINER_CLASSES; ?>">
+ <?php roots_main_before(); ?>
+ <div id="main" class="<?php echo MAIN_CLASSES; ?>" role="main">
+ <?php roots_loop_before(); ?>
+ <?php get_template_part('loop', 'page'); ?>
+ <?php roots_loop_after(); ?>
+ </div><!-- /#main -->
+ <?php roots_main_after(); ?>
+ <?php roots_sidebar_before(); ?>
+ <aside id="sidebar" class="<?php echo SIDEBAR_CLASSES; ?>" role="complementary">
+ <?php roots_sidebar_inside_before(); ?>
+ <?php get_sidebar(); ?>
+ <?php roots_sidebar_inside_after(); ?>
+ </aside><!-- /#sidebar -->
+ <?php roots_sidebar_after(); ?>
+ </div><!-- /#content -->
+ <?php roots_content_after(); ?>
+<?php get_footer(); ?>

0 comments on commit 7701c4a

Please sign in to comment.