فهرست منبع

[search] Add file visualization in browser window

Romain Rigaux 12 سال پیش
والد
کامیت
49a4466b3d

+ 2 - 1
apps/filebrowser/src/filebrowser/views.py

@@ -107,6 +107,7 @@ def download(request, path):
     Downloads a file.
 
     This is inspired by django.views.static.serve.
+    ?disposition={attachment, inline}
     """
     if not request.fs.exists(path):
         raise Http404(_("File not found: %(path)s") % {'path': escape(path)})
@@ -126,7 +127,7 @@ def download(request, path):
     response = HttpResponse(_file_reader(fh), mimetype=mimetype)
     response["Last-Modified"] = http_date(stats['mtime'])
     response["Content-Length"] = stats['size']
-    response["Content-Disposition"] = "attachment"
+    response['Content-Disposition'] = request.GET.get('disposition', 'attachment')
     return response
 
 

+ 21 - 1
apps/search/src/search/models.py

@@ -196,7 +196,27 @@ class CoreManager(models.Manager):
                    'dates': []
                 }))
       result = Result.objects.create(data=json.dumps({
-                  'template': '{{id}} To customize!<br/>',
+                  'template': """
+<div class="row-fluid">
+  <div class="span1"><img src="http://twitter.com/api/users/profile_image/{{user_screen_name}}" style="margin:10px"></div>
+  <div class="span9">
+    <h5>{{user_name}}</h5>
+    {{text}}
+    <br>    
+    <a href="/filebrowser/view/{{file_path}}">
+      {{file_name}} {{content_type}} {{file_length}}{{#file_length}} bytes{{/file_length}}
+    </a>
+    {{#file_path}}
+    <a href="/filebrowser/download{{file_path}}?disposition=inline">
+      Download
+    </a>
+    {{/file_path}}
+  </div>
+  <div class="span2"><br><a class="btn" href="https://twitter.com/{{user_screen_name}}/status/{{id}}" target="_blank" title="Open in Twitter">
+    <i class="icon-twitter"></i></a>
+  </div>
+</div>                  
+                  """,
                   'highlighting': [],
                   'properties': {'highlighting_enabled': False},
               }))

+ 2 - 6
apps/search/src/search/templates/admin_core_template.mako

@@ -68,9 +68,6 @@ ${ commonheader(_('Search'), "search", user) | n,unicode }
 
         <div class="row-fluid">
           <div class="span12">
-            <div>
-             ${ _('Edit the result snippet below.') }
-            </div>
             <div id="toolbar"></div>
             </br>
             <div id="content-editor" class="clear">${ hue_core.result.get_template() | n,unicode }</div>
@@ -103,7 +100,7 @@ ${ commonheader(_('Search'), "search", user) | n,unicode }
             <textarea id="template-source"></textarea>
           </div>
 
-          <div class="span3">
+          <div class="span3">          
             <div class="well available-fields">
               <h4>${_('Available Fields')}</h4>
               <ul data-bind="foreach: fields">
@@ -151,7 +148,6 @@ ${ commonheader(_('Search'), "search", user) | n,unicode }
       </div>
     </div>
 
-
   </%def>
 </%layout:skeleton>
 
@@ -208,7 +204,7 @@ ${ commonheader(_('Search'), "search", user) | n,unicode }
         if (self.lastIndex() > contentEditor.childNodes.length || self.lastIndex() < 0) {
           self.lastIndex() = contentEditor.childNodes.length - 1;
         }
-        var text = document.createTextNode("{{" + field + "}}");
+        var text = document.createTextNode(" {{" + field + "}}");
         if (contentEditor.childNodes.length) {
           console.log(self.lastIndex());
           console.log(contentEditor.childNodes);

+ 1 - 1
apps/search/src/search/templates/index.mako

@@ -159,7 +159,7 @@ ${ commonheader(_('Search'), "search", user, "40px") | n,unicode }
       <%
         docs = response['response']['docs']
         for doc in response['response']['docs']:
-          if doc['id'] in response['highlighting']:
+          if doc['id'] in response.get('highlighting', []):
             doc.update(response['highlighting'][doc['id']])
         %>
         $.each(${ json.dumps([result for result in docs]) | n,unicode }, function (index, item) {

+ 30 - 8
dist/README

@@ -6,12 +6,30 @@ for more details.
 
 ## Install
 $ PREFIX=/usr/share make install
-$ sudo chmod 4750 $PREFIX/hue/apps/shell/src/shell/build/setui
-$ sudo chown root:$USER $PREFIX/hue/apps/shell/src/shell/build/setui
 
-## Install plug-ins
-$ cd /usr/lib/hadoop-0.20-mapreduce/lib
-$ ln -s /usr/share/hue/desktop/libs/hadoop/java-lib/hue*jar
+(dependencies might be missing from https://github.com/cloudera/hue#development-prerequisites)
+
+## Configure Solr
+Edit conf/hue.ini:
+
+[search]
+
+   # URL of the Solr Server
+   ##solr_url=http://localhost:1978/solr/
+
+## Run!
+$ /usr/share/hue/build/env/bin/supervisor
+
+
+
+Go to http://localhost:8888/
+
+Please report feeback!
+
+
+
+
+## For enabling file download
 
 ## Configure Hadoop
 Edit hdfs-site.xml:
@@ -21,6 +39,13 @@ Edit hdfs-site.xml:
   <value>true</value>
 </property>
 
+
+## Optional 
+
+## Install plug-ins
+$ cd /usr/lib/hadoop-0.20-mapreduce/lib
+$ ln -s /usr/share/hue/desktop/libs/hadoop/java-lib/hue*jar
+
 Edit mapred-site.xml:
 
 <property>
@@ -29,6 +54,3 @@ Edit mapred-site.xml:
   <description>Comma-separated list of jobtracker plug-ins to be activated.
   </description>
 </property>
-
-## Run!
-$ /usr/share/hue/build/env/bin/supervisor