Browse Source

add possibility to set tags in the document body

damien 11 years ago
parent
commit
ebce78db29
2 changed files with 22 additions and 11 deletions
  1. 11 0
      pboard/pboard/model/data.py
  2. 11 11
      pboard/pboard/templates/dashboard.mak

+ 11 - 0
pboard/pboard/model/data.py View File

@@ -195,6 +195,17 @@ class PBNode(object):
195 195
       lsTruncatedLabel = self.data_label
196 196
     return lsTruncatedLabel
197 197
 
198
+  @classmethod
199
+  def addTagReplacement(cls, matchobj):
200
+    if matchobj.group(0) == '-': return ' '
201
+    else: return "<span class='badge'>%s</span>" %(matchobj.group(0))
202
+
203
+  def getContentWithTags(self):
204
+    import re
205
+    return re.sub('@(\w+)', PBNode.addTagReplacement, self.data_content)
206
+
207
+
208
+
198 209
 from sqlalchemy.orm import mapper
199 210
 mapper(PBNode, pb_node_table)
200 211
 

+ 11 - 11
pboard/pboard/templates/dashboard.mak View File

@@ -101,16 +101,6 @@ POD :: ${current_node.getTruncatedLabel(40)} [${current_node.getStatus().label}]
101 101
         
102 102
         
103 103
         
104
-        <form style='display: none;' id="current-document-title-edit-form" method='post' action='${tg.url('/edit_label')}'>
105
-          <div class="input-prepend input-append">
106
-            <input type='hidden' name='node_id' value='${current_node.node_id}'/>
107
-            ${POD.CancelButton('current-document-title-edit-cancel-button')}
108
-            <input type='text' name='data_label' value='${current_node.data_label}' class="span2" />
109
-            ${POD.SaveButton('current-document-title-save-cancel-button')}
110
-          </div>
111
-        </form>
112
-
113
-
114 104
       <div class="btn-group">
115 105
         <button class="btn">Status</button>
116 106
         <a class="btn ${current_node.getStatus().css}" href="#"><i class="${current_node.getStatus().icon}"></i> ${current_node.getStatus().getLabel()}</a>
@@ -138,12 +128,22 @@ POD :: ${current_node.getTruncatedLabel(40)} [${current_node.getStatus().label}]
138 128
       
139 129
             <!--</div> PAGE HEADER -->
140 130
       <h3 id="current-document-title">${current_node.data_label}</h3>
131
+        <form style='display: none; margin-top: 1em;' id="current-document-title-edit-form" method='post' action='${tg.url('/edit_label')}'>
132
+          <div class="input-prepend input-append">
133
+            <input type='hidden' name='node_id' value='${current_node.node_id}'/>
134
+            ${POD.CancelButton('current-document-title-edit-cancel-button')}
135
+            <input type='text' name='data_label' value='${current_node.data_label}' class="span2" />
136
+            ${POD.SaveButton('current-document-title-save-cancel-button')}
137
+          </div>
138
+        </form>
139
+
140
+
141 141
 </div>
142 142
       <div class="span5">
143 143
       
144 144
       <p>
145 145
         <div id='current-document-content' class="">
146
-          ${current_node.data_content|n}
146
+          ${current_node.getContentWithTags()|n}
147 147
         </div>
148 148
         <form style='display: none;' id="current-document-content-edit-form" method='post' action='${tg.url('/edit_content')}'>
149 149
           <input type='hidden' name='node_id' value='${current_node.node_id}'/>