GithubHelp home page GithubHelp logo

nicosantangelo / sublime-text-trello Goto Github PK

View Code? Open in Web Editor NEW
50.0 8.0 7.0 485 KB

Sublime Text 3 package to interact with the Trello API

License: MIT License

Python 100.00%
sublime python trello-api

sublime-text-trello's Introduction

Sublime Trello

This is a package for Sublime Text 3 that provides a number of useful commands for interacting with Trello (using the Trello API).

Usage

This package allows you to navigate the data Trello provides using the Trello API. It's heavily inspired in the File Navigator package.

For more info on how to customize the plugin check the settings.

Navigate

If you run the Trello: Navigate command, you'll see your boards, and from there you can go into the Trello element structure (Board -> List -> Card -> Actions).

In the default settings you can find { "keep_navigate_open_after_action": true } If you want you can set it to false on your user settings so the panel will close after each action.

Card creation

'Quick create card' and 'Create card with description'

It tries to create a Card on the last active List. The active List refers to the last List viewed using the Trello: Navigate command.

If you didn't use Navigate yet the package will display a panel explaining the situation.

Notifications

Running Trello: Notifications you'll get two options, Unread and Read all.

Unread notifications

When you run Trello: Unread Notifications, you'll see the amount of unread notifications the current user has, and a little description of what happened, for example:

Total unread: 1

1) Nofitication type: commentCard
Card: Some Card
Board: Some Board

This could be improved a lot, but I think it's understandable (with a little bit of brain parsing) and I prefer adding some other stuff before making it prettier (pull requests are welcome!).

Read all notifications

This command will attempt to read all your current unread notifications. This may result in an error because more privileges are needed. The package will explain how to fix this (if you so desire) in a panel.

Cache

By default most requests will be cached, to improve performance. When you do an action that requires the element to be realoaded, for example creating a new card in a list, the package will try to delete only that cache, maintaining the rest.

But if you make changes in the web version or by some chance elements remain cached, changes will not be reflected.

To avoid this you have two options, run the Trello: Delete cache command, which will clean the cache and will request everything again or you can switch the use_cache (which is true by default) option to false on your user settings, like this:

{ "use_cache": false }

which is not really recommended because the package will request everything on every request, but it's an option just in case.

Generating Your Keys

By default the package uses a Trello app generated only to be used here. If the token isn't present the package will pop up a message telling you how to get it.

Basically because of the way Trello authentication works, you'll need to copy a url in your browser and pase the result in the token property of the user settings, for example:

Url:

https://trello.com/1/connect?key={KEY}&name=sublime_app&response_type=token&scope=read,write

Options:

{
    "key"   : "",
    "secret": "",
    "token" : "{token_goes_here}"
}

If you don't want to use the default app, you can change it by adding your own key and secret to the user settings (check the default settings to see how). You can get them from here.

Also, if you want to enable only some access to your account, you can modify the scope of the url before pasting it in the browser, for example from &scope=read,write to &scope=read

All settings

{
    // Key and secret to identify the app. If not present the default is used
    "key"   : "",
    "secret": "",

    // Access token to interact with the API (required)
    "token" : "",

    // Cache unchanged responses for better performance
    "use_cache": true,

    // After creating elements or performing an action on them the panel reopens (until exit is selected)
    "keep_navigate_open_after_action": true,

    // Use a new tab when showing the results. If it's false it'll use a panel (like the ST console)
    "results_in_new_tab": true,

    // Syntax to use when showing the text from a trello element
    "syntax_file": "Packages/Markdown/Markdown.tmLanguage",

    // Set the delemiter used to create more than one card at once in 'Create card with description'.
    // By default, if you place "<end>" after the card description placeholder you can create another card (as many as you want)
    "card_delimiter": "<end>"
}

Shortcut Keys

Windows and Linux:

  • Navigate: ctrl+alt+t
  • Unread notifications: ctrl+alt+n

OSX

  • Navigate: super+alt+t
  • Unread notifications: super+alt+n

Delete cache and Notifications don't have a shortcut, but you can set it in Preferences -> Key Bindings - User by adding:

{
    "keys": ["alt+d"], "command": "trello_delete_cache", 
    "keys": ["alt+n"], "command": "trello_notifications"
}

Settings location

Preferences -> Package Settings -> Trello -> Settings - User

Installation

PackageControl

If you have PackageControl installed, you can use that to install the package.

Just type cmd-shift-p/ctrl-shift-p to bring up the command pallate and pick Package Control: Install Package from the dropdown.

Then type Trello and choose this package from the dropdown. That's it!

Manual

You can clone the repo in your /Packages (Preferences -> Browse Packages...) folder and start using/hacking it.

cd ~/path/to/Packages
git clone git://github.com/NicoSantangelo/sublime-text-trello.git Trello

Known issues

Curl is required for Linux users (it should be on: /usr/local/sbin, /sbin, /usr/sbin, /usr/local/bin, /usr/bin, or /bin).

Roadmap

  • Checklists
  • Port to ST2?
  • The rest of the Trello API?
  • Labels
  • Don't cache requests
  • Go back option
  • Card description
  • Create Card from List
  • Create List from Board
  • Create Board
  • Print the comment somewhere when it's selected from the list of Card comments (ouput panel)

Any idea?

  • Pull requests are more than welcome, you can run the tests using the AAAPT Package or in the terminal (for example: cd path/to/Trello && python3 -m tests.test_output).

  • Another way would be adding an issue with your feature request.

Thanks to

Copyright

Copyright © 2013+ Nicolás Santángelo.

See LICENSE for details.

sublime-text-trello's People

Contributors

martisak avatar nicosantangelo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sublime-text-trello's Issues

The error encountered was: '401 Client Error: Unauthorized'

Hi there, very nice idea really appreciate it. I installed the plug in via package control then got to the site https://trello.com/1/connect?... to get my ket. Got it and then i went to preferences>package settings> trello>setting user> and passed the stuff below:

{
"key" : "",
"secret": "",
"token" : "{THE TOKEN I GOT FROM THE WEB PAGE PASED HERE}"
}

Saved. And then tried to do Trello:Navigate but i keep getting the error "The error encountered was: '401 Client Error: Unauthorized'"" . I tried to copy and paste the token again as suggested but the same error appears. Am i doing something wrong? (I m very new to sublime)

Moving cards

Hey Nico,

found your plugin earlier this day and it's pretty cool. It would be even better if we could move cards to other lists.

I hope it's not already mentioned on wbond.

Nice work! :)

[Feature Request] User settings for customising the default message in operations.py

Story time:

As a user of this awesome feature I would like to be able to customise the default strings in the "create_with_description" operation which is currently hardcoded in operations.py. If I could do this (e.g. via the user settings file) I would be able to save myself a significant amount of time over the course of my usage by pre-setting a template which matches how I like to style my Trello card descriptions (specifically to be able to retain indent formatting in my Sublime Text notes and leverage Trello Markdown)

Example custom message:

[TITLE]

[`DESCRIPTION`]

Acceptance Criteria:

  1. create_with_description message is set via the settings file
  2. It is possible to edit the create_with_description message via the user settings file

Documentation:

    def create_with_description(self, label=""):
        first  = "Replace this with the card name. The card will be saved when this tab is closed, leave this tab empty to cancel"
        middle = "Replace this with the card description, it can be multiline."
        last   = "You can create as many cards as you want, just split them by the card_delimiter (from the settings) and a newline." 
        message = "%s %s\n\n%s\n%s" % (label, first, middle, last)

don't work plugin

CrunchBang, sublimetext 3

Traceback (most recent call last):
File "/home/alex/.config/sublime-text-3/Packages/Trello/trello.py", line 100, in
sublime.set_timeout_async(lambda: self.call(fn, progress), delay)
File "/home/alex/.config/sublime-text-3/Packages/Trello/trello.py", line 103, in call
fn()
File "/home/alex/.config/sublime-text-3/Packages/Trello/trello.py", line 26, in
self.defer(lambda: self.work(trello_connection))
File "/home/alex/.config/sublime-text-3/Packages/Trello/trello_navigate.py", line 10, in work
BoardOperation(connection.me).execute(self)
File "/home/alex/.config/sublime-text-3/Packages/Trello/executable.py", line 6, in execute
self.command.display(self.items(), self.callback)
File "/home/alex/.config/sublime-text-3/Packages/Trello/operations.py", line 23, in items
self.set_collection()
File "/home/alex/.config/sublime-text-3/Packages/Trello/operations.py", line 27, in set_collection
self.collection = TrelloCollection(self.trello_element, self.trello_element_property())
File "/home/alex/.config/sublime-text-3/Packages/Trello/trello_collection.py", line 3, in init
if hasattr(trello_element, attr):
File "/home/alex/.config/sublime-text-3/Packages/Trello/lib/trollop/lib.py", line 207, in get
data = json.loads(instance._conn.get(path))
File "/home/alex/.config/sublime-text-3/Packages/Trello/lib/trollop/lib.py", line 44, in get
return self.request('GET', path, params)
File "/home/alex/.config/sublime-text-3/Packages/Trello/lib/trollop/lib.py", line 40, in request
response.raise_for_status()
File "/home/alex/.config/sublime-text-3/Packages/Trello/lib/requests/models.py", line 686, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: None

Feature Request: Quick-add cards without navigation

First off, plugin works brilliantly. Nicely done :D

