Skip to content
Browse files

first commit

  • Loading branch information...
0 parents commit 5bf0e046058718405a876525607f1b02d7c99960 @naoya committed Apr 29, 2012
Showing with 1,333 additions and 0 deletions.
  1. +1 −0 .meteor/.gitignore
  2. +9 −0 .meteor/packages
  3. +29 −0 diary-css.coffee
  4. +94 −0 diary-css.html
  5. +777 −0 diary-css.js
  6. +423 −0 diary-css.less
1 .meteor/.gitignore
@@ -0,0 +1 @@
+local
9 .meteor/packages
@@ -0,0 +1,9 @@
+# Meteor packages used by this project, one per line.
+#
+# 'meteor add' and 'meteor remove' will edit this file for you,
+# but you can also edit it by hand.
+
+autopublish
+coffeescript
+less
+jquery
29 diary-css.coffee
@@ -0,0 +1,29 @@
+@Entries = new Meteor.Collection 'entries'
+
+if Meteor.is_client
+ Meteor.startup () ->
+
+ Template.admin.events =
+ 'click button' : (event) ->
+ t = $('#text')
+ if t.val()?
+ Entries.insert
+ text: t.val()
+ created_at: Date.now()
+ t.val("")
+
+ Template.diary.diary = () ->
+ title: "Naoya's Hatena Diary"
+ url: 'http://d.hatena.ne.jp/naoya/'
+ description: 'naoyaのはてなダイアリー'
+
+ Template.entries.hatenafy = (text) ->
+ hatena = new Hatena sectionanchor : ""
+ hatena.parse text
+ return hatena.html()
+
+ Template.entries.entries = () ->
+ return Entries.find {}, { sort: {created_at: -1} }
+
+if Meteor.is_server
+ Meteor.startup () ->
94 diary-css.html
@@ -0,0 +1,94 @@
+<head>
+ <title>diary-css</title>
+</head>
+
+<body>
+ {{> header}}
+ {{> diary}}
+ {{> footer}}
+ {{> admin}}
+</body>
+
+<template name="header">
+ <div id="simple-header">
+ <a href=""><img src="http://d.hatena.ne.jp/images/hatena-simple_de.gif" id="logo-hatena" width="65" height="17" /></a><a href=""><img src="http://d.hatena.ne.jp/images/diary-simple_de.gif" id="logo-diary" width="43" height="17" /></a>
+ <form method="get" action="" class="search-form">
+ <input type="text" class="search-word" name="word" />
+ <input type="submit" class="search-button" name="diary" value="日記" />
+ <input type="submit" class="search-button" name="submit" value="検索" />
+ <ul class="menu">
+ <li><a href="">ブログトップ</a></li>
+ <li><a href="">記事一覧</a></li>
+ <li><a href="">記事を書</a></li>
+ <li><a href="">管理</a></li>
+ <li><a href="">ログアウト</a></li>
+ <li><a href="">ヘルプ</a></li>
+ </ul>
+ </form>
+ </div>
+</template>
+
+<template name="admin">
+ <div id="admin">
+ <textarea id="text"></textarea>
+ <button>記事追加</button>
+ </div>
+</template>
+
+<template name="diary">
+ {{#with diary}}
+ <h1><a href="">{{title}}</a></h1>
+ <div class="hatena-body">
+ <p class="description">{{description}}</p>
+ <div class="main">
+ <div class="calendar" id="pager-top">
+ <a rel="prev" href="/naoya/?of=5" class="prev">&lt;前の5日分</a>&nbsp;<span id="edit-in-place-add"></span>
+ </div><!-- .calendar -->
+
+ <div id="days">
+ {{> entries}}
+ </div><!-- #days -->
+
+ <div class="calendar" id="pager-bottom">
+ <a rel="prev" href="/naoya/?of=5" class="prev">&lt;前の5日分</a>&nbsp;<span id="edit-in-place-add"></span>
+ </div><!-- .calendar -->
+
+ </div><!-- .main -->
+ </div><!-- hatena-body -->
+ {{/with}}
+</template>
+
+<template name="entries">
+
+ <div class="day">
+ <h2><a href="/naoya/20111111"><span class="date">November 11, 2011</span></a> <a href="" class="edit">編集</a></h2>
+ <div class="body">
+ {{#each entries}}
+ {{{hatenafy text}}}
+ {{/each}}
+ </div><!-- body -->
+ </div><! -- day -->
+
+</template>
+
+<template name="footer">
+ <div id="footer">
+ <div class="footer-wrapper">
+ <div class="footer-section">
+ <div id="footer-column01">
+ <a href="/about"><img src="http://www.st-hatena.com/users/na/naoya/user.jpg" alt="Naoya Ito" title="Naoya Ito" /></a>
+ </div>
+ <div id="footer-column02">
+ <h2>Naoya Ito</h2>
+ <h3><a href="http://d.hatena.ne.jp/naoya/about">id:naoya</a></h3>
+ <ul>
+ <li><a href="http://twitter.com/naoya_ito">Twitter</a> | </li>
+ <li><a href="https://github.com/naoya">github</a> | </li>
+ <li><a href="http://www.flickr.com/photos/naoya1977/">Flickr</a> |</li>
+ <li><a href="http://b.hatena.ne.jp/naoya/">はてなブックマーク</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+</template>
777 diary-css.js
@@ -0,0 +1,777 @@
+if (Meteor.is_client) {
+ // copied from text-hatena.js : http://tech.nitoyon.com/javascript/application/texthatena/download.html
+ // from prototype.js
+ Object.extend = function(destination, source) {
+ for (property in source) {
+ destination[property] = source[property];
+ }
+ return destination;
+ }
+
+ String.times = function(str, time){
+ var s = "";
+ for(var i = 0; i < time; i++)s += "\t";
+ return s;
+ }
+
+ String._escapeHTML = function(s){
+ s = s.replace(/\&/g, "&amp;");
+ s = s.replace(/</g, "&lt;");
+ s = s.replace(/>/g, "&gt;");
+ s = s.replace(/"/g, "&quot;");
+ s = s.replace(/\'/g, "&#39");
+ s = s.replace(/\\/g, "&#92");
+ return s;
+ }
+
+ String._unescapeHTML = function(s){
+ s = s.replace(/&amp;/g, "&");
+ s = s.replace(/&lt;/g, "<");
+ s = s.replace(/&gt;/g, ">");
+ s = s.replace(/&quot;/g, "\"");
+ return s;
+ }
+
+
+ // Hatena::Hatena_HTMLFilter
+ Hatena_HTMLFilter = function(args){
+ this.self = {
+ context : args["context"],
+ html : ''
+ };
+ this.init();
+ }
+ Hatena_HTMLFilter.prototype = {
+ init :function(){
+ // HTML::Parser を利用すべきなんだけど JavaScript ではなんとも...
+ },
+
+ parse : function(html){
+ var c = this.self.context;
+ this.self.html = c.self.texthandler(html, c);
+ },
+
+ html : function(){
+ return this.self.html;
+ }
+ }
+
+
+ // Hatena
+ Hatena = function(args){
+ if(args == null) args = {};
+ this.self = {
+ html : '',
+ baseuri : args["baseuri"],
+ permalink : args["permalink"] || "",
+ ilevel : args["ilevel"] || 0,
+ invalidnode : args["invalidnode"] || [],
+ sectionanchor : args["sectionanchor"] || 'o-',
+ texthandler : args["texthandler"] || function(text, c){
+ // footnote
+ var p = c.self.permalink;
+ var html = "";
+ var foot = text.split("((");
+ for(var i = 0; i < foot.length; i++){
+ if(i == 0){
+ html += foot[i];
+ continue;
+ }
+ var s = foot[i].split("))", 2);
+ if(s.length != 2){
+ html += "((" + foot[i];
+ continue;
+ }
+ var pre = foot[i - i];
+ var note = s[0];
+ var post = foot[i].substr(s[0].length + 2);
+ if(pre.match(/\)$/) && post.match(/^\(/)){
+ html += "((" + post;
+ } else {
+ var notes = c.footnotes(note);
+ var num = notes.length;
+ note = note.replace(/<.*?>/g, "");
+ note = note.replace(/&/g, "&amp;");
+ html += '<span class="footnote"><a href="' + p + '#f' + num + '" title="' + note + '" name="fn' + num + '">*' + num + '</a></span>' + post;
+ }
+ }
+ return html;
+ }
+ };
+ }
+ Hatena.prototype = {
+ parse : function(text){
+ this.self.context = new Hatena_Context({
+ text : text || "",
+ baseuri : this.self.baseuri,
+ permalink : this.self.permalink,
+ invalidnode : this.self.invalidnode,
+ sectionanchor : this.self.sectionanchor,
+ texthandler : this.self.texthandler
+ });
+ var c = this.self.context;
+ var node = new Hatena_BodyNode();
+ node._new({
+ context : c,
+ ilevel : this.self.ilevel
+ });
+ node.parse();
+ var parser = new Hatena_HTMLFilter({
+ context : c
+ });
+ parser.parse(c.html());
+ this.self.html = parser.html();
+
+ if (this.self.context.footnotes().length != 0) {
+ var node = new Hatena_FootnoteNode();
+ node._new({
+ context : this.self.context,
+ ilevel : this.self.ilevel
+ });
+ node.parse();
+ this.self.html += "\n";
+ this.self.html += node.self.html;
+ }
+ },
+
+ html : function(){
+ return this.self.html;
+ }
+ }
+
+
+ // Hatena::Context
+ Hatena_Context = function(args){
+ this.self = {
+ text : args["text"],
+ baseuri : args["baseuri"],
+ permalink : args["permalink"],
+ invalidnode : args["invalidnode"],
+ sectionanchor : args["sectionanchor"],
+ texthandler : args["texthandler"],
+ _htmllines : [],
+ footnotes : Array(),
+ sectioncount : 0,
+ syntaxrefs : [],
+ noparagraph : 0
+ };
+ this.init();
+ }
+ Hatena_Context.prototype = {
+ init : function() {
+ this.self.text = this.self.text.replace(/\r/g, "");
+ this.self.lines = this.self.text.split('\n');
+ this.self.index = -1;
+ },
+
+ hasnext : function() {
+ return (this.self.lines != null && this.self.lines.length - 1 > this.self.index);
+ },
+
+ nextline : function() {
+ return this.self.lines[this.self.index + 1];
+ },
+
+ shiftline : function() {
+ return this.self.lines[++this.self.index];
+ },
+
+ currentline : function() {
+ return this.self.lines[this.self.index];
+ },
+
+ html : function() {
+ return this.self._htmllines.join ("\n");
+ },
+
+ htmllines : function(line) {
+ if(line != null) this.self._htmllines.push(line);
+ return this.self._htmllines;
+ },
+
+ lasthtmlline : function() {return this.self._htmllines[this.self._htmllines.length - 1]; },
+
+ footnotes : function(line) {
+ if(line != null) this.self.footnotes.push(line);
+ return this.self.footnotes;
+ },
+
+ syntaxrefs : function(line) {
+ if(line != null) this.self.syntaxrefs.push(line);
+ return this.self.syntaxrefs;
+ },
+
+ syntaxpattern : function(pattern) {
+ if(pattern != null) this.self.syntaxpattern = pattern;
+ return this.self.syntaxpattern;
+ },
+
+ noparagraph : function(noparagraph) {
+ if(noparagraph != null) this.self.noparagraph = noparagraph;
+ return this.self.noparagraph;
+ },
+
+ incrementsection : function() {
+ return this.self.sectioncount++;
+ }
+ }
+
+
+ // Hatena::Node
+ Hatena_Node = function(){}
+ Hatena_Node.prototype = {
+ html : "",
+ pattern : "",
+
+ _new : function(args){
+ if(args == null) args = Array();
+ this.self = {
+ context : args["context"],
+ ilevel : args["ilevel"],
+ html : ''
+ };
+ this.init();
+ },
+ init : function(){
+ this.self.pattern = '';
+ },
+
+ parse : function(){ alert('die'); },
+
+ context : function(v){
+ this.self.context = v;
+ }
+ };
+
+
+ // Hatena::BodyNode
+ Hatena_BodyNode = function(){};
+ Hatena_BodyNode.prototype = Object.extend(new Hatena_Node(), {
+ parse : function(){
+ var c = this.self.context;
+ while (this.self.context.hasnext()) {
+ var node = new Hatena_SectionNode();
+ node._new({
+ context : c,
+ ilevel : this.self.ilevel
+ });
+ node.parse();
+ }
+ }
+ })
+
+
+ // Hatena::BrNode
+ Hatena_BrNode = function(){};
+ Hatena_BrNode.prototype = Object.extend(new Hatena_Node(), {
+ parse : function(){
+ var c = this.self.context;
+ var l = c.shiftline();
+ if(l.length != 0) return;
+ var t = String.times("\t", this.self.ilevel);
+ if (c.lasthtmlline() == t + "<br>" || c.lasthtmlline() == t) {
+ c.htmllines(t + "<br>");
+ } else {
+ c.htmllines(t);
+ }
+ }
+ })
+
+
+ // Hatena::CDataNode
+ Hatena_CDataNode = function(){};
+ Hatena_CDataNode.prototype = Object.extend(new Hatena_Node(), {
+ parse : function(){
+ var c = this.self.context;
+ var t = String.times("\t", this.self.ilevel);
+ var l = c.shiftline();
+ var text = new Hatena_Text();
+ text._new({context : c});
+ text.parse(l);
+ l = text.html();
+ c.htmllines(t + l);
+ }
+ })
+
+
+ // Hatena::DlNode
+ Hatena_DlNode = function(){};
+ Hatena_DlNode.prototype = Object.extend(new Hatena_Node(), {
+ init : function(){
+ this.self.pattern = /^\:((?:<[^>]+>|\[\].+?\[\]|\[[^\]]+\]|\[\]|[^\:<\[]+)+)\:(.+)$/;
+ },
+
+ parse : function(){
+ var c = this.self.context;
+ var l = c.nextline();
+ if(!l.match(this.self.pattern)) return;
+ this.self.llevel = RegExp.$1.length;
+ var t = String.times("\t", this.self.ilevel);
+
+ c.htmllines(t + "<dl>");
+ while (l = c.nextline()) {
+ if(!l.match(this.self.pattern)) break;
+ c.shiftline();
+ c.htmllines(t + "\t<dt>" + RegExp.$1 + "</dt>");
+ c.htmllines(t + "\t<dd>" + RegExp.$2 + "</dd>");
+ }
+ c.htmllines(t + "</dl>");
+ }
+ })
+
+
+ // Hatena::FootnoteNode
+ Hatena_FootnoteNode = function(){};
+ Hatena_FootnoteNode.prototype = Object.extend(new Hatena_Node(), {
+ html : "",
+
+ parse : function(){
+ var c = this.self["context"];
+ if(c.self.footnotes == null || c.self.footnotes.length == 0) return;
+ var t = String.times("\t", this.self["ilevel"]);
+ var p = c.self.permalink;
+ this.self["html"] = '';
+
+ this.self.html += t + '<div class="footnote">\n';
+ var num = 0;
+ var text = new Hatena_Text();
+ text._new({context : c});
+ for(var i = 0; i < c.self.footnotes.length; i++) {
+ var note = c.self.footnotes[i];
+ num++;
+ text.parse(note);
+ var l = t + '\t<p class="footnote"><a href="' + p + '#fn' + num + '" name="f' + num + '">*' + num + '</a>: '
+ + text.html() + '</p>';
+ this.self["html"] += l + "\n";
+ }
+ this.self["html"] += t + '</div>\n';
+ }
+ })
+
+
+ // Hatena::H3Node
+ Hatena_H3Node = function(){};
+ Hatena_H3Node.prototype = Object.extend(new Hatena_Node(), {
+ init : function(){
+ this.self.pattern = /^\*(?:(\d{9,10}|[a-zA-Z]\w*)\*)?((?:\[[^\:\[\]]+\])+)?(.*)$/;
+ },
+
+ parse : function(){
+ var c = this.self.context;
+ var l = c.shiftline();
+ if(l == null) return;
+ if(!l.match(this.self.pattern)) return;
+ var name = RegExp.$1;
+ var cat = RegExp.$2;
+ var title = RegExp.$3;
+ var b = c.self.baseuri;
+ var p = c.self.permalink;
+ var t = String.times("\t", this.self.ilevel);
+ var sa = c.self.sectionanchor;
+
+ /* TODO: カテゴリは未対応
+ if (cat) {
+ if(cat.match(/\[([^\:\[\]]+)\]/)){ // 繰り返しできないなぁ...
+ var w = RegExp.$1;
+ var ew = escape(RegExp.$1);
+ cat = cat.replace(/\[([^\:\[\]]+)\]/, '[<a class="sectioncategory" href="' + b + '?word=' + ew + '">' + w + '</a>]');
+ }
+ }*/
+ var extra = '';
+ var ret = this._formatname(name);
+ var name = (ret[0] != undefined ? ret[0] : ""); extra = (ret[1] != undefined ? ret[1] : "");
+ c.htmllines(t + '<h3><a href="' + p + '#' + name + '" name="' + name + '"><span class="sanchor">' + sa + '</span></a> ' + cat + title + '</h3>' + extra);
+ },
+
+ _formatname : function(name){
+ /* TODO: 時間も未対応。表示時の時間が表示されてしまう...
+ if (name && name.match(/^\d{9,10}$/)) {
+ var m = sprintf('%02d', (localtime($name))[1]);
+ var h = sprintf('%02d', (localtime($name))[2]);
+ return (
+ $name,
+ qq| <span class="timestamp">$h:$m</span>|,
+ );
+ } elsif ($name) {*/
+ if(name != ""){
+ return [name];
+ } else {
+ this.self.context.incrementsection();
+ name = 'p' + this.self.context.self.sectioncount;
+ return [name];
+ }
+ }
+ })
+
+
+ // Hatena::H4Node
+ Hatena_H4Node = function(){};
+ Hatena_H4Node.prototype = Object.extend(new Hatena_Node(), {
+ init : function(){
+ this.self.pattern = /^\*\*((?:[^\*]).*)$/;
+ },
+
+ parse : function(){
+ var c = this.self.context;
+ var l = c.shiftline();
+ if(l == null) return;
+ if(!l.match(this.self.pattern)) return;
+ var t = String.times("\t", this.self.ilevel);
+ c.htmllines(t + "<h4>" + RegExp.$1 + "</h4>");
+ }
+ })
+
+
+ // Hatena::H5Node
+ Hatena_H5Node = function(){};
+ Hatena_H5Node.prototype = Object.extend(new Hatena_Node(), {
+ init : function(){
+ this.self.pattern = /^\*\*\*((?:[^\*]).*)$/;
+ },
+
+ parse : function(){
+ var c = this.self.context;
+ var l = c.shiftline();
+ if(l == null) return;
+ if(!l.match(this.self.pattern)) return;
+ var t = String.times("\t", this.self.ilevel);
+ c.htmllines(t + "<h5>" + RegExp.$1 + "</h5>");
+ }
+ })
+
+
+ // Hatena::ListNode
+ Hatena_ListNode = function(){};
+ Hatena_ListNode.prototype = Object.extend(new Hatena_Node(), {
+ init : function(){
+ this.self.pattern = /^([\-\+]+)([^>\-\+].*)$/;
+ },
+
+ parse : function(){
+ var c = this.self.context;
+ var l = c.nextline();
+ if(!l.match(this.self.pattern)) return;
+ this.self.llevel = RegExp.$1.length;
+ var t = String.times("\t", this.self.ilevel + this.self.llevel - 1);
+ this.self.type = RegExp.$1.substr(0, 1) == '-' ? 'ul' : 'ol';
+
+ c.htmllines(t + "<" + this.self.type + ">");
+ while (l = c.nextline()) {
+ if(!l.match(this.self.pattern)) break;
+ if (RegExp.$1.length > this.self.llevel) {
+ //c.htmllines(t + "\t<li>"); bug??
+ var node = new Hatena_ListNode();
+ node._new({
+ context : this.self.context,
+ ilevel : this.self.ilevel
+ });
+ node.parse();
+ //c.htmllines(t + "\t</li>"); bug??
+ } else if(RegExp.$1.length < this.self.llevel) {
+ break;
+ } else {
+ l = c.shiftline();
+ c.htmllines(t + "\t<li>" + RegExp.$2 + "</li>");
+ }
+ }
+ c.htmllines(t + "</" + this.self.type + ">");
+ }
+ })
+
+
+ // Hatena::PNode
+ Hatena_PNode = function(){};
+ Hatena_PNode.prototype = Object.extend(new Hatena_Node(), {
+ parse :function(){
+ var c = this.self.context;
+ var t = String.times("\t", this.self.ilevel);
+ var l = c.shiftline();
+ var text = new Hatena_Text();
+ text._new({context : c});
+ text.parse(l);
+ l = text.html();
+ c.htmllines(t + "<p>" + l + "</p>");
+ }
+ });
+
+
+ // Hatena::PreNode
+ Hatena_PreNode = function(){};
+ Hatena_PreNode.prototype = Object.extend(new Hatena_Node(), {
+ init :function(){
+ this.self.pattern = /^>\|$/;
+ this.self.endpattern = /(.*)\|<$/;
+ this.self.startstring = "<pre>";
+ this.self.endstring = "</pre>";
+ },
+
+ parse : function(){
+ c = this.self.context;
+ if(!c.nextline().match(this.self.pattern)) return;
+ c.shiftline();
+ var t = String.times("\t", this.self.ilevel);
+ c.htmllines(t + this.self.startstring);
+ var x = '';
+ while (c.hasnext()) {
+ var l = c.nextline();
+ if (l.match(this.self.endpattern)) {
+ var x = RegExp.$1;
+ c.shiftline();
+ break;
+ }
+ c.htmllines(this.escape_pre(c.shiftline()));
+ }
+ c.htmllines(x + this.self.endstring);
+ },
+
+ escape_pre : function(text){ return text; }
+ })
+
+
+ // Hatena::SuperpreNode
+ Hatena_SuperpreNode = function(){};
+ Hatena_SuperpreNode.prototype = Object.extend(new Hatena_PreNode(), {
+ init : function(){
+ this.self.pattern = /^>\|\|$/;
+ this.self.endpattern = /^\|\|<$/;
+ this.self.startstring = "<pre>";
+ this.self.endstring = "</pre>";
+ },
+
+ escape_pre : function(s){
+ return String._escapeHTML(s);
+ }
+ })
+
+
+ // Hatena::SuperpreNode
+ Hatena_TableNode = function(){};
+ Hatena_TableNode.prototype = Object.extend(new Hatena_Node(), {
+ init : function(){
+ this.self.pattern = /^\|([^\|]*\|(?:[^\|]*\|)+)$/;
+ },
+
+ parse : function(s){
+ var c = this.self.context;
+ var l = c.nextline();
+ if(!l.match(this.self.pattern)) return;
+ var t = String.times("\t", this.self.ilevel);
+
+ c.htmllines(t + "<table>");
+ while (l = c.nextline()) {
+ if(!l.match(this.self.pattern)) break;
+ l = c.shiftline();
+ c.htmllines(t + "\t<tr>");
+ var td = l.split("|");
+ td.pop(); td.shift();
+ for (var i = 0; i < td.length; i++) {
+ var item = td[i];
+ if (item.match(/^\*(.*)/)) {
+ c.htmllines(t + "\t\t<th>" + RegExp.$1 + "</th>");
+ } else {
+ c.htmllines(t + "\t\t<td>" + item + "</td>");
+ }
+ }
+ c.htmllines(t + "\t</tr>");
+ }
+ c.htmllines(t + "</table>");
+ }
+ })
+
+
+ // Hatena::Section
+ Hatena_SectionNode = function(){};
+ Hatena_SectionNode.prototype = Object.extend(new Hatena_Node(), {
+ init : function(){
+ this.self.childnode = ["h5", "h4", "h3", "blockquote", "dl", "list", "pre", "superpre", "table", "tagline", "tag"];
+ this.self.startstring = '<div class="section">';
+ this.self.endstring = '</div>';
+ this.self.child_node_refs = Array();
+ },
+
+ parse : function(){
+ var c = this.self.context;
+ var t = String.times("\t", this.self.ilevel);
+ this._set_child_node_refs();
+ c.htmllines(t + this.self.startstring);
+ while (c.hasnext()) {
+ var l = c.nextline();
+ var node = this._findnode(l);
+ if(node == null) return;
+ // TODO: ref == instanceof ???
+ //if (ref(node) eq 'Hatena_H3Node') {
+ // if(this.self.started++) break;
+ //}
+ node.parse();
+ }
+ c.htmllines('<p class="sectionfooter"><a href="">Permalink</a> | <a href="">コメント(0)</a> | <a href="">トラックバック</a> | 19:12</p>');
+ c.htmllines(t + this.self.endstring);
+ },
+
+ _set_child_node_refs : function(){
+ var c = this.self.context;
+ var nodeoption = {
+ context : c,
+ ilevel : this.self.ilevel + 1
+ };
+ var invalid = Array();
+ if(c.self.invalidnode) invalid[c.self.invalidnode] = Array();
+ for(var i = 0; i < this.self.childnode.length; i++) {
+ var node = this.self.childnode[i];
+ if(invalid[node]) continue;
+ var mod = 'Hatena_' + node.charAt(0).toUpperCase() + node.substr(1).toLowerCase() + 'Node';
+ var n = eval("new "+ mod +"()");
+ n._new(nodeoption);
+ this.self.child_node_refs.push(n);
+ }
+ },
+
+ _findnode : function(l){
+ for(var i = 0; i < this.self.child_node_refs.length; i++) {
+ var node = this.self.child_node_refs[i];
+ var pat = node.self.pattern;
+ if(pat == null) continue;
+ if (l.match(pat)) {
+ return node;
+ }
+ }
+ var nodeoption = {
+ context : this.self.context,
+ ilevel : this.self.ilevel + 1
+ };
+ if (l.length == 0) {
+ var node = new Hatena_BrNode(nodeoption);
+ node._new(nodeoption);
+ return node;
+ } else if (this.self.context.noparagraph()) {
+ var node = new Hatena_CDataNode();
+ node._new(nodeoption);
+ return node;
+ } else {
+ var node = new Hatena_PNode;
+ node._new(nodeoption);
+ return node;
+ }
+ }
+ })
+
+
+ // Hatena::BrockquoteNode
+ Hatena_BlockquoteNode = function(){};
+ Hatena_BlockquoteNode.prototype = Object.extend(new Hatena_SectionNode(), {
+ init : function(){
+ this.self.pattern = /^>>$/;
+ this.self.endpattern = /^<<$/;
+ this.self.childnode = ["h4", "h5", "blockquote", "dl", "list", "pre", "superpre", "table"];//, "tagline", "tag"];
+ this.self.startstring = "<blockquote>";
+ this.self.endstring = "</blockquote>";
+ },
+
+ parse : function(){
+ var c = this.self.context;
+ if(!c.nextline().match(this.self.pattern)) return;
+ c.shiftline();
+ var t = String.times("\t", this.self.ilevel);
+ this._set_child_node_refs();
+ c.htmllines(t + this.self.startstring);
+ while (c.hasnext()) {
+ var l = c.nextline();
+ if (l.match(this.self.endpattern)) {
+ c.shiftline();
+ break;
+ }
+ var node = this._findnode(l);
+ if(node == null) break;
+ node.parse();
+ }
+ c.htmllines(t + this.self.endstring);
+ }
+ })
+
+
+ // Hatena::TagNode
+ Hatena_TagNode = function(){};
+ Hatena_TagNode.prototype = Object.extend(new Hatena_SectionNode(), {
+ init : function(){
+ this.self.pattern = /^>(<.*)$/;
+ this.self.endpattern = /^(.*>)<$/;
+ this.self.childnode = ["h4", "h5", "blockquote", "dl", "list", "pre", "superpre", "table"];
+ this.self.child_node_refs = Array();
+ },
+
+ parse : function(){
+ var c = this.self.context;
+ var t = String.times("\t", this.self.ilevel);
+ if(!c.nextline().match(this.self.pattern)) return;
+ c.shiftline();
+ c.noparagraph(1);
+ this._set_child_node_refs();
+ var x =this._parse_text(RegExp.$1);
+ c.htmllines(t + x);
+ while (c.hasnext()) {
+ var l = c.nextline();
+ if (l.match(this.self.endpattern)) {
+ c.shiftline();
+ x = this._parse_text(RegExp.$1);
+ c.htmllines(t + x);
+ break;
+ }
+ var node = this._findnode(l);
+ if(node == null) break;
+ node.parse();
+ }
+ c.noparagraph(0);
+ },
+
+ _parse_text : function(l){
+ var text = new Hatena_Text();
+ text._new({context : this.self.context});
+ text.parse(l);
+ return text.html();
+ }
+ })
+
+
+ // Hatena::TaglineNode
+ Hatena_TaglineNode = function(){};
+ Hatena_TaglineNode.prototype = Object.extend(new Hatena_SectionNode(), {
+ init : function(){
+ this.self.pattern = /^>(<.*>)<$/;
+ this.self.child_node_refs = Array();
+ },
+
+ parse : function(){
+ var c = this.self.context;
+ var t = String.times("\t", this.self.ilevel);
+ if(!c.nextline().match(this.self.pattern)) return;
+ c.shiftline();
+ c.htmllines(t + RegExp.$1);
+ }
+ })
+
+
+ // Hatena::Text
+ Hatena_Text = function(){}
+ Hatena_Text.prototype = {
+ _new : function(args){
+ this.self = {
+ context : args["context"],
+ html : ''
+ };
+ },
+
+ parse : function(text){
+ this.self.html = '';
+ if(text == null) return;
+ this.self.html = text;
+ },
+
+ html : function(){return this.self.html;}
+ }
+
+
+ /*var h = new Hatena();
+ h.parse("hoge((a))aaa))aaaa\n><a>hoge</a><aaa");
+ WScript.echo(h.html());
+ */
+}
423 diary-css.less
@@ -0,0 +1,423 @@
+// Import Hatena-origin styles
+// -------------------------
+@import url("http://d.st-hatena.com/statics/css/base.css");
+@import url("http://d.st-hatena.com/statics/css/headerstyle_de.css");
+
+// Web fonts
+// -------------------------
+@import url(http://fonts.googleapis.com/css?family=Canata+One);
+
+
+// Container
+// -------------------------
+
+@bodyWidth: 80%;
+@bodyMaxWidth: 800px;
+@bodyMinWidth: 300px;
+
+// Colors
+// -------------------------
+
+@white: #fff;
+@black: #000;
+@beige: #efedea;
+@gray: #333;
+@lightGray: #727374;
+@bruiseBlue: #293587;
+@darkBlue: #314a64;
+@grass: #557933;
+@lightGrass: #bbdb90;
+@skyblue: #00afd8;
+@vermilion: #ec3925;
+@hotWater: #0ca5b0;
+@coffeeBeans: #4e3f30;
+@milk: #fefeeb;
+@sugar: #f8f4e4;
+@stlrrlngSpoon: #a5b3aa;
+
+@qwhite: #eeeeee;
+@loversGray: #515151;
+@metroBlue: #00B4ff;
+
+// Text and background colors
+// -------------------------
+@bodyBackground: @beige;
+@footerBackground: darken(@bodyBackground, 10%);
+@textColor: @gray;
+@footerTextColor: @black;
+@borderColor: #cdcdcc;
+
+// Links
+// -------------------------
+
+@linkColor: @bruiseBlue;
+@linkColorHover: darken(@linkColor, 15%);
+
+@footerLinkColor: @linkColor;
+@footerLinkColorHover: darken(@footerLinkColor, 15%);
+
+// Dates
+// -------------------------
+@dateColor: @grass;
+
+// Typography
+// -------------------------
+@sansFontFamily: Corbel, 'Helvetica Neue', Arial, sans-serif;
+@serifFontFamily: Georgia, "Times New Roman", Times, serif;
+@quoteFontFamily: "Constantia", Georgia, 'Hoefler Text', 'Times New Roman', serif;
+@monoFontFamily: Monaco, Consolas, "Courier New", monospace;
+@titleFontFamily: 'Cantata One', serif;
+
+@baseFontSize: 1.2em;
+@baseFontFamily: @sansFontFamily;
+@baseLineHeight: 1.7em;
+
+@titleFontColor: @textColor;
+@titleFontSize: @baseFontSize + 1.5;
+
+@sectionFooterColor: @lightGray;
+@sectionFooterFontSize: @baseFontSize - 0.3;
+
+@headingsFontFamily: @sansFontFamily;
+@headingsColor: @black;
+
+// Mixins
+// -------------------------
+.border-radius(@radius) {
+ -webkit-border-radius: @radius;
+ -moz-border-radius: @radius;
+ border-radius: @radius;
+}
+
+.flexbox() {
+ display: -webkit-box;
+ display: -moz-box;
+ display: -ms-box;
+}
+
+.letter-press(@deep: 1px) {
+ text-shadow: 0 @deep 0 @white;
+}
+
+.quoteMargin() {
+ -webkit-margin-before: 1em;
+ -webkit-margin-after: 1em;
+ -webkit-margin-start: 40px;
+ -webkit-margin-end: 40px;
+}
+
+// Container
+// ------
+
+body {
+ margin: 0;
+ padding: 0;
+ background-color: @bodyBackground;
+ color: @textColor;
+}
+
+div.hatena-body, h1, div#admin {
+ margin-right: auto;
+ margin-left: auto;
+ max-width: @bodyMaxWidth;
+ width: @bodyWidth;
+}
+
+div#footer {
+ background-color: @footerBackground;
+ font-family: @serifFontFamily;
+ color: @footerTextColor;
+ padding-top: 20px;
+ padding-bottom: 50px;
+ margin-top: 2em;
+ border: 1px solid darken(@footerBackground, 2%);
+
+ .footer-wrapper {
+ margin-left: auto;
+ margin-right: auto;
+ max-width: @bodyMaxWidth;
+ width: @bodyWidth;
+ }
+
+ .footer-section {
+ .flexbox();
+ }
+
+ #footer-column01 {
+ width: 80px;
+ img {
+ max-width: 64px;
+ .border-radius(5px);
+ }
+ }
+
+ #footer-column02 {
+ width: 400px;
+ }
+
+ ul {
+ margin-top: 0;
+ padding-top: 5px;
+ margin-left: 0;
+ padding-left: 0;
+ }
+
+ ul li {
+ display: inline;
+ color: darken(@footerBackground, 10%);
+ }
+}
+
+// Links
+// -----
+
+a {
+ color: @linkColor;
+ // text-decoration: none;
+}
+
+a:hover {
+ color: @linkColorHover;
+}
+
+a.keyword {
+ text-decoration: none;
+}
+
+div#footer {
+ a {
+ color: @footerLinkColor;
+ text-decoration: none;
+ }
+
+ a:hover {
+ color: @footerLinkColorHover;
+ text-decoration: underline;
+ }
+}
+
+
+// Body Text
+// ---------
+
+div.hatena-body {
+ font-size: @baseFontSize;
+
+ p {
+ font-family: @baseFontFamily;
+ line-height: @baseLineHeight;
+ margin: 1.2em 0;
+ }
+
+ p.description {
+ color: @lightGray;
+ font-size: @baseFontSize - 0.4;
+ font-weight: normal;
+ // border-bottom: 1px solid @borderColor;
+ margin-top: 0;
+ padding-left: 3px;
+ text-indent: 0;
+ text-align: left;
+ .letter-press(1px);
+ }
+
+ p.sectionfooter {
+ text-indent: 0;
+ font-size: @sectionFooterFontSize;
+ color: @sectionFooterColor;
+ text-align: right;
+ }
+
+ ul {
+ // font-size: @baseFontSize;
+ font-family: @baseFontFamily;
+ }
+
+ ul li {
+ line-height: 150%;
+ }
+
+ blockquote {
+ display: block;
+ position: relative;
+ margin: 1.5em 4em;
+ line-height: 1.45em;
+
+ p {
+ }
+
+ cite {
+ font-size: @baseFontSize - 0.3em;
+ }
+
+ ::before {
+ font-family: @quoteFontFamily;
+ left: -.5em;
+ position: absolute;
+ top: .25em;
+ content: '\201C';
+ font-size: 4em;
+ opacity: .2;
+ }
+ }
+}
+
+// HEADINGS
+// --------
+
+h1, h2, h3, h4, h5, h6 {
+ font-family: @headingsFontFamily;
+ color: @headingsColor;
+
+ a {
+ text-decoration: none;
+ }
+
+ a:hover {
+ text-decoration: underline;
+ }
+}
+
+h1 {
+ // font-weight: normal;
+ font-size: @titleFontSize;
+ font-family: @titleFontFamily;
+ text-align: left;
+ //text-transform: uppercase;
+ margin-bottom: 0;
+ padding-bottom: 0;
+ .letter-press(2px);
+
+ // background-color: #DBE3E5;
+ // background-image: url("http://www.st-hatena.com/users/na/naoya/user.jpg");
+ // background-repeat: no-repeat;
+ // margin-left: 40px;
+
+ a {
+ color: @titleFontColor;
+ // color: #00AFD9;
+ }
+
+ img {
+ max-width: 64px;
+ .border-radius(5px);
+ }
+}
+
+h1::first-letter {
+ // color: @vermilion;
+ // background-color: @skyblue;
+ // padding: 5px;
+ // margin-right: 2px;
+ // .letter-press(3);
+}
+
+h2 {
+ font-weight: normal;
+ font-size: @baseFontSize - 0.1;
+ font-family: @sansFontFamily;
+ .letter-press(1px);
+
+ a {
+ color: @dateColor;
+ }
+ a:hover {
+ color: darken(@dateColor, 15%)
+ }
+ .edit {
+ color: @lightGray;
+ font-size: 70%;
+ }
+ .edit:hover {
+ color: darken(@lightGray, 15%);
+ }
+}
+
+#footer h2 {
+ color: @footerTextColor;
+ font-family: @titleFontFamily;
+ font-size: @baseFontSize + 0.2;
+ font-weight: bold;
+ // text-shadow: 0 1px 0 @lightGrass;
+ .letter-press(1px);
+ margin-top: 0;
+ margin-bottom: 0;
+ padding-bottom: 0;
+}
+
+h3 {
+ font-family: @serifFontFamily;
+ font-size: @baseFontSize + 0.2;
+ .letter-press(2px);
+ margin-top: 0;
+ margin-bottom: 0;
+ padding-top: 0.8em;
+ padding-bottom: 0.8em;
+
+ border-top: 1px solid @borderColor;
+ border-bottom: 1px solid @borderColor;
+}
+
+h4 {
+ font-size: @baseFontSize;
+ // .letter-press(1px);
+}
+
+h5 {
+ // .letter-press(1px);
+}
+
+#footer h3 {
+ color: @footerTextColor;
+ font-family: @serifFontFamily;
+ font-weight: normal;
+ font-size: @baseFontSize - 0.2;
+ .letter-press(0);
+ padding-top: 5px;
+
+ border-top: 0;
+ border-bottom: 0;
+}
+
+// Inline and block code styles
+// --------
+
+code, pre {
+ font-family: @monoFontFamily;
+ font-size: @baseFontSize - 0.4;
+}
+
+pre {
+ display: block;
+ // padding: (@baseLineHeight - 1) / 2;
+ // margin: 0 0 @baseLineHeight / 2;
+ padding: 1em;
+ margin: 0.5em;
+ word-break: break-all;
+ word-wrap : break-word;
+ white-space: pre;
+ white-space: pre-wrap;
+ background-color: #f5f5f5;
+ border: 1px solid rgba(0,0,0,.15);
+ .border-radius(4px);
+}
+
+// Misc
+// ------
+div.calendar {
+ font-family: @sansFontFamily;
+ font-size: @baseFontSize - 0.3;
+ text-align: right;
+}
+
+// Admin
+// ------
+div#admin {
+ margin-top: 1em;
+ margin-bottom: 1em;
+}
+
+div#admin textarea {
+ width: 100%;
+ height: 20em;
+}

0 comments on commit 5bf0e04

Please sign in to comment.
Something went wrong with that request. Please try again.