El Dorado

A full-stack community web application written in Ruby/Rails
Fri, 23 May 2008, 3:28pm bbcode lists »
irkenInvader
Member
Zim
Registered: May, 2008
Last visit: Wed, 04 Jun 2008
Posts: 85

Ok

Here are the changes I'll be making to my site to add [list] blocks to my bbcodeizer:

In the bbcodeizer.rb file, I added the following to the Tags hash:

:start_list            => [ /\[list\]/i, '<ul>' ],
:list_item => [ /\[\*\](.+?)(?:\r\n?)/, '<li>\1</li>' ],
:end_list => [ /\[\/list\]/i, '</ul>' ],

In the same file, the TagsList array looks like this:

TagList = [ :bold, :italic, :underline, :email_with_name, :email_sans_name, 
:url_with_title, :url_sans_title, :image, :size, :color, :code,
:quote, :youtube, :googlevid, :flash, :spoiler, :nsfw, :hide, :mp3,
:superdeluxe, :comedycentral, :revver, :myspacetv, :collegehumor,
:metacafe, :yahoovid, :flickr, :gametrailers, :slideshare, :funnyordie,
:atomfilms, :vimeo, :list, :list_item ]

Also in the same file, I added the following function:

def list(string)
# list tags must match, else don't do any replacing.
if string.scan(Tags[:start_list].first).size == string.scan(Tags[:end_list].first).size
apply_tags(string, :start_list, :end_list)
end
end

Finally, I added the following to my application.css stylesheet:

.post-body ul {
margin: 10px !important;
padding: 6px;
}

.post-body li {
list-style-type: disc;
}

The lists now look pretty cool, but I still have the problem with the blockquote element. Task for another day.


Zim wrote:

Invader’s blood marches through my veins like giant, radioactive rubber pants! The pants command me! Do not ignore my veins!

Offline