about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lepus.uberspace.de>2014-12-03 21:55:42 +0100
committerhut <hut@lepus.uberspace.de>2014-12-03 21:55:42 +0100
commitbe79683c98602082b16c6ef0194a22c6f904a572 (patch)
treef64a3df13421308ae06902a0765eafe1434aa105
parent13b6d8413630c00fb1fb7f55cc416bca5ce2425c (diff)
downloadranger-be79683c98602082b16c6ef0194a22c6f904a572.tar.gz
config/commands.py: add papermanager commands
-rw-r--r--ranger/config/commands.py47
-rw-r--r--ranger/ext/papermanager.py3
2 files changed, 50 insertions, 0 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
index 953e2cc3..39334659 100644
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -1281,3 +1281,50 @@ class flat(Command):
         self.fm.thisdir.flat = level
         self.fm.thisdir.load_content()
 
+
+# Papermanager commands
+# --------------------------------
+class paper_title(Command):
+    """
+    :paper_title <title>
+
+    Tells the paper manager to set/update the title of the current file
+    """
+    _key = "title"
+
+    def execute(self):
+        update_dict = dict()
+        update_dict[self._key] = self.rest(1)
+        self.fm.papermanager.set_paper_info(self.fm.thisfile.path, update_dict)
+
+    def tab(self):
+        paperinfo = self.fm.papermanager.get_paper_info(self.fm.thisfile.path)
+        if paperinfo[self._key]:
+            return self.arg(0) + " " + paperinfo[self._key]
+
+
+class paper_authors(paper_title):
+    """
+    :paper_authors <authors>
+
+    Tells the paper manager to set/update the authors of the current file
+    """
+    _key = "authors"
+
+
+class paper_url(paper_title):
+    """
+    :paper_url <authors>
+
+    Tells the paper manager to set/update the url of the current file
+    """
+    _key = "url"
+
+
+class paper_year(paper_title):
+    """
+    :paper_year <authors>
+
+    Tells the paper manager to set/update the year of the current file
+    """
+    _key = "year"
diff --git a/ranger/ext/papermanager.py b/ranger/ext/papermanager.py
index ff6ffb73..0a3e73ac 100644
--- a/ranger/ext/papermanager.py
+++ b/ranger/ext/papermanager.py
@@ -51,6 +51,9 @@ class PaperManager(object):
             self.metadata_cache[filename] = result
             return result
 
+    def set_paper_info(self, filename, update_dict):
+        pass
+
     def _get_metafile_content(self, metafile):
         if metafile in self.metafile_cache:
             return self.metafile_cache[metafile]