Browse Source

redfam: Make get_disc_link() able to return wikilink

Issue #64 (https://git.golderweb.de/wiki/jogobot-red/issues/64)
Jonathan Golder 11 months ago
parent
commit
389c48605e
1 changed files with 10 additions and 2 deletions
  1. 10
    2
      lib/redfam.py

+ 10
- 2
lib/redfam.py View File

@@ -652,10 +652,13 @@ class RedFamWorker( RedFam ):
652 652
         self.status.remove("note_rej")
653 653
         self.status.add( "marked" )
654 654
 
655
-    def get_disc_link( self ):
655
+    def get_disc_link( self, as_link=False ):
656 656
         """
657 657
         Constructs and returns the link to Redundancy discussion
658 658
 
659
+        @param as_link If true, wrap link in double square brackets (wikilink)
660
+        @type as_link bool
661
+
659 662
         @returns  Link to diskussion
660 663
         @rtype  str
661 664
         """
@@ -675,7 +678,12 @@ class RedFamWorker( RedFam ):
675 678
         anchor_code = mwparser.parse( anchor_code ).strip_code()
676 679
 
677 680
         # We try it without any more parsing as mw will do while parsing page
678
-        return ( self.redpage.pagetitle + "#" + anchor_code.strip() )
681
+        link = self.redpage.pagetitle + "#" + anchor_code.strip()
682
+
683
+        if as_link:
684
+            return "[[{0}]]".format(link)
685
+        else:
686
+            return link
679 687
 
680 688
     def disc_section_exists( self ):
681 689
         """