Commits

Gabriele Lanaro committed f2d8428

added new module and starting to write the mode

Comments (0)

Files changed (2)

 
-(defvar eblog-mode-map nil "Local keymap for dired-mode buffers.")
+(defvar blogger-mode-map nil "Local keymap for dired-mode buffers.")
+(defvar blogger-username nil "Username used to log in")
+(defvar blogger-password nil "Password to log in")
+
+(defun echofun (val)
+  (lambda (aa) (message val)))
+
+(defun blogger-quit ()
+  "quit the blogger buffer"
+  (interactive)
+  (when (eq major-mode 'blogger-mode)
+    (kill-buffer-and-window))
+  )
+
+(defun blogger-show ()
+  "Starts a buffer with the blogs listed and shows the entries of
+  each blog, in Blogger mode"
+  (interactive)
+  ;; If no username and password defined, read from the minibuffer
+  (when (not (or blogger-username blogger-password))
+    (setq blogger-username (read-from-minibuffer "Username: "))
+    (setq blogger-password (read-passwd "Password: ")))
+  (pop-to-buffer (generate-new-buffer "Blogger"))
+  (blogger-mode)
+  (blogger-create-bloglist))
 
 ;; Making a keymap!!!
 (let ((map (make-keymap)))
   (suppress-keymap map)
-  (define-key map [mouse-2] 'dired-mouse-find-file-other-window)
   ;; Commands to mark or flag certain categories of files
-  (define-key map "#" 'dired-flag-auto-save-files)
-  (define-key map "." 'dired-clean-directory)
-  (define-key map "~" 'dired-flag-backup-files)
-  (define-key map "&" 'dired-flag-garbage-files)
-  (setq dired-mode-map map))
+  (define-key map "m"  (echofun "m"))
+  (define-key map "." (echofun "n"))
+  (define-key map "q" 'blogger-quit)
+  (setq blogger-mode-map map))
 
 
-(defun eblog-mode ()
+(defun blogger-mode ()
   "Mode for watching the blogs in blogger(?)"
   (interactive)
 
   ;; Adding the local variables
   (kill-all-local-variables)
   ;; Setting the major mode
-  (setq major-mode 'eblog-mode)
+  (setq major-mode 'blogger-mode)
   ;; Pretty name in the mode line
-  (setq mode-name "Eblog Mode")
-  (use-local-map eblog-mode-map)
-  (buffer-read-only t)  
+  (setq mode-name "Blogger Mode")
+  (use-local-map blogger-mode-map)
+  (setq buffer-read-only t)  
   )
+import re
+from BeautifulSoup import BeautifulSoup
+
+def pipe(*a):
+    '''takes functions to pipe in a single function
+    '''
+    def fun(arg):
+        for function in a:
+            arg = function(arg)
+        return arg
+    return fun
+        
+def extract_body(html):
+    '''
+    Extract the body part from the html string
+    '''
+    soup = BeautifulSoup(html)
+    body = soup.findAll("body")[0]
+    return "".join(str(element) for element in body.contents)
+
+def degrade_sections(html):
+    '''Degrade h1 to h2 , h2 to h3 etc...
+    '''
+    soup = BeautifulSoup(html)
+    for i in range(1,6)[::-1]:
+        headers = soup.findAll("h%d"%i)
+        for head in headers:
+            head.name = "h%d"%(i+1)
+    return str(soup)