Currently running newLISP on Rockets version: 0.43
I've been setting up a lot of new sites lately using newLISP on Rockets. Here's the process for making a brand new site from scratch.
This assumes you've already got Linux, Apache, and newLISP installed. Your web directory should be in /var/www.
<VirtualHost *:80>
ServerAdmin starman@starscene.net
ServerName starscene.net
ServerAlias www.starscene.net
DocumentRoot /var/www/starscene
<Directory />
Options FollowSymLinks +ExecCGI
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews +ExecCGI
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Views: 191
Poll Results:
Total votes: 89
| one : | 6 | ...... |
| two : | 32 | ................................... |
| three : | 7 | ....... |
| four : | 10 | ........... |
| forty-two : | 34 | ...................................... |
Views: 404
Poll Results:
Total votes: 47
| one : | 9 | ................... |
| two : | 16 | .................................. |
| three : | 9 | ................... |
| four : | 13 | ........................... |
Views: 269
I'd been putting off doing a Forgot Password module for newLISP on Rockets because it is such a pain doing it properly. You can't just have one click to reset a password, because what if someone else knows your user name or email? Then they could change your password to whatever they want!
So what most sites do is let you trigger a reset, then send a confirmation message to that email address, and then make you retrieve the email and click on a special link to reset your password.
Funnily enough, on another site I'm developing I was testing logging out and logging in, and you know what? I forgot my password. So I figured this was as good as an excuse as any to build a Forgot Module! (And no, I couldn't just grab the password from the database, because it's encrypted for security!)
I wanted the whole thing to be only a single page for simplicity. rockets-forgotpassword.lsp is the page that handles triggering the email, confirming and sending the email, and resetting the password, so the code flow may not seem obvious at first glance. The emails contain links of unique identifiers (sometimes called GUIDs) that expire after an hour and are matched with email addresses of the people who sent them, so people won't be able to guess them either. The tokens are stored in a file called reset-tokens.lisp. This file is automatically generated if it doesn't previously exist.
One more thing: to get the email links to work, the module needs two additional configuration options in Rockets-config.lisp:
(set 'AdminEmail "newlisponrockets@newlisponrockets.com")
(set 'SiteURL "newlisponrockets.com")
Views: 202
I've been wanting to update newLISP on my development box to see what neat new changes and features are available. Unfortunately, it's a 64-bit Ubuntu install, and pre-packaged binaries are only available for i386 (32-bit) on newlisp.org.
So what to do? Well, compile from source of course!
First get the source:
cd ~
wget http://www.newlisp.org/downloads/newlisp-10.4.5.tgz
tar zxvf newlisp-10.4.5.tgz
cd newlisp-10.4.5
sudo apt-get install libffi-dev
sudo apt-get install libreadline6 libreadline6-dev
sudo make
sudo make install
cd /usr/share/newlisp/modules
sudo nano sqlite3.lsp
"/usr/lib/x86_64-linux-gnu/libsqlite3.so" ; Ubuntu "/usr/lib/x86_64-linux-gnu/libcrypto.so.0.9.8" ; UbuntuViews: 294
Today I relaunched my personal website at http://www.jeremyreimer.com. It had previously been running on Dragonfly, a web development framework that inspired me to write Rockets.
Converting the code was really easy. All it took was the following:
1. Replace all instances of (print) with (display) and (println) with (displayln)
2. Remove Dragonfly-specific functions like (web-root) that are no longer necessary.
3. Make sure to start each page with:
#!/usr/bin/env newlisp
(load "newlisp-rockets.lisp") ; this is where the magic happens!
(display-footer "Jeremy Reimer")
(display-page)
Views: 224
I've made some changes to the code base that will make it easier to start new custom sites based on Rockets. This is for my benefit as well as everyone else's-- I'm currently developing a bunch of new sites with this technology!
Now, when you run setup-rockets.lisp, the script asks you for a long and short name for your blog, an owner name, and the database name. These are automatically saved in a new configuration file called Rockets-config.lisp. I went through every page in the Rockets blog and changed it so that it reads various custom data about the blog from the config file.
The config file looks like this:
(context 'RocketsConfig)
(set 'Database "ROCKETS-BLOG")
(set 'Name "The newLISP on Rockets Blog")
(set 'ShortName "newLISP on Rockets")
(set 'Owner "Rocket Man")
(context MAIN)
Views: 238
newLISP on Rockets comes with and works with jQuery, which lets you do all sorts of wild and wonderful things on your page. But where should you put your Javascript code?
It doesn't really matter where it goes as long as there are <script> tags around it, but sometimes you want to defer execution to the end of the page. This leads to the best performance, because the user isn't waiting for the Javascript to load before seeing the page elements.
I've modified (display-footer) to let you add a string of Javascript or jQuery code to your page and insert it right at the end. You assign the code to a string variable and then just call (display-footer "Your name" name-of-string-variable) and it will execute the Javascript or jQuery code at the end of the page.
Views: 222
JSON stands for the JavaScript Object Notation, and it's used by lots of applications because it's much more compact than the bulky XML format. It's also suspiciously similar to LISP lists, which isn't that surprising considering that JavaScript was originally written as a LISP interpreter.
The basic format is something like this:
{
"firstName": "John",
"lastName": "Smith",
"age": 25,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": 10021
},
"phoneNumber": [
{
"type": "home",
"number": "212 555-1234"
},
{
"type": "fax",
"number": "646 555-4567"
}
]
}
Views: 316
RSS feeds are useful and great, but the XML structure they come in is rather unwieldy to read through and parse. newLISP has a great function called (parse-xml) that converts an XML tree into a list, but now you just have an unwieldy list. It's helpful to be able to extract only the data we want and put it in a simple nested list.
I've written a new function in Rockets that lets you do just that.
First, get the data from the RSS feed URL that you want:
(set 'feed-url " http://penny-arcade.com/feed"))
(set 'rss-result (xml-parse (get-url feed-url)))
Now, we want to extract the fields "title", "author", and "link" from that feed.
(set 'field-result (get-fields-from-rss rss-result '("title" "author" "link")))
(("News Post: The Book Of Divine Wisdom" "tycho@penny-arcade.com (Tycho)" " http://penny-arcade.com/2013/01/25/the-book-of-divine-wisdom1")
("News Post: So many games!" "gabe@penny-arcade.com (Gabe)" " http://penny-arcade.com/2013/01/25/so-many-games")
...etc ... )
Views: 330