Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

site_map

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

site_map

  • 0.3.5
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= SiteMap

== Description

SiteMap provides a way to model out your site's views in a hierarchal fashion. You configure your views and then it builds a tree structure from it that is easy to lookup specific nodes and also traverse their relationships, such as parents or children.

== Installation

gem install site_map

== Usage

=== Basic Definition

SiteMap provides a simple syntax for defining a site's views. Add the following to +config/site_map.rb+ (site_map will load this when required) or an initializer for your app:

require 'site_map'
SiteMap.define do |map|
  map.view :home
  map.view :about
  map.view :contact
end

This defines three views home, about and contact. The +view+ method is the most basic way to configure your site map and only requires a unique index as it's first parameter. It simply creates within the site map a view node with the index provided (in this case +home+, +about+ or +contact+).

=== Setting Attributes

Every site map view node also has a +label+, +url+ and +visible+ attribute. The label is the name of the page the node represents and the url is how you navigate to that page. The visible attribute specifies whether this node should be shown. Using these options is simple:

require 'site_map'
SiteMap.define do |map|
  map.view(:home, {
    :label => "Home :app_name",
    :url => "'/home'"
  })
  map.view(:about, {
    :url => "about_path"
  })
  map.view(:contact, {
    :visible => "can_contact?"
  })
end

So same basic configuration, but I've added custom options for the previously mentioned attributes. Firstly, url and visible attributes are intended to be eval'd within the view space (scope) of an app. This allows you to specify very custom ways to determine a path or check if a node should be shown. Label's are not intended to be eval'd, but are dynamic in a different way, by subbing out symbol names with an options hash, again in the view space (scope). This is explained more and used within site map's view helpers.

SiteMap also has other ways to define your site map. Check out the wiki for more help: http://wiki.github.com/jcredding/site_map/

Copyright (c) 2010 John Collin Redding See the attached MIT License.

FAQs

Package last updated on 03 May 2010

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc