summary refs log tree commit diff stats
Commit message (Expand)AuthorAgeFilesLines
* commented indexHandlerBen Morrison2019-05-131-5/+14
* send etag for index. sha256 of template mod time.Ben Morrison2019-05-131-1/+8
* template initialization addedBen Morrison2019-05-136-22/+123
* skeleton template for indexBen Morrison2019-05-131-0/+13
* serving css virtually instead of directlyBen Morrison2019-05-135-9/+75
* comment on handler testsBen Morrison2019-05-131-0/+2
* separating cache into its own libraryBen Morrison2019-05-133-2/+46
* fixed viper config parsing resulting in build errorsBen Morrison2019-05-133-3/+18
* removed unneeded config valuesBen Morrison2019-05-132-2/+6
* help messageBen Morrison2019-05-131-1/+2
* changing flagsBen Morrison2019-05-131-8/+14
* handling viper error when binding to pflagsBen Morrison2019-05-131-1/+3
* staticcheck warning fixedBen Morrison2019-05-131-2/+2
* redundant path removed. comments added.Ben Morrison2019-05-131-3/+5
* adjusting test config init funcBen Morrison2019-05-131-6/+1
* more stubbed testsBen Morrison2019-05-132-2/+74
* travis-ci badgeBen Morrison2019-05-131-1/+1
* travis ci configBen Morrison2019-05-131-0/+8
* stubbing out testsBen Morrison2019-05-131-0/+31
* watching for ^C. added comments.Ben Morrison2019-05-132-2/+37
* passing logfile as var to closing goroutine to prevent race conditionBen Morrison2019-05-121-9/+9
* reorganized handlers. StrictSlash(true). handling POST /api/plain/users for n...Ben Morrison2019-05-122-9/+39
* added stdoutLogging bool and related configurationBen Morrison2019-05-123-30/+58
* new defaultsBen Morrison2019-05-121-0/+1
* commented someBen Morrison2019-05-121-1/+9
* ignoring log fileBen Morrison2019-05-121-0/+1
* config fleshed out; using viper+pflagBen Morrison2019-05-124-12/+88
* dependencies updatedBen Morrison2019-05-122-0/+40
* revive static analysis configBen Morrison2019-05-121-0/+30
* query vars to endpoint in routingBen Morrison2019-05-111-1/+3
* more graceful routing of http requestsBen Morrison2019-05-111-8/+23
* commenting earlyBen Morrison2019-05-111-0/+3
* commenting earlyBen Morrison2019-05-111-8/+19
* logging initialization in init()Ben Morrison2019-05-111-0/+27
* removed unneded conf fieldBen Morrison2019-05-111-7/+0
* skeleton handlers respondingBen Morrison2019-05-113-8/+51
* dependenciesBen Morrison2019-05-112-0/+12
* stubbed out handlersBen Morrison2019-05-114-22/+25
* gzipped responsesBen Morrison2019-05-113-2/+10
* reorgBen Morrison2019-05-113-4/+5
* change port for unprivileged bindsBen Morrison2019-05-101-1/+1
* ignoring binaryBen Morrison2019-05-101-0/+1
* updated readmeBen Morrison2019-05-101-1/+3
* building the skeletonBen Morrison2019-05-103-0/+69
* go moduleBen Morrison2019-05-091-0/+3
* Initial commitBen Morrison2019-05-092-0/+676
span> mode): self.line = line self.mode = mode def execute(self): pass def tab(self): pass def quick_open(self): pass # -------------------------------- definitions class cd(Command): """The cd command changes the directory. The command 'cd -' is equivalent to typing ``. In the quick console, the directory will be entered without the need to press enter, as soon as there is one unambiguous match. """ def execute(self): line = parse(self.line) try: destination = line.chunks[1] except IndexError: destination = '~' if destination == '-': self.fm.enter_bookmark('`') else: self.fm.enter_dir(destination) def tab(self): from os.path import dirname, basename, expanduser, join, isdir line = parse(self.line) pwd = self.fm.env.pwd.path try: rel_dest = line.chunks[1] except IndexError: rel_dest = '' if rel_dest.startswith('~'): return line + expanduser(rel_dest) + '/' abs_dest = join(pwd, rel_dest) abs_dirname = dirname(abs_dest) rel_basename = basename(rel_dest) rel_dirname = dirname(rel_dest) try: if rel_dest.endswith('/') or rel_dest == '': _, dirnames, _ = os.walk(abs_dest).next() else: _, dirnames, _ = os.walk(abs_dirname).next() dirnames = [dn for dn in dirnames \ if dn.startswith(rel_basename)] except (OSError, StopIteration): pass else: dirnames.sort() if len(dirnames) == 0: return if len(dirnames) == 1: return line + join(rel_dirname, dirnames[0]) + '/' return (line + join(rel_dirname, dirname) for dirname in dirnames) def quick_open(self): from os.path import isdir, join, normpath line = parse(self.line) pwd = self.fm.env.pwd.path try: rel_dest = line.chunks[1] except IndexError: return False abs_dest = normpath(join(pwd, rel_dest)) return rel_dest != '.' and isdir(abs_dest) class find(Command): """The find command will attempt to find a partial, case insensitive match in the filenames of the current directory. In the quick command console, once there is one unambiguous match, the file will be run automatically. """ count = 0 def execute(self): if self.mode != '>': self._search() import re search = parse(self.line).chunk(1) search = re.escape(search) self.fm.env.last_search = re.compile(search, re.IGNORECASE) def quick_open(self): self._search() if self.count == 1: self.fm.move_right() self.fm.block_input(0.5) return True def _search(self): self.count = 0 line = parse(self.line) pwd = self.fm.env.pwd try: arg = line.chunks[1] except IndexError: return False length = len(pwd.files) for i in range(length): actual_index = (pwd.pointed_index + i) % length filename = pwd.files[actual_index].basename_lower if arg in filename: self.count += 1 if self.count == 1: pwd.move_pointer(absolute=actual_index) self.fm.env.cf = pwd.pointed_file if self.count > 1: return False return self.count == 1 class quit(Command): """Quits the program.""" def execute(self): raise SystemExit class delete(Command): def execute(self): self.fm.delete() class mkdir(Command): def execute(self): line = parse(self.line) try: self.fm.mkdir(line.chunks[1]) except IndexError: pass # -------------------------------- rest by_name = {} for varname, var in vars().copy().items(): try: if issubclass(var, Command) and var != Command: by_name[var.name or varname] = var except TypeError: pass def alias(**kw): for key, value in kw.items(): by_name[key] = value alias(q=quit)