Skip to content

Instantly share code, notes, and snippets.

@navinpai
Created March 9, 2012 08:28
Show Gist options
  • Select an option

  • Save navinpai/2005646 to your computer and use it in GitHub Desktop.

Select an option

Save navinpai/2005646 to your computer and use it in GitHub Desktop.
Create notes on wrttn (http://wrttn.me)
#For some reasons, Fonts aren't getting rendered in Firefox. Not sure why!
#Using gectechnix.in as a temp filestore. Will prolly be deleting the fonts from the server soon
#If it works right, this is how your note looks: Default: http://wrttn.me/bf1081/ ( http://www.diigo.com/item/image/x9o0/vm2u?size=o ) Black: http://wrttn.me/537a88/ ( http://www.diigo.com/item/image/x9o0/q02j?size=o )
require 'net/http' #For making the actual POST
require 'json' #For parsing the POST data
require 'launchy' #For opening generated link in default browser
$/ = "~~"
uri=URI('http://wrttn.me/api/v1/notes.json')
print "Create Notes on http://wrttn.me via command line\n"
print "Enter Text (Terminate input with ~~):"
text= STDIN.gets.sub('~~','')
$/ = "\n"
buffer=STDIN.gets #To ignore the trailing \n . Prolly not the best way to do this!
print "Enter Title:"
title= STDIN.gets.chomp
mycss='@font-face {
font-family: "PoiretOne-Regular";
src: url("http://www.gectechnix.in/fonts/poiretone-regular.eot");
src: url("http://www.gectechnix.in/fonts/poiretone-regular.eot?#iefix") format("embedded-opentype"),
url("http://www.gectechnix.in/fonts/poiretone-regular.woff") format("woff"),
url("http://www.gectechnix.in/fonts/poiretone-regular.ttf") format("truetype"),
url("http://www.gectechnix.in/fonts/poiretone-regular.svg#poiretone-regular") format("svg");
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: "Fresca-Regular";
src: url("http://www.gectechnix.in/fonts/fresca-regular.eot");
src: url("http://www.gectechnix.in/fonts/fresca-regular.eot?#iefix") format("embedded-opentype"),
url("http://www.gectechnix.in/fonts/fresca-regular.woff") format("woff"),
url("http://www.gectechnix.in/fonts/fresca-regular.ttf") format("truetype"),
url("http://www.gectechnix.in/fonts/fresca-regular.svg#fresca-regular") format("svg");
font-weight: normal;
font-style: normal;
}
h1{font-size:40px;font-style:bold;font-family:"Fresca-Regular",sans-serif;font-weight:800}'
print "CSS Styling (B-black else Default): "
csstype=STDIN.gets.chomp
if csstype=='B' || csstype=='b'
mycss=mycss+'body{font-family:"PoiretOne-Regular";font-size:20px;color:#FFFFFF; text-shadow: black 0.1em 0.1em 0.2em;background: #000 url("http://i.imgur.com/9saQv.png") repeat 0 0;}'
else
mycss=mycss+'body{font-family:"PoiretOne-Regular";font-size:20px;color:#000000;}'
end
if !(text.empty? || title.empty?)
getdata = Net::HTTP.post_form(uri, 'note' => text, 'title' => title, 'format'=>'html','css'=>mycss)
#puts getdata.body
id=JSON.parse(getdata.body)
link="http://wrttn.me/"+id['key'] #Creates the link to open/display
print "Open the link? (y/n) :"
choice=STDIN.gets.chomp
if choice=='y'
print "Opening: "+link+"\n"
Launchy.open(link) #Cross platform solution to open links in browser
else
print "\n"+link+"\n"
end
else
if text.empty? && title.empty?
print "No text or title entered"
elsif text.empty?
print "No text entered"
else
print "No title entered"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment