How to develop a Plug-in for Panic Coda with Python
If you are (like me) a mac fan and you use the excellent Panic Coda to develop, you should know that is now possible to write plugins with every languages you want (if you have the interpreter installed on your system).
Python is bundled on every mac, and is also a beautiful and simple language, so i want to show how to develop a simple plugin for Coda with Python!
First of all you need to download the Coda Plug-in Creator that is the application that will convert your python script into a brand new plugin.
The plugin that we are going to create is simple but useful; it will convert the selected rows in the current document into a html unordered list:
Remember the milk
Build a Coda Plugin
Clean the house
Feed the cats
will become
<ul> <li>Remember the milk</li> <li>Build a Coda Plugin</li> <li>Clean the house</li> <li>Feed the cats</li> </ul>
Simple but enough to understand the principle of making a pulgin, however it can be useful in some situations when you need a “raw list” on your page.
So, let’s get started! Fire up your text editor and enter this python code:
#!/sw/bin/python import sys text = sys.stdin.read() unorderedlist = "<ul>\n" for line in text.splitlines(): unorderedlist = unorderedlist + "\t<li>" + line + "</li>\n" unorderedlist = unorderedlist + "</ul>\n" sys.stdout.write(unorderedlist)
Save it as textToList.py. The code is very simple: after importing the sys module, we read the standard input with sys.stdin.read() and we put it on the variable text.
Next we initialize a string called unorderedlist with the first html element we need to build the structure, and then we read every single line of the selection, using splitlines() method on the text string, to create every single list entry.
Finally, we pass the complete unorderedlist string to the standard output with sys.stdout.write().
Now open the Coda plug-in creator, click on Add Command button and name it textToList (or what you want) drag and drop the textToList.py in the Script input field, choose Selection in the STDIN popup menu and Replace Selection in the STDOUT popup menu (to know how to use this settings please refear to the Coda developer documentations) and save the plugin with a nice name (like textToList for example, lol).
That’s it! Our brand new plugin is ready to be installed! Double click on it and you will find it in the plugin menu. To test it write some line of text, select the lines, and then choose textToList from the plugin menu.
Enjoy!
If you like this article, please write a comment and share it! Thanks
A.Fruit
For some reason Coda’s freezing when I run my created plugin. [Spinning beach ball - forever]
Any thoughts?
Mauro
Sorry for the late answer, can you post the code that freeze Coda?
Joseph Viens
You’re polishing yor skill as a writer. Keep it up!
Genoveva Comiskey
Hey there, Great post. First time here, and looking to start web blogging for myself.
ClearPores Reviews
This site can be a walk-through for the entire info you needed about this and didn’t know who to ask. Glimpse here, and you’ll undoubtedly uncover it.
Fernanda
Youre so cool! I dont suppose Ive learn something like this before. So nice to find anyone with some authentic ideas on this subject. realy thank you for starting this up. this website is one thing that’s wanted on the net, somebody with a little bit originality. useful job for bringing something new to the internet!
net
As a net resource for businesses and engineering enthusiasts to follow the newest and best improvements in Unified Communications, IP Telephony, Hosted Communications and VoIP.
Variation Order
This post How to develop a Plug-in for Panic Coda with Python | mdgArt was a good read so I Tweeted it to hopefully give you more readers. thanks. Johnny Debt