[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [emacs-wiki-discuss] Re: menus again
From: |
Marc Tommasi |
Subject: |
Re: [emacs-wiki-discuss] Re: menus again |
Date: |
Fri, 17 Sep 2004 08:49:02 +0200 |
User-agent: |
Mozilla Thunderbird 0.7.3 (X11/20040803) |
Hello,
A small patch to add menus to wiki pages. There are several ways to
produce menus
- from a default one
- from the list of projects
- from a file
- from an inline directive #menu in the first line of a wiki page
Last two ways declare menus in the following way
#menu (("menuitem1" "url1" "tooltip1")("menuitem2" "url2" "tooltip2") ... )
(I'm an elisp beginner, hope this helps anyway...)
Marc.
--
Marc Tommasi --- http://www.grappa.univ-lille3.fr/~tommasi
UFR MSES Univ. de Lille 3 59653 Villeneuve d'Ascq cedex -- FRANCE
Phone:(+33)320416175 --- Fax:(+33)320416770
--
N'ajoutez pas mon email dans votre carnet d'adresses Outlook SVP.
Please do not add my email in your Outlook addressbook.
2314a2315,2317
>
> <lisp>(funcall emacs-wiki-menu-factory)/lisp>
>
2395a2399,2464
>
>
> (defcustom emacs-wiki-menu-factory 'emacs-wiki-menu-from-projects
> " Selects the way to produce menu
> 'emacs-wiki-menu-fixed : the value of emacs-wiki-default-menu
> 'emacs-wiki-menu-no-menu : no menu in the page
> 'emacs-wiki-menu-from-projects : create menus items from the project lists
> 'emacs-wiki-menu-from-file : create menus from a file
> "
> :type 'function
> :group 'emacs-wiki-publish
> )
>
> (defcustom emacs-wiki-menu-filename ".menu-emacs-wiki"
> "The filename where the menu stands in the working dir"
> :type 'string
> :group 'emacs-wiki-publish
> )
>
> (defcustom emacs-wiki-top-menu
> "<script language=\"javascript\">
> function showToolTip(machaine) {
> if (machaine != \"\") {
> document.getElementById('tooltip').innerHTML = machaine;
> document.getElementById('tooltipbox').style.visibility = 'visible';
> }
> }
> function hide() {
> document.getElementById('tooltip').innerHTML = '';
> document.getElementById('tooltipbox').style.visibility = 'hidden';
> }
> </script>
> <div class=\"menu\">
> "
> " html code prepend to the menuitems when 'emacs-wiki-menu-factory
> is 'emacs-wiki-menu-from-projects or the inline #menu is used."
> :type 'string
> :group 'emacs-wiki-publish
> )
>
>
> (defcustom emacs-wiki-bottom-menu
> "
> </div><!-- menu ends here -->
> <div id=\"tooltipbox\">
> <div id=\"tooltip\"></div>
> </div>"
> " html code prepend to the menuitems when 'emacs-wiki-menu-factory
> is 'emacs-wiki-menu-from-projects or the inline #menu is used."
> :type 'string
> :group 'emacs-wiki-publish
> )
>
> (setq emacs-wiki-current-menu nil)
>
> (defcustom emacs-wiki-default-menu
> "<div class=\"menu\">
> <div class=\"menuitem\"><a href=\"/\">Home</a></div>
> </div>\n"
> "list of menuitems. Each menu item is a 3-element list
> text, url and tooltip
> "
> :type 'string
> :group 'emacs-wiki-publish
> )
>
2430a2500,2542
> .menu {
> border-top:5px solid lightgrey;
> border-bottom:5px solid lightgrey;
> content: \"Menu\";
> background: #F5F5F5;
> color: white;
> display: inline-table;
> float:right;
> padding: .5em;
> }
>
> .menuitem{
> margin: .2em;
> text-align: center;
> }
>
> .menuitem a:link,.menuitem a:visited{
> color: darkgreen;
> text-decoration: none;
> }
>
> .menuitem a:hover {
> background:lightgrey;
> }
>
> .menuitem a:hover:before { content:\"ยป \"}
> .menu:before{
> color: grey;
> display: block;
> content:\"Menu\" ;
> text-align: center;
> border: 1pt solid;
> }
>
> #tooltipbox{
> float: right;
> visibility: hidden;
> }
>
> #tooltip{
> color: lightgrey;
> }
>
2484c2596
< ["^#\\(title\\|date\\|style\\|related\\)\\s-+\\(.+\\)\n+" 0
---
> ["^#\\(menu\\|title\\|date\\|style\\|related\\)\\s-+\\(.+\\)\n+" 0
3223a3336,3422
>
> (defun emacs-wiki-menu-fixed ()
> (or emacs-wiki-current-menu emacs-wiki-default-menu)
> )
>
> (defun emacs-wiki-menu-no-menu ()
> (or emacs-wiki-current-menu "\n<!-- No menu -->\n")
> )
>
>
> (defun emacs-wiki-project-homepage (proj)
> "Give the url of project "
> ; I assume no server-prefix => private is it wrong ?
> (let ((prefix (cdr (assoc 'emacs-wiki-project-server-prefix (cddr
> proj)))))
> (and prefix (concat prefix
> (or (cdr (assoc 'emacs-wiki-default-page (cddr proj) ))
> (concat "/" emacs-wiki-default-page))))
> )
> )
>
> (defun emacs-wiki-menu-from-projects ()
> " build a menu according to the list of projects "
> (or emacs-wiki-current-menu
> (let ((projs emacs-wiki-projects) (str))
> (while projs
> (setq url (emacs-wiki-project-homepage (car projs))) ; url
> (and url ; no url = private project...
> (setq str (concat str
> "<div class=\"menuitem\">\n <a href=\""
> url
> "\">"
> (car(car projs)) ; text
> "</a>\n</div>\n"
> )))
> (setq projs (cdr projs)))
> (concat emacs-wiki-top-menu str emacs-wiki-bottom-menu))
> ))
>
> (defun emacs-wiki-menu-from-file ()
> "Build a menu according to the contents of a file in the same form as
> described in 'emacs-wiki-make-menu-from-list
> "
> (or emacs-wiki-current-menu
> (emacs-wiki-make-menu-from-list
> (save-excursion
> (let ( (buffer (find-file-noselect emacs-wiki-menu-filename)) )
> (and buffer
> (progn
> (set-buffer buffer)
> (setq buffer-read-only t)
> (beginning-of-buffer)
> (and (re-search-forward "^#\\(menu \\)\\(.*\\)$" nil t)
> (setq resu (match-string 2)))
> (kill-buffer buffer)
> )
> )
> ; resu)
> (car (read-from-string resu)) )
> )
> ))
> )
>
>
>
>
>
> (defun emacs-wiki-make-menu-from-list (menu)
> "Argument is a list of 3tuples of the form text, url, tooltip"
> (let (str)
> (while menu
> (setq str (concat str
> " <div class=\"menuitem\">\n <a href=\""
> (cadr(car menu)) ; url
> "\" onMouseOut=\"hide()\" "
> "onMouseOver=\"showToolTip("
> (caddr(car menu)) ; tooltip
> ")\">"
> (car(car menu)) ; text
> "</a>\n </div>\n"
> ))
> (setq menu (cdr menu))
> )
> (concat emacs-wiki-top-menu str emacs-wiki-bottom-menu)
> )
> )
>
>
>
3225a3425,3427
> ((string= (match-string 1) "menu")
> (set (make-local-variable 'emacs-wiki-current-menu)
> (emacs-wiki-make-menu-from-list (car (read-from-string (match-string
> 2))))))
3973a4176
> ; (insert tag)