Example #1
0
    def run(self):
        try:
            agent = G.AGENT
            d = {
                'port': agent.proto.port,
                'secure': agent.proto.secure,
                'owner': agent.owner,
                'workspace': agent.workspace,
                'host': agent.proto.host,
            }
            view = self.window.active_view()
            if view:
                path = view.file_name()
                if path and utils.is_shared(path):
                    d['path'] = utils.to_rel_path(path)
                    try:
                        d['line'] = view.rowcol(view.sel()[0].a)[0]
                    except Exception:
                        pass

            url = utils.to_workspace_url(d)
            webbrowser.open(url)
        except Exception as e:
            sublime.error_message(
                'Unable to open workspace in web editor: %s' % str_e(e))
    def upload(self, path):
        if not utils.is_shared(path):
            editor.error_message('Cannot share %s because is not in shared path %s.\n\nPlease move it there and try again.' % (path, G.PROJECT_PATH))
            return
        ig = ignore.create_ignore_tree(G.PROJECT_PATH)
        G.IGNORE = ig
        is_dir = os.path.isdir(path)
        if ig.is_ignored(path, is_dir, True):
            editor.error_message('Cannot share %s because it is ignored.\n\nAdd an exclude rule (!%s) to your .flooignore file.' % (path, path))
            return
        rel_path = utils.to_rel_path(path)
        if not is_dir:
            self._upload_file_by_path(rel_path)
            return

        for p in rel_path.split('/'):
            child = ig.children.get(p)
            if not child:
                break
            ig = child

        if ig.path != path:
            msg.warn(ig.path, ' is not the same as ', path)

        self._rate_limited_upload(ig.list_paths(), ig.total_size, upload_func=self._upload_file_by_path)
Example #3
0
    def upload(self, path):
        if not utils.is_shared(path):
            editor.error_message(
                'Cannot share %s because is not in shared path %s.\n\nPlease move it there and try again.'
                % (path, G.PROJECT_PATH))
            return
        ig = ignore.create_ignore_tree(G.PROJECT_PATH)
        G.IGNORE = ig
        is_dir = os.path.isdir(path)
        if ig.is_ignored(path, is_dir, True):
            editor.error_message(
                'Cannot share %s because it is ignored.\n\nAdd an exclude rule (!%s) to your .flooignore file.'
                % (path, path))
            return
        rel_path = utils.to_rel_path(path)
        if not is_dir:
            self._upload_file_by_path(rel_path)
            return

        for p in rel_path.split('/'):
            child = ig.children.get(p)
            if not child:
                break
            ig = child

        if ig.path != path:
            msg.warn(ig.path, ' is not the same as ', path)

        self._rate_limited_upload(ig.list_paths(),
                                  ig.total_size,
                                  upload_func=self._upload_file_by_path)
Example #4
0
    def run(self, paths, current_file=False):
        if not self.is_enabled():
            return

        if paths is None and current_file:
            active_view = self.window.active_view()
            if active_view is None:
                msg.log(
                    'AddToWorkspace: No active view found. Perhaps active tab is an image?'
                )
                return
            paths = [active_view.file_name()]

        notshared = []
        for path in paths:
            if utils.is_shared(path):
                G.AGENT.upload(path)
            else:
                notshared.append(path)

        if notshared:
            limit = 5
            sublime.error_message(
                "The following paths are not a child of\n\n%s\n\nand will not be shared for security reasons:\n\n%s%s."
                % (G.PROJECT_PATH, ",\n".join(notshared[:limit]),
                   len(notshared) > limit and ",\n..." or ""))
Example #5
0
def is_modifiable(name_to_check=None):
    if not agent or not agent.protocol:
        return
    vim_buf = vim.current.buffer
    name = vim_buf.name
    if not name:
        return
    if name_to_check and name_to_check != name:
        msg.warn('Can not call readonly on file: %s' % name)
    if not utils.is_shared(name):
        return
    if 'patch' not in agent.protocol.perms:
        vim.command("call g:FlooSetReadOnly()")
        utils.set_timeout(is_modifiable, 0, name)