What I would love is to be able to create a card directly from the top-level command palette without having to go through "Navigate." In my mind, the workflow would look something like this:

  • The "Active" list would be the last Board -> List that a user selected through the current Trello: Navigate menu option.
  • Trello: Quick create card and Trello: Create card with description would be available from the top-level commands (as well as where they currently are under Trello: Navigate).
  • Selecting either of those options would automatically send a card to the currently active Board/List.

Basically this is similar to what's present in SublimeGit. There I can do the full Git: Commit command, or just run the Git: Quick Commit option to skip the more complex options.

Haven't written any plugins for ST yet, so I'm not sure how complex that would be to add. Thoughts?

Batch of Cards

Add a batch of cards, take a look at (from #5):

class CardOperation(BaseOperation):
    def after_init(self):
        self.custom_actions.remove("Open in Browser")
        self.custom_actions.rename("Create Card", "Quick create card")
        self.custom_actions.add("Create card with description", self.create_with_description)

    def trello_element_property(self):
        return "cards"

    def next_operation_class(self):
        return CardOptions

    def create_with_description(self):
        message = "Replace this with the card name\n\nReplace this with the card description (the card will be saved when this tab is closed, leave empty to cancel)"
        self.command.output_editable(message, self)

    def full_add(self, content):
        for card in self.split_cards(content):
            name, description = self.split_card_contents(card)
            self.add(name, description)
        self.restart()

    def add(self, text, description = None):
        self.trello_element.add_card(text, description)

    def split_cards(self, content):
        return content.split("##\n")

    def split_card_contents(self, content):
        splitted = content.split("\n\n", 1)
        return (splitted[0], splitted[1] if len(splitted) > 1 else None)

PRs and Features - Are you still maintaining this?

I currently maintain a package call OrgExtended.
One of the things I want to do is give OrgExtended the ability to sync org files from trello boards and asana lists. (I happen to use both for various work operations, but I would rather keep all my work in org mode files rather than the visual tool, I just also need to be able to facilitate communication with others via these tools)

I would like to build the trello functionality on top of this package (I have a portion of a prototype working at the moment but it required a couple of tweaks) if you are still maintaining it. I need a few tweaks around checkboxes especially since I believe that functionality is still in its infancy in this package.

I am wondering if you are maintaining this package?
If I push some PRs your way they will be received, and if not, if you might consider adding me as a maintainer to help push it along a bit?

Sincerely
Ian

[Bug] Creating new cards occasionally doesn't work

Actual outcome:

Occasionally, the prompt for creating new cards fails to appear. The workaround is to quit and reopen sublime

Expected outcome:

Once the operation for Trello, navigate has been run once both quick create and create with description work flawlessly

Steps to reproduce:

  1. Create a card succesfully
  2. Navigate to other programs / windows
  3. Come back and try to create a card
  4. Observe the "Trello working" status at the bottom of the Sublime app and observe that it stops after 5 second and no card creation prompts are opened

Client Error: Unauthorized

If a valid but expired token is used, the app does not show a useful warning.

The console shows

Traceback (most recent call last):
  File "/Users/nicosantangelo/Library/Application Support/Sublime Text 3/Packages/Trello/trello.py", line 103, in <lambda>
    sublime.set_timeout_async(lambda: self.call(fn, progress), delay)
  File "/Users/nicosantangelo/Library/Application Support/Sublime Text 3/Packages/Trello/trello.py", line 107, in call
    fn()
  File "/Users/nicosantangelo/Library/Application Support/Sublime Text 3/Packages/Trello/trello.py", line 26, in <lambda>
    self.defer(lambda: self.work(trello_connection))
  File "/Users/nicosantangelo/Library/Application Support/Sublime Text 3/Packages/Trello/trello_notifications.py", line 49, in work
    output = Output.notifications(member.unread_notifications())
  File "/Users/nicosantangelo/Library/Application Support/Sublime Text 3/Packages/Trello/lib/trollop/lib.py", line 437, in unread_notifications
    return Notification(self._conn, "").unread(self)
  File "/Users/nicosantangelo/Library/Application Support/Sublime Text 3/Packages/Trello/lib/trollop/lib.py", line 455, in unread
    data = json.loads(self._conn.get(path, dict(read_filter="unread")))
  File "/Users/nicosantangelo/Library/Application Support/Sublime Text 3/Packages/Trello/lib/trollop/lib.py", line 44, in get
    return self.request('GET', path, params)
  File "/Users/nicosantangelo/Library/Application Support/Sublime Text 3/Packages/Trello/lib/trollop/lib.py", line 40, in request
    response.raise_for_status()
  File "/Users/nicosantangelo/Library/Application Support/Sublime Text 3/Packages/Trello/lib/requests/models.py", line 686, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized

After performing action on card, menu closes

After performing an action, such as moving a card to another list, it would be useful if the menu would stay open. That way one can keep moving around without having to open the menu again.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.