Seeing as how Craft’s `happylager.dev` demo site comes with a gruntfile, I took a couple minutes to add LiveReload to it. As LiveReload is now part of `grunt-contrib-watch`, it was as easy as adding this into the existing `gruntfile.js`:
```
options: {
livereload: true,
},
```
into the block that looks like:
```
grunt.initConfig({
watch: {
// ...
}
}
```
And then adding `` to the `{%block head %}` of `/templates/_layouts/base.html`:
--
It was finicky at first, but after running `grunt` in the command line and reloading the Chrome browser (which has (link: https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei text: the LiveReload extension)) a bunch of times it caught up and worked.
--
## UPDATE
Thanks very much to (link: https://twitter.com/josh_stewart text: @josh_stewart) for showing me a similar — but *maybe better* — way to do this with (link: http://gulpjs.com/ text: Gulp) and (link: https://www.browsersync.io/ text: BrowserSync)
The two advantages of BrowserSync: the instructions are super-clear and the LiveReload extension support is full of comments about its lack of updates.
The major part of the gulpfile.js follows:
```
gulp.task('serve', ['styles'], function() {
browserSync.init({
proxy: 'http://SITENAME.dev',
notify: false,
logLevel: 'info',
logConnections: true,
logFileChanges: true,
online: true,
});
gulp.watch('source/sass/*.scss', ['styles']);
gulp.watch('craft/templates/**/*.html').on('change', browserSync.reload);
});
```
and that the last part of the `return` statement in `gulp.task('styles', function () { /* ... */ }` is `.pipe(browserSync.stream());`
Ran into a funny one today while working through learning the (link: https://github.com/pixelandtonic/HappyLager text: CraftCMS demo site):
With happylager.dev set up in MAMP on MacOS, I got spun out trying to determine how to edit the homepage content on the demo site because the admin page at http://happylager.dev/admin/entries/homepage/2-homepage looked like this:
(image: screen-shot-2016-01-19-at-5.36.58-pm.png)
Being new to Craft, I didn't realize it should look like:
(image: screen-shot-2016-01-19-at-5.39.27-pm.png)
After a while, I looked at the source and found this:
```
Fatal error: Maximum function nesting level of '100' reached, aborting! in /Users/max/Code/Craft-Tutorial/craft/app/models/BaseModel.php on line 258
```
Since I don't really use MAMP for development anyway, I simply turned off xDebug in its PHP settings:
(image: mamp_xdebug_2016.png)
and now the admin side of the Craft demo is working as it should.
--
My plan for this week is to get a complete functional prototype of a client site built to match wireframes. Lots of content types that Craft seems well suited for. Pretty stoked.
Two quick *helping-friends* projects this week: two artists who have been making their own sites for years, by hand, and are switching to Squarespace. Both want to keep the archives of their existing static sites, while starting fresh on Squarespace.
So, for *each*, we did the following:
- added a subdomain on the original host for archive.[DOMAIN.com] pointing to the current site's IP address
- checked that that archive.[DOMAIN.com] site was working for a bunch of test links
- made a free (link: https://www.cloudflare.com/plans/ text: CloudFlare) account
- moved the DNS from their host to CloudFlare
- changed the name server from the original host to CloudFlare
- made a text file with a map of the root-level pages and directories on the sites and wrote Squarespace-specific URL forwarding files (Settings / Advanced / URL Mapping)
- did a little `.htaccess` work to route links to an aliased domain
- add the "third-party domain" to Squarespace in its settings
.. and after waiting 24–48 hours for the name server to propagate, which you can check with (link:https://www.whatsmydns.net/ text: whatsmydns.net):
- change the CloudFlare DNS records to a hybrid of the original host (for mail, SPF records, subdomains, a dedicated ftp.* subdomain) and Squarespace ( three A records for @, CNAME for www, a verification subdomain)
Voila.
-
-
-
-