1 ;; -*- coding: utf-8-mcs-er -*-
2 (require 'cwiki-common)
8 (defun est-format-props (props)
15 (setq key (symbol-name key)))
16 (if (eq (aref key 0) ?:)
17 (setq key (substring key 1)))
19 (format "%s %s=\"%s\""
21 (www-format-encode-string
23 (est-format-unit val 'without-tags
24 'without-edit 'as-property))
28 (defun est-format-unit (format-unit
29 &optional without-tags without-edit as-property
31 (let (name props children ret object feature format value)
33 ((stringp format-unit)
34 (www-format-encode-string format-unit without-tags (not as-property))
37 (setq name (car format-unit)
38 props (nth 1 format-unit)
39 children (nthcdr 2 format-unit))
44 (when (setq object (plist-get props :object))
48 (list :href (www-uri-make-object-url object))
52 (when (and (not without-tags)
53 (setq object (plist-get props :object))
54 (setq feature (plist-get props :feature))
55 (setq value (www-get-feature-value object feature))
56 (setq ret (find-previous-defined-code-point feature value)))
60 (list :href (www-uri-make-object-url ret))
64 (when (and (not without-tags)
65 (setq object (plist-get props :object))
66 (setq feature (plist-get props :feature))
67 (setq value (www-get-feature-value object feature))
68 (setq ret (find-next-defined-code-point feature value)))
72 (list :href (www-uri-make-object-url ret))
75 ((eq name 'feature-name)
78 (when (and (setq object (plist-get props :object))
79 (setq feature (plist-get props :feature)))
84 (www-uri-make-feature-name-url
85 (www-uri-encode-feature-name feature)
86 (www-uri-encode-object object)))
91 (if (consp (car children))
96 (list (list 'edit-value
98 (list* :format format props)
101 (:type "submit" :value "edit")))))))
104 props (list* :class "value" props)))
107 (setq ret (plist-get props :ref))
108 ;; (unless (stringp ret)
109 ;; (setq props (plist-remprop (copy-list props) :ref))
111 ;; (cons (list 'ref nil ret)
115 props (list* :href ret
116 (plist-remprop (copy-list props) :ref))))
118 ((and (eq name 'edit-value)
119 (setq object (plist-get props :object))
120 (setq feature (plist-get props :feature)))
121 (setq format (or (plist-get props :format) 'default))
123 props (list :href (format "%s?%s=%s&feature=%s&format=%s"
125 (est-object-genre object)
126 (www-uri-encode-object object)
127 (www-uri-encode-feature-name feature)
137 (setq props (list* :class name props)
141 (setq separator (plist-get props :separator)))
144 (est-format-list children without-tags as-property separator)
145 (format "<%s%s>%s</%s>"
148 (est-format-props props)
151 children nil without-edit as-property separator)
156 name (est-format-props props))))
159 (format "%s" format-unit)))))
161 (defun est-format-list (format-list
162 &optional without-tags without-edit as-property
164 (if (atom format-list)
166 format-list without-tags without-edit as-property separator)
167 (mapconcat (lambda (unit)
169 unit without-tags without-edit as-property separator))
170 format-list separator)))
176 (provide 'est-format)
178 ;;; est-format.el ends here