It is the first post with our new blog, we're upgrading our infrastructure, and have lots of upcoming events. Let me give a brief overview of what's up.

HAI

It's a new exciting semester! We had a great turnout to the general meeting (thanks Marc!) And we just had had our first Python workshop utilizing the Udacity course Intro to Computer Science taught by Professor Dave Evans.

Be sure to come out to our next workshop Intro to Android Mobile App Development on Friday 2-21. Download the IDE we’ll be using here and git the demo here. Also, please check out Professor Puder’s Android tutorial.

See our other upcoming events at sfsu.acm.org/calendar. Events include a Button Smashing Night at 20mission, an Intelligence Community Virtual Career Fair, a guest speaker from Twitter, an Intro to Open Source, a Raspberry Pi & Arduino Meetup, and more!

Blog

Now that the shameless plugs are over with, I thought I'd post about what just happened to the site. We just forked paullik's IRC-Bot to sit in our #acm-sfsu IRC channel, and thought we'd keep up with the Python theme. So, we used the static site generator Pelican which is very similar in process to Jekyll. Btw, we will be doing a lightning presentation on both Jekyll and Pelican soon, if any of you are interested in leveraging these. Come out and learn to blog like a hacker!

Aside: maybe the shameless plugs aren't quite over with ;)

Pelican

Pelican is a static site generator powered by Python! and is very similar in implementation as Jekyll. Since we're into social coding, I'd like to use this blog post as a mini-tutorial. So, if you are indeed using this as a tutorial, git Pelican here and read over getting started and using Pelican on Github Pages.

Our old blog was made in Wordpress. We used pelican-import to get the old entries. It has two dependencies:

  • BeautifulSoup pip install BeautifulSoup
  • Pandoc apt-get pandoc

See: pelican-import

Import with pelican-import --wpfile -o content posts.xml which takes your Wordpress' exported posts.xml file and makes reStructuredText (reST) posts of your content in the content folder. You can use both Markdown and reST for writing your posts.

Aside: This post is written in Markdown if you were curious.

Aside: If you need BeautifulSoup4, pip install BeautifulSoup4.

Generating the site

Run pelican. This will generate your site in the output folder by default. It also uses your pelicanconf.py file by default. See the basic usage for more info such as running pelican -r to do automatic reloading when you make changes.

Aside: Alternately, run make regenerate.

You can view the site on your browser by opening the index.html file in the output folder. Also, checkout the kickstart your blog section. If you installed Fabric, you can also run these useful commands for building the site, regenerating, serving, and publishing. Also, you can use make serve if you used the quick configuration to generate a Makefile.

Theming

This comes with a default theme, you might need to update the RELATIVE_URLS parameter in the pelicanconf.py file to utilize your stylesheets etc during development.

If you want to play with the themes, you can quickly switch between themes by cloning some sample ones with git clone https://github.com/getpelican/pelican-themes.git themes and then run pelican with pelican -t /themes/chunk or edit pelicanconf.py where it says THEME = "/themes/chunk" and just run pelican. Adding a theme submodule is easy with git submodule add https://github.com/hdra/pelican-cait.git themes/pelican-cait. This'll probably save you build issues in the next section.

Github Pages

To put this on Github Pages, you'll want to use your output folder as the gh-pages branch, then it can be hosted as a Github Pages page. Follow the how to use Pelican on Github Pages and Publishing to Github tutorials.

Most simply:

  • ghp-import output. By typing git branch you'll now see a gh-pages branch.
  • git push origin gh-pages

Aside: or in one command, make github which does the same thing.

If you are using an Organization/User page like us, you'll do things slightly different. You'll want all of your generated files in the master branch. Do this in the beginning.

If you didn't do this in the beginning and want to now, keep reading. In this case, you don't have to call your branch gh-pages, so we went with source. However, originally I was working on all my source in the master branch, but then wanted to shift this all over to a source branch and then orphan my master and start it from scratch with the generated output.

If you've run across this, follow these instructions (src):

git checkout -b source master     # create and switch to the release branch
git push -u origin source         # push the release branch to the remote and track it
git branch -D master              # delete local master
git push --delete origin master   # delete remote master

If trying to delete your master branch with git branch -D master, you'll get an error, but you can resolve it by going into your admin settings and changing the default branch to source. This is so that Github knows what to serve up when people visit the site. Now you may repeat the command and it will work.

You can verify that master was deleted by typing git branch. Now we're going to start the master branch from scratch again with git checkout --orphan master. Definitely check out the explanations in git checkout --help and creating project pages manually.

That is, we're doing

  • git checkout --orphan master. You can confirm that you're in a parentless tree with git log.
  • and clear out everything with git rm -rf . and git clean the remainder, or manually rm anything else . Double-check what you did with git status.

Now move the contents of your output folder into the folder, then

  • git add .
  • git commit -m 'output' -m 'pelican output to master branch'
  • git push origin master

See what's up with your beautiful network graph.

Aside: You get emailed if the build fails when using Jekyll, but not when using Pelican or building otherwise. If you want to confirm, check in your admin settings whether it was built.

Hope to see you at an upcoming event, feel free to stop by in our IRC #acm-sfsu if you have any questions,

Cheers, Tom


Previous Article: Intro to Android Mobile App Development - Friday 2/21 @3pm, TH 335 Next Article: Raspberry Pi & Arduino Meetup in Oakland