To learn means different things. Generally speaking, actual learning implies a change of the state of mind. It may imply a different mood that allows you to do something unexpected. I learned a lot of things in this course. Among these there is a fancy one, for me. Software coding was a relevant part of my former researcher activity but since I was charged with teaching in the medical school I forgot about coding. Wandering in this course and browsing Stephen Downes gRSShopper, all of a sudden I realized that with some small pieces of code I could facilitate my work in many instances.
You see, my past work involved assembly languages, a lot of FORTRAN and mathematical scripting languages, some C. The scenario my mind inherited from such activities did not allow me to grasp how many layers of functionalities are available out there nowadays, despite the fact that the virtues of the open source model are very recurrent in my talks.
Hanging around for a while in that part of the CCK08 forest that gRSShopper is, I realized, in a very tangible way, that a great deal of available software could help me in a number of tasks and that with languages such as perl or ruby it is extremely easy to integrate that software. Thus I began to play writing some code in perl and ruby. Yes, no doubt that I got distracted from a number of CCK08 activities but this is part of the game and I’m really happy with these new possibilities.
For instance, I let the students enroll by means of a Google form where they have to specify their blog addresses and as new data arrive I put the blog addresses in a feed aggregator. I did it by hand because I felt to have too little time to face the issue in some other ways. Now, I have written a small script in ruby by means of which the creation of an OPML file with feeds derived from the blog addresses stored in a Google spreadsheet is a push-button operation.
I put here the code just to show how easy it is for those that may be interested or those that could give me some advices.
Note of November, 21: now the opml file is directly upoaded into the wiki where the students can download it.#!/usr/bin/ruby
# url2opml.rb
# This very simple script allows one to retrieve a column of a Google spreadsheet containing a
# series of blog addresses and to produce an opml file to be uploaded to a feed reader.
# It is very rough … just to show how this task can be done very easily
# Spreadsheet address and data location in it are hard-coded just to have a handy
# push-button procedure
# Required packages
# RubyGems is the Ruby standard for publishing and managing third party libraries:
# http://www.rubygems.org/read/chapter/1
require “rubygems”
# roo is a package to access content of Open-office spreadsheets (.ods),
# Excel spreadsheets (.xls), Google (online) spreadsheets, Excel’s new file format .xlsx:
# http://roo.rubyforge.org/ … very nice!
require “roo”
# Retrieves the spreadsheet, the first argument is the “key” of the spreadsheet that can
# be extracted from the spreadsheet address. For instance, the address of the
# spreadsheet I’m using is
# http://spreadsheets.google.com/ccc?key=pZzXgwUua-JPX2YdQbK1nRg&hl=en
# The key is pZzXgwUua-JPX2YdQbK1nRg
# The second and third arguments are gmail address and password, respectively
oo = Google.new(“pZzXgwUua-JPX2YdQbK1nRg”, “andreas.formiconi@gmail.com”, “mypassword”)
oo.default_sheet = oo.sheets.first # sets the default sheet to work with
lines = Array.new # creates an array to store the column element
# Copies the cell contents of column “G” in the array “lines”
first_useful_row = 3
first_useful_row.upto(oo.last_row) do |i|
lines[i-first_useful_row] = oo.cell(i,“G”)
end
folder_name = “INF08” # I want that in the feed reader these feeds will be in folder INF08
folder_name.chomp! # throw away the final newline character …
file_out = “INF08_fall.opml” # sets the name of the output opml file
outfile = File.new(file_out.chomp, “w”) # creates that file …
# and now write there the first group of lines, such as header and stuff like that
outfile.write “<?xml version=\”1.0\” encoding=\”UTF-8\”?>\n”
outfile.write “<opml version=\”1.1\”>\n”
outfile.write “<head>\n”;
outfile.write “<title>Studenti “ + folder_name + “</title>\n”
outfile.write “</head>\n”
outfile.write “<body>\n”
outfile.write “<outline title=\”” + folder_name + “\” text=\”” + folder_name + “\”>\n”
# Now for each line …
lines.each do
|ind|
# skip void lines
if ind =~ /./
# add leading http:// if it is not there
if ind !~ /http:\/\//
ind = “http://” + ind
end
# generates feeds for wordpress posts and comments, line finishing with … wordpress.com/
if ind =~ /wordpress.com\//
ind.chomp!
f = ind + “feed/”
outfile.write “<outline xmlUrl=\”” + f + “\” />\n”
f = ind + “comments/feed/”
outfile.write “<outline xmlUrl=\”” + f + “\” />\n”
# generates feeds for wordpress posts and comments, line finishing with … wordpress.com
elsif ind =~ /wordpress.com/
ind.chomp!
f = ind + “/feed/”
outfile.write “<outline xmlUrl=\”” + f + “\” />\n”
f = ind + “/comments/feed/”
outfile.write “<outline xmlUrl=\”” + f + “\” />\n”
# generates feeds for blogspot posts and comments, line finishing with … blogspot.com/
elsif ind =~ /blogspot.com\//
ind.chomp!
f = ind + “feeds/posts/default/”
outfile.write “<outline xmlUrl=\”” + f + “\” />\n”
f = ind + “feeds/comments/default/”
outfile.write “<outline xmlUrl=\”” + f + “\” />\n”
# generates feeds for blogspot posts and comments, line finishing with … blogspot.com
elsif ind =~ /blogspot.com/
ind.chomp!
f = ind + “/feeds/posts/default/”
outfile.write “<outline xmlUrl=\”” + f + “\” />\n”
f = ind + “/feeds/comments/default/”
outfile.write “<outline xmlUrl=\”” + f + “\” />\n”
else
# other blogs, just put htere blog address and be confident in reader …
ind.chomp!
outfile.write “<outline xmlUrl=\”” + ind + “\” />\n”
end
end
end
# writing closing lines of opml file
outfile.write “</outline>\n”
outfile.write “</body>\n”
outfile.write “</opml>\n”
outfile.close # close opml file
# (November, 21) and now upload the file into the wiki …
system “curl -F \”someFile=@INF08_fall.opml\” http://infomedfi.pbwiki.com/api_v2/ -Fop=PutFile -Fadmin_key=mykey”
Oh, a computer is infinitely stupid with respect to a little child, it is through little children that the Universe is beginning to know itself … 🙂
Well my little experience with the code, does not allow to understand the ruby language, maybe ‘cause i consider all the languages a sort of esotheric world… even with a kind of fear linked to that! it is a sort of magic to talk with a processor and ask it to do something for us in different ways and in different languages… i find less difficult to do that wih a little child 🙂
Yes I know http://feed2opml.com but this service simply puts an xml wrap to a list of URL addresses. I need to make some cleaning of the addresses as well as generating feeds for both posts and comments, whenever possible, in order to follow and analyze the activities of the students.
OPML generator http://feed2opml.com
Buon giorno Andreas
Thank you for sharing this. I would like to share this post with some colleagues who help me do what you and Stephen find so easy to do!
I do think this behind the scenes work is essential if we are to be even better connected.
Le sono molto grato
Keith