Edit your Rakefile and drop the following lines in it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Usage : rake new_aside[“Title of Aside”]
Following a recent discussion on Twitter about excluding some posts from the front page (which I think is a great idea), here’s my recipe for controlling which posts are shown and which ones are hidden based on categories.
First, let’s add two settings to our _config.yml file.
Next, find the pagination plugin under the plugins directory, and add the following code just after line #33:
1 2 3 4 5 6 7
Your pagination file should look like this :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Now, here’s how it works. If you want to hide posts under categories “Octopress” and “Plugin”, just add it to your _config.yml
And if you want to show only posts under category “Octopress” on the front page, replace “hide” by “show”:
This is a follow-up of the Contact Form in Octopress. In this post, we’re going to use custom scripts in Google Docs to mail the form values on form submit. Here’s how:
Step 1: Open the spreadsheet for the Google Form built in the previous post.
Step 2: Open the Script Editor (Tools -> Script Editor)
Step 3: Add in a title for the new script. (eg. mailFormValuesOnSubmit)
Step 4: Paste in the following code and save it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
The code above will get the values of the last row and mail it to the recipient email address provided. My form has name, email, subject and message fields. So I’m using this code to mail me the values with the name, email and message in the email body. You can customize the subject and message to send. The values variable is a 2d array indexed by row number then by column number. So the following code returns the value of the first row and third column, which in my case here is email.
Now that our script is saved, we need to tell the spreadsheet to run this script on form submit. We’ll use a trigger.
Step 5 : Under Resources, Click on “Current Script’s triggers”. Add a new trigger : Run mailFormValuesOnSubmit From Spreadsheet On Form Submit. Save.
Now, when you submit your form, you should get the values submitted in an email right away.
That’s it, contact form awesomeness in Octopress.
Building a contact form for Octopress can be a real PITA? Why? Octopress runs on a server-less (static pages) configuration, which means no interaction with any server and consequently no mail interface. Our only solution in this case is to use 3rd party forms that we can embed on our site. So here’s what we’re going to do :
- Create a form on Google Docs.
- Set notifications for the form.
- Create a new page on Octopress to hold our form.
- Use the Google Form Liquid tag to embed our form.
Create a form on Google Docs.
Step 1: Head to Google Docs
Step 2: Click on Create -> Form
Step 3: Build your form. (You can add required elements here)
Set notifications for the form.
Now that our form is ready. Let’s configure notifications for it.
Step 1: Find the See Responses button, and select Spreadsheet
Step 2: On the spreadsheet, open the notification (Tool -> Notification Rules)
Step 3: Tell Google to send you an email when a user submits the form.
Create a new page on Octopress to hold our form.
Our form is ready. Let’s add it to Octopress. We’ll build a page to hold the form.
bundle exec rake new_page["Contact"]
Use the Google Form filter to embed our form.
Now that the page is built. Let’s embed the form in it. You’ll need the Google Form plugin for that. Go here to get it.
Once installed, open the page created above in an editor and add the following code to it.
Regenerate your site and you should see your form on your contact page.
bundle exec rake generate
The Google Form plugin should take care of validation and custom CSS as well.
Here’s a demo of a contact form running off Google Docs. Please, don’t spam.
See the recent comments in the sidebar? Here’s how it’s done:
Step 1: Let’s create a new aside. Create a new file recent_comment.html under source/_includes/custom/asides
Step 2: Add the following code
1 2 3 4
Here are the parameters you can use for comments :
- hide_avatars : hides the avatar in comments (values : 0, 1)
- num_items : number of comments to show
- excerpt_length : number of characters to show for each comment
Step 3: Add the aside to _config.yml
Step 4: Re-build your site
A while back, I helped write the Drupal 7 port for the Drupal DOPL module. This module makes it easy to link back to modules, themes, nodes, users and pretty much anything on http://drupal.org. For people who blogs about Drupal it’s a great help. So the first thing i wanted when I moved to Octopress is that same funtionality. So here goes “Drupal Tag”, an Octopress filter plugin that let’s you link to Drupal.org pages.
1 2 3 4 5
1 2 3 4
1 2 3 4