Example #6
0
def floobits_maybe_new_file():
    path = vim.current.buffer.name
    if path is None or path == '':
        msg.debug('get:buf buffer has no filename')
        return None

    if not os.path.exists(path):
        return None
    if not utils.is_shared(path):
        msg.debug('get_buf: %s is not shared' % path)
        return None

    buf = G.AGENT.get_buf_by_path(path)
    if not buf:
        if not ignore.is_ignored(path):
            G.AGENT.upload(path)
Example #7
0
def floobits_maybe_new_file():
    path = vim.current.buffer.name
    if path is None or path == '':
        msg.debug('get:buf buffer has no filename')
        return None

    if not os.path.exists(path):
        return None
    if not utils.is_shared(path):
        msg.debug('get_buf: %s is not shared' % path)
        return None

    buf = G.AGENT.get_buf_by_path(path)
    if not buf:
        if not ignore.is_ignored(path):
            G.AGENT.upload(path)
    def run(self, paths, current_file=False):
        if not self.is_enabled():
            return

        if paths is None and current_file:
            paths = [self.window.active_view().file_name()]

        notshared = []
        for path in paths:
            if utils.is_shared(path):
                G.AGENT.upload(path)
            else:
                notshared.append(path)

        if notshared:
            limit = 5
            sublime.error_message("The following paths are not a child of\n\n%s\n\nand will not be shared for security reasons:\n\n%s%s." %
                                  (G.PROJECT_PATH, ",\n".join(notshared[:limit]), len(notshared) > limit and ",\n..." or ""))
Example #9
0
    def run(self, paths, current_file=False):
        if not self.is_enabled():
            return

        if paths is None and current_file:
            paths = [self.window.active_view().file_name()]

        notshared = []
        for path in paths:
            if utils.is_shared(path):
                G.AGENT.upload(path)
            else:
                notshared.append(path)

        if notshared:
            limit = 5
            sublime.error_message("The following paths are not a child of\n\n%s\n\nand will not be shared for security reasons:\n\n%s%s." %
                                  (G.PROJECT_PATH, ",\n".join(notshared[:limit]), len(notshared) > limit and ",\n..." or ""))
Example #10
0
def floobits_maybe_new_file():
    path = vim.current.buffer.name
    if path is None or path == '':
        msg.debug('get:buf buffer has no filename')
        return None

    if not os.path.exists(path):
        return None
    if not utils.is_shared(path):
        msg.debug('get_buf: %s is not shared' % path)
        return None

    buf = G.AGENT.get_buf_by_path(path)
    if not buf:
        is_dir = os.path.isdir(path)
        if not G.IGNORE:
            msg.warn('G.IGNORE is not set. Uploading anyway.')
            G.AGENT.upload(path)
        if G.IGNORE and G.IGNORE.is_ignored(path, is_dir, True):
            G.AGENT.upload(path)
    def run(self, paths, current_file=False):
        if not self.is_enabled():
            return

        if paths is None and current_file:
            active_view = self.window.active_view()
            if active_view is None:
                msg.log('AddToWorkspace: No active view found. Perhaps active tab is an image?')
                return
            paths = [active_view.file_name()]

        notshared = []
        for path in paths:
            if utils.is_shared(path):
                G.AGENT.upload(path)
            else:
                notshared.append(path)

        if notshared:
            limit = 5
            sublime.error_message("The following paths are not a child of\n\n%s\n\nand will not be shared for security reasons:\n\n%s%s." %
                                  (G.PROJECT_PATH, ",\n".join(notshared[:limit]), len(notshared) > limit and ",\n..." or ""))
    def run(self):
        try:
            agent = G.AGENT
            d = {
                'port': agent.proto.port,
                'secure': agent.proto.secure,
                'owner': agent.owner,
                'workspace': agent.workspace,
                'host': agent.proto.host,
            }
            view = self.window.active_view()
            if view:
                path = view.file_name()
                if path and utils.is_shared(path):
                    d['path'] = utils.to_rel_path(path)
                    try:
                        d['line'] = view.rowcol(view.sel()[0].a)[0]
                    except Exception:
                        pass

            url = utils.to_workspace_url(d)
            webbrowser.open(url)
        except Exception as e:
            sublime.error_message('Unable to open workspace in web editor: %s' % str_e(e))