Changeblog

Per-page editing permissions [21.11.2008]

Just introduced to Blueprint is the new per-page permissions feature. From the Structure tab, you can now assign an access role to each page.

Once assigned, only users belonging to that role — or to any role that allows editing pages from the Structure tab — may edit that page via the Content tab. This include creating posts, configuring the page, et cetera.

Users who don't have permission to edit a page will see it greyed out, with a lock icon replacing the normal page icon, in the Content tab.

Ppperms

You can svn up and rake db:migrate to start using this new feature.

0 comments

Tools for optimising your templates [11.11.2008]

I've just checked in a couple of new methods that might help you figure out the bottlenecks that are slowing down the rendering of your templates.

They are:

  • bench_marker — takes a "label" argument describing this point in the code. In the log, displays the time since the start of the request that this point was reached.
  • bench_measure — takes a "label" argument and block of code. Surrounds the block with bench_marker logging.

You can pass a few flags to bench_measure:skip, which does not execute the block at all, and :echo, which returns the string result of the block rather than concatenating it to the template output (and is therefore only really useful in helpers).

bench_marker takes a hash of options, although only one option is currently checked — :prefix, which lets you change the text that precedes the timestamp in the logs.

Note: like most logging, benchmarking only displays in development logs.

0 comments

Capistrano for remotely manipulating sites and blueprints [07.08.2008]

There's a bunch of existing rake tasks for operating on blueprints and sites -- pushing and pulling data, syncing templates, installing blueprints and sites, erasing blueprints and sites, et cetera.

For the last few months, to perform these operations on remote servers (production or staging), you've had to log into the server as the deploy user, and run the rake task with the correct environment argument.

Now there are Capistrano tasks that allow you to do these things on remote servers from the comfort of your local command-line. Here's the current list of available tasks -- run cap -T for an official list.

cap site:data:pull       
cap site:data:push       
cap site:list            
cap site:retrieve        
cap site:templates:update

cap blueprint:install    
cap blueprint:migrate    
cap blueprint:uninstall  
cap blueprint:upgrade:all

Each cap task takes the same arguments as its rake equivalent. Assuming you have set up your config/hosts.yml file correctly, you can invoke them like this:

$ cap site:data:push domain=foo.org rails_env=staging

The rails_env determines which hosts the action is performed on. To save typing, you might want to set up the following bash aliases:

alias pcap='RAILS_ENV=production cap'
alias scap='RAILS_ENV=staging cap'

Then you can run the same command more succinctly:

$ scap site:data:push domain=foo.org

0 comments

Rake tasks for creating new blueprint modules [07.08.2008]

Until recently, you used the script/generate task to create new blueprint modules. Now that blueprints are stored in a separate repository, however, this approach has been deprecated in favour of a rake task that not only generates the requisite files and directories, but imports them into your blueprint repository, and checks them out for you.

You can learn about the rake tasks using the -D describe switch:

$ rake -D blueprint:create
rake blueprint:create
    Generate a new blueprint, checking it into a blueprint repository. 
        Arguments:
          CODE    - the blueprint code for the new blueprint
          ACTIONS - string list of actions (white-space separated) for which to
                    create templates and controller actions.

rake blueprint:create:inherit
    Generate a new blueprint inheriting from an existing blueprint, checking 
          it into the selected repository. Arguments:
            CODE    - the blueprint code for the child blueprint
            PARENT  - the blueprint code for the parent blueprint

So, for example, to create a 'Directory' blueprint:

rake blueprint:create CODE=dir ACTIONS="index list item alphabetical by_publication_date"

Or to extend the existing 'Gallery' blueprint to handle videos:

rake blueprint:create:inherit PARENT=gly CODE=vidgly

0 comments

The hosts.yml file [06.08.2008]

This is a fairly major change, and requires some explanation.

As Blueprint is now being used by developers other than Inventive Labs, anyone might potentially want to create custom blueprint modules. Previously these were all in the core Blueprint repository; this update has moved them into separate repositories. The 'Page' and 'Search' blueprint modules are the only ones that come with Blueprint core. The rest of the core modules have been moved to http://canister.inventivelabs.com.au/blueprints/core.

You can add your own repository for custom blueprints. The mechanism for this is the new config/hosts.yml file, which replaces Rails' built-in database.yml file. You'll need to create this file -- you can base it off the hosts.sample.yml file in the same directory. Define your site and blueprint repositories (you should probably retain the 'core' blueprints repository), and set up your databases as you previously did for databases.yml.

Once this is done, you need to follow a one-off upgrade path:

rm -rf app
svn up
rake blueprint:upgrade:all

One of the benefits of this change is that you no longer need to enter the 'Repository root' for a site when running rake site:retrieve.

0 comments

Asset captions [15.07.2008]

The 'Bluedown' text formatter has had an upgrade, providing marked-up caption text for images inserted into text fields.

As you know, you can insert an image into text with the following syntax:

[[example]]

Which results in markup like this:

<img alt="Example" src="/static/files/assets/4068c115/example.jpg" title="Example" />

There are a bunch of options you can add to the asset tag, such as:

[[example|class=left,size=thumb]]

Which modify the resultant HTML in certain ways:

<img alt="Example" class="left" src="/static/files/assets/4068c115/example_thumb.jpg" title="Example" />

Just added is the ability to do captions, by attaching parenthesised text to the end of the asset tag:

[[example]](This is a free markdown area, until the next closing parenthesis not 
preceded by a backslash. So this won't close the caption: \) but this *will*: )

Which gives markup like the following:

<div class="captioned">
  <img alt="Example" src="/static/files/assets/4068c115/example.jpg" title="Example" />
  <blockquote><p>This is a free markdown area, until the next closing parenthesis not 
  preceded by a backslash. So this won't close the caption: ) but this <em>will</em>: </p></blockquote>
</div>

That is, the image tag is enclosed in a div tag with the class captioned, which also contains a blockquote containing the marked-up caption text. You can then style this however you like with CSS.

0 comments