Example #1
0
def get_option(c, q):
    option = {"mark": util.filter_mark(c), "private": util.filter_private(c)}

    if '!' in q:  # all option
        q = q.replace('!', '')
        option['mark'] = 2
        option['private'] = 2
    elif '@' in q:  # private only option
        q = q.replace('@', '')
        option['private'] = 1
    elif '*' in q:  # mark only option
        q = q.replace('*', '')
        option['mark'] = 1

    return (q, option)
Example #2
0
def get_option(c,q):
    option = {
        "mark": util.filter_mark(c),
        "private": util.filter_private(c)
        }

    if '!' in q:   # all option
        q = q.replace('!', '')
        option['mark']=2
        option['private']=2
    elif '@' in q:   # private only option
        q = q.replace('@', '')
        option['private']=1
    elif '*' in q:   # mark only option
        q = q.replace('*', '')
        option['mark']=1

    return (q,option)
Example #3
0
def process_option(c,q):
    result = []
    help_back_string = "enter to go Back"
    help_select_string = ""
    mods = {
        "ctrl": {"valid": False, "subtitle": ""},
        "alt": {"valid": False, "subtitle": ""},
        "cmd": {"valid": False, "subtitle": ""},
        "shift": {"valid": False, "subtitle": ""}
    }
    mark = util.filter_mark(c)
    private = util.filter_private(c)
    sort = util.sql_orderby(c)

    if q.startswith("_mark"):
        result.append({"title": "mark [filter] - "+util.filter_option[mark],
                       "subtitle": help_back_string,
                       "valid": False,
                       "autocomplete":"_",
                       "mods": mods
        })
        add_option_submenu(result,mods,"mark",mark)
    elif q.startswith("_private"):
        result.append({"title": "private [filter] - "+util.filter_option[private],
                       "subtitle": help_back_string,
                       "valid": False,
                       "autocomplete":"_",
                       "mods": mods
        })
        add_option_submenu(result,mods,"private",private)
    elif q.startswith("_sort"):
        result.append({"title": "sort - "+util.sort_option[sort],
                       "subtitle": help_back_string,
                       "valid": False,
                       "autocomplete":"_",
                       "mods": mods
        })
        add_option_submenu(result,mods,"sort",sort)
    elif q.startswith("_pbauth"):
        result.append({"title": "_pbauth username:token",
                       "subtitle": "Setup Pinboard authentication token",
                       "valid": False,
                       "mods": mods
        })
        if ' ' in q and ':' in q:
            result[0]['valid'] = True
            result[0]['arg'] = '_auth='+q.split(' ')[1]
            result[0]['subtitle'] = "Enter to set"
    else:
        result.append({"title": "Settings",
                       "subtitle": "enter to go Back",
                       "valid": False,
                       "autocomplete": "",
                       "mods": mods
                       })
                       
        result.append({"title": "mark [filter] - "+util.filter_option[mark],
                       "subtitle": help_select_string,
                       "valid": False,
                       "autocomplete":"_mark",
                       "mods": mods
        })
        result.append({"title": "private [filter] - "+util.filter_option[private],
                       "subtitle": help_select_string,
                       "valid": False,
                       "autocomplete":"_private",
                       "mods": mods
        })
        result.append({"title": "sort - "+util.sort_option[sort],
                       "subtitle": help_select_string,
                       "valid": False,
                       "autocomplete":"_sort",
                       "mods": mods
        })
        auth = util.authinfo(c)
        if auth:
            result.append({"title": "> Pinboard User - %s"%auth.split(':')[0],
                           "subtitle": 'enter to change',
                           "valid": False,
                           "autocomplete":"_pbauth ",
                           "mods": mods
            })
            result.append({"title": ">> Download pinboard data",
                           "subtitle": 'enter to reload pinboard',
                           "valid": True,
                           "arg": "_pbreload",
                           "autocomplete":"_pbreload ",
                           "mods": mods
            })
        else:
            result.append({"title": ">> Login Pinboard account",
                           "subtitle": 'pbauth - username:token',
                           "valid": False,
                           "autocomplete":"_pbauth ",
                           "mods": mods
            })
            
    print json.dumps({"items": result})
Example #4
0
def process_option(c, q):
    result = []
    help_back_string = "enter to go Back"
    help_select_string = ""
    mods = {
        "ctrl": {
            "valid": False,
            "subtitle": ""
        },
        "alt": {
            "valid": False,
            "subtitle": ""
        },
        "cmd": {
            "valid": False,
            "subtitle": ""
        },
        "shift": {
            "valid": False,
            "subtitle": ""
        }
    }
    mark = util.filter_mark(c)
    private = util.filter_private(c)
    sort = util.sql_orderby(c)

    if q.startswith("_mark"):
        result.append({
            "title": "mark [filter] - " + util.filter_option[mark],
            "subtitle": help_back_string,
            "valid": False,
            "autocomplete": "_",
            "mods": mods
        })
        add_option_submenu(result, mods, "mark", mark)
    elif q.startswith("_private"):
        result.append({
            "title":
            "private [filter] - " + util.filter_option[private],
            "subtitle":
            help_back_string,
            "valid":
            False,
            "autocomplete":
            "_",
            "mods":
            mods
        })
        add_option_submenu(result, mods, "private", private)
    elif q.startswith("_sort"):
        result.append({
            "title": "sort - " + util.sort_option[sort],
            "subtitle": help_back_string,
            "valid": False,
            "autocomplete": "_",
            "mods": mods
        })
        add_option_submenu(result, mods, "sort", sort)
    elif q.startswith("_pbauth"):
        result.append({
            "title": "_pbauth username:token",
            "subtitle": "Setup Pinboard authentication token",
            "valid": False,
            "mods": mods
        })
        if ' ' in q and ':' in q:
            result[0]['valid'] = True
            result[0]['arg'] = '_auth=' + q.split(' ')[1]
            result[0]['subtitle'] = "Enter to set"
    else:
        result.append({
            "title": "Settings",
            "subtitle": "enter to go Back",
            "valid": False,
            "autocomplete": "",
            "mods": mods
        })

        result.append({
            "title": "mark [filter] - " + util.filter_option[mark],
            "subtitle": help_select_string,
            "valid": False,
            "autocomplete": "_mark",
            "mods": mods
        })
        result.append({
            "title":
            "private [filter] - " + util.filter_option[private],
            "subtitle":
            help_select_string,
            "valid":
            False,
            "autocomplete":
            "_private",
            "mods":
            mods
        })
        result.append({
            "title": "sort - " + util.sort_option[sort],
            "subtitle": help_select_string,
            "valid": False,
            "autocomplete": "_sort",
            "mods": mods
        })
        auth = util.authinfo(c)
        if auth:
            result.append({
                "title": "> Pinboard User - %s" % auth.split(':')[0],
                "subtitle": 'enter to change',
                "valid": False,
                "autocomplete": "_pbauth ",
                "mods": mods
            })
            result.append({
                "title": ">> Download pinboard data",
                "subtitle": 'enter to reload pinboard',
                "valid": True,
                "arg": "_pbreload",
                "autocomplete": "_pbreload ",
                "mods": mods
            })
        else:
            result.append({
                "title": ">> Login Pinboard account",
                "subtitle": 'pbauth - username:token',
                "valid": False,
                "autocomplete": "_pbauth ",
                "mods": mods
            })

    print json.dumps({"items": result})