Title photo
frugal technology, simple living and guerrilla large-appliance repair
Sat, 21 Oct 2017

Diversity in Open Source, and Jekyll’s role in it | jekyll

Diversity in open source, and Jekyll's role in it https://jekyllrb.com/news/2017/10/19/diversity-open-source/ https://jekyllrb.com/news/2017/10/19/diversity-open-source/

Ode - A Simple Personal Publishing Platform For the Web

Ode - A Simple Personal Publishing Platform For the Web https://ode.io/

Ode

Ode - a simple blogging system https://ode.io/home https://ode.io/home

My blog-posting program in Ruby

I'm actually doing it. I'm writing a blog-posting program that will take an http link, extract the remote page's title and create a social-media-style blog post (title, body text and link) that can be easily uploaded to my flat-file blogging system's server.

The idea is to make it as easy to post a "social"-style update to my own blog as it is to post to Twitter (or Facebook or Google+).

(I use IFTTT -- and formerly dlvr.it -- to post these social entries on Twitter, but I could see this program taking over that task as well.)

Back to my application. I could have gone several different ways from a conceptual standpoint.

  • I could have done this idea as a web app, but in order to get the files to upload to the blog, I'd either have to write a server component on that side, or create a backend service -- with some measure of security -- to handle the upload (I'm using FTP, but it doesn't have to be that).

  • I thought about a desktop GUI. I want this to be a true cross-platform app. I seriously considered using the now-ancient Tk framework with Ruby. I less-seriously considered Java FX, though I did successfully hack together code to upload via FTP using Java. (At least it was a worthwhile programming exercise.) I could have gone with QT. Maybe I could have done the whole thing with QML.

I'm not ruling out any of these GUI solutions, but I needed to start coding, and the easiest, quickest thing for me to do (or so I thought) is a menu-driven console app. I could have gone with Java, JavaScript, Ruby, even Perl. I did tests of various components in three of those languages.

I'm writing the app for the console with an eye toward re-using the code in a future GUI app, and for that reason maybe I should have used JavaScript.

But I really wanted to use Ruby. I'm trying to grasp object-orientated programming, and there is a whole lot of web-based help for Ruby programmers that often acknowledges that there are beginners out there who need a helping hand.

And I really would love to eventually port this code to Tk, or even as a Sinatra or Rails app. I should want to do it in JavaScript. But Ruby is so friendly, and it's made for use in the console.

So I'm writing it in Ruby. And I have some 190 lines of code that do the following:

  • Display a menu of tasks and wait for input
  • When a URL is entered, grab the HTML title
  • Create a simple document with a title and text derived from the remote HTML title
  • Add a Markdown-formatted link back to the original HTML page
  • Save all as a text file with an auto-generated file name incorporating the current date and text derived from the title
  • Allow user to enter different text for the title or body
  • Let user choose not to include the source site's URL
  • Save all to a text file
  • Upload to website via FTP and "tell" blog to index the new entry

I have all of these features working, and while the app is very far from perfect, it is functional. The code isn't ready for public consumption -- it needs lots of cleanup before I publish it, and it's really meant more for Ode users and blogs that work in a similar way (files are uploaded to a server, from which the blog software renders them for the reader) than it is for flat-file systems such as Hugo, where a dedicated program builds the blog locally and sends files on their way, but the concepts and code used in this app can certainly be modified for that workflow -- and I'm not at all above doing that in the future.

Aside from adding more features, primarily the ability to edit elements instead of re-typing them (maybe by invoking the vi editor), I want to make the code more modular. Right how it's a huge procedural hack, and modularity (and object orientation) will make it cleaner and more flexible. That's the idea anyway.

Before that I need to clean up the configuration, which is all over the place.

Still, I wanted to make an app, I used the skills I had (and Googled and read plenty), and now I have something that works, however ugly it may look on the back end.

Fri, 20 Oct 2017

If and Else | The Bastards Book of Ruby

If and Else | The Bastards Book of Ruby http://ruby.bastardsbook.com/chapters/ifelse/

Ruby for Beginners

Ruby for Beginners http://ruby-for-beginners.rubymonstas.org/index.html

Programming Ruby: The Pragmatic Programmer's Guide

Programming Ruby: The Pragmatic Programmer's Guide http://ruby-doc.com/docs/ProgrammingRuby/

Beginning Ruby: The Book to Learn Ruby Programming

Beginning Ruby: The Book to Learn Ruby Programming http://peterc.org/beginningruby/

Sinatra, a simpler Ruby web framework

Sinatra, a simpler Ruby web framework http://www.sinatrarb.com/intro.html

Padrino - The Elegant Ruby Web Framework

Padrino - The Elegant Ruby Web Framework http://padrinorb.com/