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 (est-object-genre object)
86 (www-uri-encode-feature-name feature)
87 (www-uri-encode-object object)))
92 (if (consp (car children))
97 (list (list 'edit-value
99 (list* :format format props)
102 (:type "submit" :value "edit")))))))
105 props (list* :class "value" props)))
108 (setq ret (plist-get props :ref))
109 ;; (unless (stringp ret)
110 ;; (setq props (plist-remprop (copy-list props) :ref))
112 ;; (cons (list 'ref nil ret)
116 props (list* :href ret
117 (plist-remprop (copy-list props) :ref))))
119 ((and (eq name 'edit-value)
120 (setq object (plist-get props :object))
121 (setq feature (plist-get props :feature)))
122 (setq format (or (plist-get props :format) 'default))
124 props (list :href (format "%s?%s=%s&feature=%s&format=%s"
126 (est-object-genre object)
127 (www-uri-encode-object object)
128 (www-uri-encode-feature-name feature)
139 (setq props (list* :class name props)
143 (setq separator (plist-get props :separator)))
146 (est-format-list children without-tags as-property separator)
147 (format "<%s%s>%s</%s>"
150 (est-format-props props)
153 children nil without-edit as-property separator)
158 name (est-format-props props))))
161 (format "%s" format-unit)))))
163 (defun est-format-list (format-list
164 &optional without-tags without-edit as-property
166 (if (atom format-list)
168 format-list without-tags without-edit as-property separator)
169 (mapconcat (lambda (unit)
171 unit without-tags without-edit as-property separator))
172 format-list separator)))
178 (provide 'est-format)
180 ;;; est-format.el ends here