OneLevelUp - butscher/WikidPad GitHub Wiki

Note:

The feature this plugin implements is part of Wikidpad starting with version 2.1beta10.

BR

# -*- coding: utf-8 -*-

# One Level Up plugin
# ====================
#
# Moves up one level in the subpages hierarchy.
# 
# For example we are in Food/Fruits/Papaya page
# One Level Up will move to Food/Fruits page
#
# by aless 21 Nov 2010, license GPL
   
import re
    
# === Menu items ===

# descriptor for EditorFunctions plugin type
WIKIDPAD_PLUGIN = (("MenuFunctions",1),)

def describeMenuItems(wiki):
    return ((up_one_level, u'MyUtils|Up one level\tAlt-1' , ''),)

    

def up_one_level(wiki, evt):
    
    page_name = wiki.getCurrentWikiWord()
      
    # matches whole path up to the last slash included
    match = re.match(r'^(.*/)', page_name)
    
    if match is None:
        
        return
        
    else:
    
        # strips trailing slash (/)
        one_level_up = match.group(1)[:-1]
        
        wiki.openWikiPage(one_level_up)
        wiki.getActiveEditor().SetFocus()
   

#EOF
⚠️ **GitHub.com Fallback** ⚠️