Last active
December 12, 2015 08:18
-
-
Save dduvnjak/4742505 to your computer and use it in GitHub Desktop.
Simple ruby script to list all Etherpad pads (using etherpad-client and sinatra for web)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'sinatra' | |
require 'etherpad-lite' | |
ETHERPAD_URL = "http://ether.example.com" | |
client = EtherpadLite.connect(ETHERPAD_URL, 'api_key', '1.2.1') | |
header = '<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<style type="text/css"> | |
a:link {text-decoration:none;} | |
a:visited {text-decoration:none;} | |
a:hover {text-decoration:underline;color:green;} | |
a:active {text-decoration:underline;} | |
body {font-family:Calibri; font-size: 20px} | |
</style> | |
</head> | |
<body> | |
<h2>Etherpad - list of pads</h1>' | |
footer = " </body> | |
</html>" | |
def get_pads(client) | |
pad_list = '<p>' | |
client.pads.each do |pad| | |
pad_list = pad_list + '<a href="' + ETHERPAD_URL + '/p/' + pad.id.to_s + '"">' + pad.id.to_s + '</a>' + '<br />' | |
#puts pad.methods | |
end | |
pad_list = pad_list + '</p>' | |
return pad_list | |
end | |
get '/' do | |
"#{header} | |
#{get_pads(client)} | |
#{footer}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment