Skip to content

Instantly share code, notes, and snippets.

@tamoot
Created September 10, 2010 07:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tamoot/573263 to your computer and use it in GitHub Desktop.
Save tamoot/573263 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
#
# evernote_sitememory.rb - embeded Evernote Site Memory
# http://www.evernote.com/about/developer/sitememory/developer.php
#
# Copyright (C) 2010, tamoot <tamoot+tdiary@gmail.com>
# You can redistribute it and/or modify it under GPL2.
#
add_section_leave_proc do |date, index|
r = ''
r << %Q|<div class="evernote-sitememory">\n|
r << %Q|<a href="#" onclick="Evernote.doClip({ \n|
r << %Q| title: '#{subtitle(date, index, true)}',\n|
r << %Q| url: '#{permalink(date, index, true)}', \n|
r << %Q| providerName: '#{@conf.html_title}'\n|
r << %Q| });return false;">\n|
r << %Q| <img src="http://static.evernote.com/article-clipper.png" />\n|
r << %Q|</a>\n|
r << %Q|</div>\n|
r
end
unless defined?(subtitle)
def subtitle( date, index, escape = true )
diary = @diaries[date.strftime( "%Y%m%d" )]
return "" unless diary
sn = 1
diary.each_section do |section|
if sn == index
old_apply_plugin = @options["apply_plugin"]
@options["apply_plugin"] = true
title = apply_plugin( section.subtitle_to_html, true )
@options["apply_plugin"] = old_apply_plugin
title.gsub!( /(?=")/, "\\" ) if escape
return title
end
sn += 1
end
end
end
unless defined?(permalink)
def permalink( date, index, escape = true )
ymd = date.strftime( "%Y%m%d" )
uri = @conf.index.dup
uri.sub!( %r|\A(?!https?://)|i, @conf.base_url )
uri.gsub!( %r|/\.(?=/)|, "" ) # /././ -> /
link = uri + anchor( "#{ymd}p%02d" % index )
link.sub!( "#", "%23" ) if escape
link
end
end
add_footer_proc do
%Q|<script type="text/javascript" src="http://static.evernote.com/noteit.js"></script>\n|
end
# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:
# vim: ts=3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment