Skip to content

Commit

Permalink
Merging changes from saturnflyer's blog extension into a fresh branch.
Browse files Browse the repository at this point in the history
Merge branch 'master' of git://github.com/saturnflyer/radiant-blog-extension into blog

Conflicts:

	README
	Rakefile
	app/models/sibling_tags.rb
	spec/models/sibling_tags_spec.rb
  • Loading branch information
nelstrom committed Oct 26, 2008
1 parent 06867e6 commit 67e91de
Show file tree
Hide file tree
Showing 4 changed files with 279 additions and 318 deletions.
90 changes: 7 additions & 83 deletions README
@@ -1,86 +1,10 @@
= Sibling Tags
= Blog

This extension for Radiant provides tags allowing you to refer to the neighbouring siblings of a page.
The Blog extension has been built to provide support for commonly used features of
web logs. It is a conglomeration of multiple extensions and new features.

== Installation
Some features from:
git://github.com/nelstrom/radiant-sibling-tags-extension.git

If your Radiant site is running on version 0.6.9 or greater, you can install extensions very easily. If you are using an older version of Radiant, don't worry, it is still quite straightforward. Instructions follow for both.

=== Installing for Radiant 0.6.9+

In a terminal, <tt>cd</tt> to the root directory of your Radiant site. Run the following command:

script/extension install sibling_tags

That's it!

=== Installing for Radiant pre-0.6.9

This extension is hosted on github. If you have git installed, then <tt>cd</tt> to the root of your radiant project and issue this command:

git clone git://github.com/nelstrom/radiant-sibling-tags-extension.git vendor/extensions/sibling_tags

If you don’t have git, then you can instead download the tarball from this URL:

http://github.com/nelstrom/radiant-sibling-tags-extension/tarball/master

and expand the contents to <tt>your-radiant-project/vendor/extensions/sibling_tags</tt>.

This extension does not modify the database, so there is no need to run any migrations. Your done!

== Usage

When you restart you Radiant site, you should have access to the sibling tags in regular pages of your site. Documentation for each individual tag is provided within Radiant. If you go to edit a page, then click the '<b>Available tags</b>' link, you should see a list of all the available tags. You can filter the list, by typing 'sibling' into the field at the top right of the window.

For examples of usage, we'll use the following site map:

Title Date of Publication
---------------- -------------------
Home
\_Articles
\_Apple 2008-02-29
\_Brocolli 2007-12-17
\_Carrot 2008-01-25

Using the sibling tags, you can access immediate neighbours of a page. But which pages are considered neighbours depends upon how you shuffle the deck! You can sort pages by any field that is stored in the database. Most likely you will want to sort by date of publication, or by page title. These could also be arranged in ascending or descending order.

By default, pages are sorted in ascending order of publication, i.e. from oldest to newest. The children of 'Articles' in the above site map would be arranged as follows:

Default order: Brocolli, Carrot, Apple

Lets examine the following snippet of code:

<r:siblings>
<r:previous>Previous article: <r:link/></r:previous>
<r:next>Next article: <r:link/></r:next>
</r:siblings>

If this was called on the 'Carrot' page, it would output:

Previous article: <a href="/articles/brocolli">Brocolli</a>
Next article: <a href="/articles/apple">Apple</a>

Whereas, if the same snippet was called from the 'Brocolli' page, it would output:

Next article: <a href="/articles/carrot">Carrot</a>

When arranged in the default sort order, 'Brocolli' comes first, so it has no predecessor. Hence, the contents of the <tt><r:siblings:previous></r:siblings:previous></tt> tag are not output.

You can change the sort order using the <tt>order</tt> and <tt>by</tt> attributes. <tt>order</tt> can either be <tt>asc</tt> or <tt>desc</tt>, whereas <tt>by</tt> can be any column name associated with a page in the database.

The following lists demonstrate how the 'Articles' pages above could be sorted:

order="desc": Apple, Carrot, Brocolli
by="title": Apple, Brocolli, Carrot
by="title" order="desc": Carrot, Brocolli, Apple

Remember that the default values are <tt>order="asc"</tt> and <tt>by="published_at"</tt>, so if either of these are not specified, they fall back to those values.

One final example demonstrates how these sorting options may be applied:

<r:siblings>
<r:previous by="title">Previous in alphabet:<r:link/></r:previous>
<r:unless_previous by="title">This is the start of the alphabet.</r:unless_previous>
<r:next by="title">Next in alphabet: <r:link/></r:next>
<r:unless_next by="title">This is the end of the alphabet.</r:unless_next>
</r:siblings>
Built by Saturn Flyer http://www.saturnflyer.com and many others
Supported by Ignite Social Media http://www.ignitesocialmedia.com
16 changes: 3 additions & 13 deletions Rakefile
@@ -1,5 +1,3 @@
# I think this is the one that should be moved to the extension Rakefile template

# In rails 1.2, plugins aren't available in the path until they're loaded.
# Check to see if the rspec plugin is installed first and require
# it if it is. If not, use the gem version.
Expand Down Expand Up @@ -62,14 +60,6 @@ namespace :spec do
t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
end
end

# Hopefully no one has written their extensions in pre-0.9 style
# desc "Translate specs from pre-0.9 to 0.9 style"
# task :translate do
# translator = ::Spec::Translator.new
# dir = RAILS_ROOT + '/spec'
# translator.translate(dir, dir)
# end

# Setup specs for stats
task :statsetup do
Expand Down Expand Up @@ -99,17 +89,17 @@ namespace :spec do
end
end

desc 'Generate documentation for the sibling_tags extension.'
desc 'Generate documentation for the blog extension.'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'SiblingTagsExtension'
rdoc.title = 'BlogExtension'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README')
rdoc.rdoc_files.include('lib/**/*.rb')
end

# For extensions that are in transition
desc 'Test the sibling_tags extension.'
desc 'Test the blog extension.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
Expand Down

0 comments on commit 67e91de

Please sign in to comment.