Commits

Anonymous committed b7e2a3c Merge

merge done

Comments (0)

Files changed (8)

 132cdf592e5d62733f79d94df607aa772537ee03 0.3.0
 ee5709ecaaabe4b82c18bab3f828bf953ba7b625 0.3.1
 896db12210b39b6a55defb83d076bf794b7dac7f 0.3.2
+896db12210b39b6a55defb83d076bf794b7dac7f 0.3.2
+cf65b9505928ff73b72520f6595addf4b691dfb7 0.3.2
+c4bb80ee1f956e93c2f0eed1a8ce9ed3895be4c6 0.3.3
 
 setup(
     name='tgapp-smallpress',
-    version='0.3.1',
+    version='0.3.3',
     description='Pluggable Minimalistic Blog for TurboGears2 with Attachments and Tags',
     long_description=README,
     author='Alessandro Molina',

smallpress/controllers/root.py

                                   (l_('Tags'), comma_separated_tags),
                                   (l_('Author'), 'author'),
                                   (l_('Publishing'), lambda row:format_published(row) + ', ' + format_date(row))])
+
 attachments_table = DataGrid(fields=[(l_('Actions'), lambda row:link_buttons(row, 'rmattachment')),
                                      (l_('Name'), 'name'),
+                                     (l_('Preview'), attachment_preview),
                                      (l_('Url'), lambda row:format_link(row.url))])
 
 def inject_css(*args, **kw):

smallpress/helpers.py

 
 def format_link(url):
     return html.builder.HTML.a(url, href=url, target='_blank')
+
+def attachment_preview(attachment):
+    attachment_mime_type = attachment.mimetype
+    if attachment_mime_type and attachment_mime_type.startswith('image'):
+        preview_url = attachment.url
+    else:
+        preview_url = "/_pluggable/smallpress/images/unknown.png"
+    return html.literal('<img src="%s" class="smallpress_attachment_minipreview"/>' % preview_url)

smallpress/model/models.py

 from tgext.datahelpers.fields import Attachment as DataHelpersAttachment
 from tgext.pluggable import call_partial
 
+import mimetypes
+mimetypes.init()
+
 try:
     import whoosh
     import whoosh.index
             pass
 
     @property
+    def mimetype(self):
+        return mimetypes.guess_type(self.content.local_path, False)[0]
+
+    @property
     def url(self):
         return self.content.url
 

smallpress/public/css/style.css

 
 #smallpress_search .submitbutton:hover {
     background-color: #BBB;
+}
+
+.smallpress_attachment_minipreview {
+    height: 64px;
+}
+
+#smallpress_attachments_title {
+    margin-bottom: 10px;
+}
+
+#smallpress_attachments_title span {
+    font-size: 1.6em;
+}
+
+#smallpress_attachments_title em {
+    margin-left: 10px;
+    font-size: 11px;
 }

smallpress/public/images/unknown.png

Added
New image

smallpress/templates/edit.html

         <h1>Edit Article</h1>
         ${form(value=value, action=action)}
         <div id="smallpress_attachments">
-            <h2>Attachments</h2>
+            <div id="smallpress_attachments_title">
+                <span>Attachments</span><em>Drag previews inside the editor to add images</em>
+            </div>
             <div>
                 ${upload_form(value=dict(article=article.uid))}
             </div>