Permalink
Browse files

添加category、tag页面

  • Loading branch information...
1 parent 530789c commit 3380dfb901ba2ad33300740d9746da103d47d228 @henryyan committed Apr 23, 2012
@@ -0,0 +1,14 @@
+{% if site.safe and site.JB.analytics.provider and page.JB.analytics != false %}
+
+{% case site.JB.analytics.provider %}
+{% when "google" %}
+ {% include JB/analytics-providers/google %}
+{% when "getclicky" %}
+ {% include JB/analytics-providers/getclicky %}
+{% when "mixpanel" %}
+ {% include JB/analytics-providers/mixpanel %}
+{% when "custom" %}
+ {% include custom/analytics %}
+{% endcase %}
+
+{% endif %}
@@ -0,0 +1,12 @@
+<script type="text/javascript">
+var clicky_site_ids = clicky_site_ids || [];
+clicky_site_ids.push({{ site.JB.analytics.getclicky.site_id }});
+(function() {
+ var s = document.createElement('script');
+ s.type = 'text/javascript';
+ s.async = true;
+ s.src = '//static.getclicky.com/js';
+ ( document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0] ).appendChild( s );
+})();
+</script>
+<noscript><p><img alt="Clicky" width="1" height="1" src="//in.getclicky.com/{{ site.JB.analytics.getclicky.site_id }}ns.gif" /></p></noscript>
@@ -0,0 +1,11 @@
+<script type="text/javascript">
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', '{{ site.JB.analytics.google.tracking_id }}']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+</script>
@@ -0,0 +1,11 @@
+<script type="text/javascript">
+ var mpq = [];
+ mpq.push(["init", "{{ site.JB.analytics.mixpanel.token}}"]);
+ (function(){var b,a,e,d,c;b=document.createElement("script");b.type="text/javascript";
+ b.async=true;b.src=(document.location.protocol==="https:"?"https:":"http:")+
+ "//api.mixpanel.com/site_media/js/api/mixpanel.js";a=document.getElementsByTagName("script")[0];
+ a.parentNode.insertBefore(b,a);e=function(f){return function(){mpq.push(
+ [f].concat(Array.prototype.slice.call(arguments,0)))}};d=["init","track","track_links",
+ "track_forms","register","register_once","identify","name_tag","set_config"];for(c=0;c<
+ d.length;c++){mpq[d[c]]=e(d[c])}})();
+</script>
@@ -0,0 +1,37 @@
+{% comment %}<!--
+The categories_list include is a listing helper for categories.
+Usage:
+ 1) assign the 'categories_list' variable to a valid array of tags.
+ 2) include JB/categories_list
+ example:
+ <ul>
+ {% assign categories_list = site.categories %}
+ {% include JB/categories_list %}
+ </ul>
+
+ Notes:
+ Categories can be either a Hash of Category objects (hashes) or an Array of category-names (strings).
+ The encapsulating 'if' statement checks whether categories_list is a Hash or Array.
+ site.categories is a Hash while page.categories is an array.
+
+ This helper can be seen in use at: ../_layouts/default.html
+-->{% endcomment %}
+
+{% if site.JB.categories_list.provider == "custom" %}
+ {% include custom/categories_list %}
+{% else %}
+ {% if categories_list.first[0] == null %}
+ {% for category in categories_list %}
+ <li><a href="{{ BASE_PATH }}{{ site.JB.categories_path }}#{{ category }}-ref">
+ {{ category | join: "/" }} <span>{{ site.categories[category].size }}</span>
+ </a></li>
+ {% endfor %}
+ {% else %}
+ {% for category in categories_list %}
+ <li><a href="{{ BASE_PATH }}{{ site.JB.categories_path }}#{{ category[0] }}-ref">
+ {{ category[0] | join: "/" }} <span>{{ category[1].size }}</span>
+ </a></li>
+ {% endfor %}
+ {% endif %}
+{% endif %}
+{% assign categories_list = nil %}
@@ -0,0 +1,32 @@
+{% comment%}<!--
+The liquid_raw helper is a way to display raw liquid code, as opposed to parsing it.
+Normally you'd use Liquid's built in 'raw' tag.
+The problem is GitHub Jekyll does not support the current Liquid release.
+GitHub Jekyll supports the deprecated 'literal' tag.
+Using one will break the other if you plan to deploy to GitHub pages.
+ see: https://github.com/mojombo/jekyll/issues/425
+
+Since I don't want to mess with Liquid versions, I'll just rewrite the way I
+intend to give liquid examples. It's not an elegant by any means:
+
+Usage:
+ 1) Define a 'text' variable with the block of liquid code you intend to display.
+ 2) Pass the text variable to include JB/liquid_raw
+
+ example:
+ {% capture text %}|.% for tag in tags_list %.|
+ <li><a href="|.{ site.var.tags_path }.||.{ tag[0] }.|-ref">|.{ tag[0] }.| <span>|.{tag[1].size}.|</span></a></li>
+ |.% endfor %.|
+
+ |.% assign tags_list = null %.|{% endcapture %}
+ {% include JB/liquid_raw %}
+
+ As seen here, you must use "|." and ".|" as opening and closing brackets.
+-->{% endcomment%}
+
+{% if site.JB.liquid_raw.provider == "custom" %}
+ {% include custom/liquid_raw %}
+{% else %}
+ <pre><code>{{text | replace:"|.", "&#123;" | replace:".|", "&#125;" | replace:">", "&gt;" | replace:"<", "&lt;" }}</code></pre>
+{% endif %}
+{% assign text = nil %}
@@ -0,0 +1,39 @@
+{% comment %}<!--
+The pages_list include is a listing helper.
+Usage:
+ 1) assign the 'pages_list' variable to a valid array of pages or posts.
+ 2) include JB/pages_list
+ example:
+ <ul>
+ {% assign pages_list = site.pages %}
+ {% include JB/pages_list %}
+ </ul>
+
+ Grouping: (optional):
+ assign the 'group' variable to constrain the list to only pages/posts
+ in the given group. Note you must define the group manually in the page/post
+ meta-data to use this feature.
+ Grouping is mainly helpful for non-post pages.
+ If you want to group posts, it's easier/better to tag them, then pass the tagged posts array.
+ i.e. site.tags.cool_tag (this returns an array of posts tagged: cool_tag)
+
+ This helper can be seen in use at: ../_layouts/default.html
+-->{% endcomment %}
+
+{% if site.JB.pages_list.provider == "custom" %}
+ {% include custom/pages_list %}
+{% else %}
+ {% for node in pages_list %}
+ {% if node.title != null %}
+ {% if group == null or group == node.group %}
+ {% if page.url == node.url %}
+ <li class="active"><a href="{{ BASE_PATH }}{{node.url}}" class="active">{{node.title}}</a></li>
+ {% else %}
+ <li><a href="{{ BASE_PATH }}{{node.url}}">{{node.title}}</a></li>
+ {% endif %}
+ {% endif %}
+ {% endif %}
+ {% endfor %}
+{% endif %}
+{% assign pages_list = nil %}
+{% assign group = nil %}
@@ -0,0 +1,55 @@
+{% comment %}<!--
+Collate_posts helper. Collated posts by year and month.
+Usage:
+ 1) assign the 'posts_collate' variable to a valid array of posts.
+ 2) include JB/posts_collate
+ example:
+ {% assign posts_collate = site.posts %}
+ {% include JB/posts_collate %}
+
+ Ordering:
+ Posts are displayed in reverse chronological order.
+ For normal chronological order:
+ 1) Change the for loop to this:
+ => 'for post in site.posts reversed'
+ 2) Next make sure to change 'post.previous.date' to:
+ => 'post.next.date'
+
+-->{% endcomment %}
+
+{% if site.JB.posts_collate.provider == "custom" %}
+ {% include custom/posts_collate %}
+{% else %}
+ {% for post in posts_collate %}
+ {% capture this_year %}{{ post.date | date: "%Y" }}{% endcapture %}
+ {% capture this_month %}{{ post.date | date: "%B" }}{% endcapture %}
+ {% capture next_year %}{{ post.previous.date | date: "%Y" }}{% endcapture %}
+ {% capture next_month %}{{ post.previous.date | date: "%B" }}{% endcapture %}
+
+ {% if forloop.first %}
+ <h2>{{this_year}}</h2>
+ <h3>{{this_month}}</h3>
+ <ul>
+ {% endif %}
+
+ <li><span>{{ post.date | date: "%B %e, %Y" }}</span> &raquo; <a href="{{ BASE_PATH }}{{ post.url }}">{{ post.title }}</a></li>
+
+ {% if forloop.last %}
+ </ul>
+ {% else %}
+ {% if this_year != next_year %}
+ </ul>
+ <h2>{{next_year}}</h2>
+ <h3>{{next_month}}</h3>
+ <ul>
+ {% else %}
+ {% if this_month != next_month %}
+ </ul>
+ <h3>{{next_month}}</h3>
+ <ul>
+ {% endif %}
+ {% endif %}
+ {% endif %}
+ {% endfor %}
+{% endif %}
+{% assign posts_collate = nil %}
View
@@ -0,0 +1,22 @@
+{% capture jbcache %}
+ <!--
+ - Dynamically set liquid variables for working with URLs/paths
+ -->
+ {% if site.JB.setup.provider == "custom" %}
+ {% include custom/setup %}
+ {% else %}
+ {% if site.safe and site.JB.BASE_PATH and site.JB.BASE_PATH != '' %}
+ {% assign BASE_PATH = site.JB.BASE_PATH %}
+ {% assign HOME_PATH = site.JB.BASE_PATH %}
+ {% else %}
+ {% assign BASE_PATH = nil %}
+ {% assign HOME_PATH = "/" %}
+ {% endif %}
+
+ {% if site.JB.ASSET_PATH %}
+ {% assign ASSET_PATH = site.JB.ASSET_PATH %}
+ {% else %}
+ {% capture ASSET_PATH %}{{ BASE_PATH }}/assets/themes/{{ page.theme.name }}{% endcapture %}
+ {% endif %}
+ {% endif %}
+{% endcapture %}{% assign jbcache = nil %}
@@ -0,0 +1,8 @@
+{% if site.safe and site.JB.sharing.provider and page.JB.sharing != false %}
+
+{% case site.JB.sharing.provider %}
+{% when "custom" %}
+ {% include custom/sharing %}
+{% endcase %}
+
+{% endif %}
@@ -0,0 +1,33 @@
+{% comment %}<!--
+The tags_list include is a listing helper for tags.
+Usage:
+ 1) assign the 'tags_list' variable to a valid array of tags.
+ 2) include JB/tags_list
+ example:
+ <ul>
+ {% assign tags_list = site.tags %}
+ {% include JB/tags_list %}
+ </ul>
+
+ Notes:
+ Tags can be either a Hash of tag objects (hashes) or an Array of tag-names (strings).
+ The encapsulating 'if' statement checks whether tags_list is a Hash or Array.
+ site.tags is a Hash while page.tags is an array.
+
+ This helper can be seen in use at: ../_layouts/default.html
+-->{% endcomment %}
+
+{% if site.JB.tags_list.provider == "custom" %}
+ {% include custom/tags_list %}
+{% else %}
+ {% if tags_list.first[0] == null %}
+ {% for tag in tags_list %}
+ <li><a href="{{ BASE_PATH }}{{ site.JB.tags_path }}#{{ tag }}-ref">{{ tag }} <span>{{ site.tags[tag].size }}</span></a></li>
+ {% endfor %}
+ {% else %}
+ {% for tag in tags_list %}
+ <li><a href="{{ BASE_PATH }}{{ site.JB.tags_path }}#{{ tag[0] }}-ref">{{ tag[0] }} <span>{{ tag[1].size }}</span></a></li>
+ {% endfor %}
+ {% endif %}
+{% endif %}
+{% assign tags_list = nil %}
View
@@ -0,0 +1,22 @@
+---
+layout: master
+title: Categories
+header: Posts By Category
+group: navigation
+---
+{% include JB/setup %}
+
+<ul class="tag_box inline">
+ {% assign categories_list = site.categories %}
+ {% include JB/categories_list %}
+</ul>
+
+
+{% for category in site.categories %}
+ <h2 id="{{ category[0] }}-ref">{{ category[0] | join: "/" }}</h2>
+ <ul>
+ {% assign pages_list = category[1] %}
+ {% include JB/pages_list %}
+ </ul>
+{% endfor %}
+
View
@@ -0,0 +1,21 @@
+---
+layout: master
+title: Tags
+header: Posts By Tag
+group: navigation
+---
+{% include JB/setup %}
+
+<ul class="tag_box inline">
+ {% assign tags_list = site.tags %}
+ {% include JB/tags_list %}
+</ul>
+
+
+{% for tag in site.tags %}
+ <h2 id="{{ tag[0] }}-ref">{{ tag[0] }}</h2>
+ <ul>
+ {% assign pages_list = tag[1] %}
+ {% include JB/pages_list %}
+ </ul>
+{% endfor %}

0 comments on commit 3380dfb

Please sign in to comment.