소스 검색

Include original page url in the file name sent to the editor.

This is similar to what itsalltext does, and allows editors to adjust their
behavior based on the site or page being loaded.
Chouser 14 년 전
부모
커밋
4c39975c60
1개의 변경된 파일7개의 추가작업 그리고 3개의 파일을 삭제
  1. 7 3
      pycl.py

+ 7 - 3
pycl.py

@@ -17,7 +17,7 @@
 import cgi, urlparse
 import subprocess
 import tempfile, time
-import os, sys
+import os, sys, re
 from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
 
 temp_has_delete=True
@@ -50,11 +50,15 @@ class Handler(BaseHTTPRequestHandler):
             print l
 
             # write text into file
+            url = self.headers.getheader('x-url')
+            print "url:", url
+            prefix = "chrome_" + re.sub("[^.\w]", "_", re.sub("^.*?//","",url))
             if temp_has_delete==True:
-                f = tempfile.NamedTemporaryFile(delete=False, suffix='.txt')
+                f = tempfile.NamedTemporaryFile(
+                        delete=False, prefix=prefix, suffix='.txt')
                 fname = f.name
             else:
-                tf = tempfile.mkstemp(suffix='.txt')
+                tf = tempfile.mkstemp(prefix=prefix, suffix='.txt')
                 f = os.fdopen(tf[0],"w")
                 fname = tf[1]