From 0d11e68bad5ea7ff891dd1a2f1475c0fd4bd68b6 Mon Sep 17 00:00:00 2001 From: Benjamin Meichsner Date: Wed, 13 May 2009 17:32:43 +0200 Subject: [PATCH] Added syntax help to wiki form. --- app/models/page.rb | 5 +++-- app/views/pages/_form.html.haml | 15 +++++++++++++++ app/views/pages/all.html.haml | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/models/page.rb b/app/models/page.rb index 53816498..6aaa3fa6 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -1,11 +1,12 @@ class Page < ActiveRecord::Base validates_presence_of :title, :body + validates_uniqueness_of :permalink - before_save :set_permalink + before_validation_on_create :set_permalink def set_permalink - if self.permalink.blank? #FIXME: or title.changed? + if self.permalink.blank? self.permalink = Page.count == 0 ? "home" : "#{title.downcase.strip.gsub(/ |\.|@/, '-')}" end end diff --git a/app/views/pages/_form.html.haml b/app/views/pages/_form.html.haml index 9e32c461..0c3645f7 100644 --- a/app/views/pages/_form.html.haml +++ b/app/views/pages/_form.html.haml @@ -1,3 +1,18 @@ +#wiki-syntax-help{:style => "float:right"} + %p + %b Schnelle Formatierungshilfe + %br/ + :plain + [[interner Link]]
+ [externer Link](http://addresse.net)
+ *kursiv*
+ **Fett**
+ * erster Listenpunkt
+ * zweiter Listenpunkt
+ %p + Übersicht über alle Formatierungen: + = link_to "Markdown Cheatsheet", "http://packetlife.net/static/cheatsheets/markdown.pdf", :target => '_blank' + - form_for @page do |f| = f.error_messages diff --git a/app/views/pages/all.html.haml b/app/views/pages/all.html.haml index 168391b4..7c03bdfe 100644 --- a/app/views/pages/all.html.haml +++ b/app/views/pages/all.html.haml @@ -4,7 +4,7 @@ %table %tr - %th Title + %th Titel %th zuletzt aktualisiert - for page in @pages %tr