* Fast open, what is published already
@ 2009-02-27 15:18 Sebastian Rose
2009-02-27 15:50 ` Carsten Dominik
0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Rose @ 2009-02-27 15:18 UTC (permalink / raw)
To: emacs-orgmode Org-Mode
[-- Attachment #1: Type: text/plain, Size: 638 bytes --]
Hi everyone,
I recently fell in love with org-annotation-helper.el and
org-browser.el. I hacked together a little shell script, that uses the
features of those two to open an already published org-file, presumed
the local repo is configured, and a protocol handler and bookmark are in
place.
Also, you may do a `git pull', `mtn pull' or what ever before the file
is opened in emacs. The script can easily be adjusted to work with any
Org project. I plan to add a little function to create new bookmarklets,
protocol handlers and scripts easily (or receive the protocol on stdin
too and map protocols to repositories).
This is it:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-sh, Size: 4316 bytes --]
#! /bin/bash
# Author: Sebastian Rose <sebastian_rose at gmx de>
#
# The idea is roughly based on org-annotation-helper and org-browser-url.el,
# written by Bastien Guerry and Ross Patterson respectively.
#
# AIMS
#
# Open already published files in emacs easily. This script is originally
# geard for usage with the contents in http://orgmode.org/worg/ (and
# Worg.git), but it can easily be changed to help with other projects too.
#
# Optionally do a `git pull', `mtn pull' or whatever.
#
# See `Future plans' for what is planed.
#
#
# REQUIREMENTS
#
# * You'll need to have ssh-askpass installed, to load ssh-key files as needed.
# * Firefox browser. The possibility to do somthing similar with Opera seems to
# exist, but I didn't test it. For more visit opera.com.
# * An SMCS, capable of using ssh-agent, and configured to use it. You might also
# use this script for repos that are accessed without any authentication at all
# (or a kind of authentication that does not require any interaction).
# * zenity
#
# USAGE:
#
# 1.) Add a new protocol handler to Firefox:
# * navigate to "about:config"
# * right click, select "New" => "String"
# * enter the name:
#
# network.protocol-handler.app.org-worg
#
# * leave the value blank
#
# See http://kb.mozillazine.org/Register_protocol for more details.
#
# 2.) Add a bookmark to Firefox. As `Location' use this here:
#
# javascript:location.href='org-worg:///'+location.href.replace(/http:\/\/orgmode.org\/worg\//, "")
#
# 3.) Customize all the option below.
#
# 4.) When browsing http://orgmode.org/worg/, click the bookmark. Firefox will
# ask for the application to use with the protocol `org-worg://'. Enter the
# path to this script and ensure it is executable. If everything is configured
# correctly, the appropriate file is opened in emacs.
#
# ##########################################################
# --- CUSTOMIZATION ---
#
# No slash at the end:
working_dir=~/develop/org/Worg
# Could be changed to "mtn sync" or what ever.
pull_command="git pull"
# Does the pull command require a ssh key file to be loaded?
# Key file to add, to be able pull:
ssh_key_file=~/.ssh/id_repo_or_cz
# Does the pull command require a ssh key file to be loaded?
# We can only ask if the fingerprint is in ssh-agent. Needed, if your
# project requires it.
fingerprint="b7:f5:10:43:3b:c2:fe:b5:54:18:3f:35:f1:d0:a3:6e"
# Pull before editing? [always|never|ask]
pull_policy=ask
# The suffix to strip (i.e. to exchange with `.org').
strip_suffix=".php"
# Only change this, if you changed the protocol used for the bookmarklet!
file=${1#org-worg:///}
#
# --- these options are less likely to change ---
#
working_suffix=".org"
#
# --- END OF CUSTOMIZATION ---
# ##########################################################
# Future plans:
case "${1}" in
--help) # Print a help message (installation...)
echo "HELP"
exit 0 ;;
--create) # Create new files and bookmarklets for more projects interactively.
echo "CREATE"
exit 0 ;;
esac
# End of future plans.
file="${file%${strip_suffix}}${working_suffix}"
if [ -f "${working_dir}/${file}" ]; then
do_pull=$pull_policy
if [ "ask" = $pull_policy ]; then
if zenity --question --title="Org-Worglet :: ${file}" --text="Shall I pull before opening\n${file}?"; then
do_pull=always
fi
fi
if [ "always" = $do_pull ]; then
val=$(ssh-add -l | grep "${fingerprint}")
if [ -z "${val}" ]; then
ssh-add "${ssh_key_file}"
fi
cd "${working_dir}"
if ! ${pull_command}; then
if ! zenity --question --title="Org-Worglet :: ${pull_command}" --text="${pull_command} FAILED. Open the file anyway?"; then
exit 1
fi
fi
fi
emacsclient --eval "(find-file \"${working_dir}/${file}\")"
else
zenity --error --title "Org-Worglet :: Error" --text "File does not exist: ${working_dir}/${file}"
fi
</#part>
--
Sebastian Rose, EMMA STIL - mediendesign, Niemeyerstr.6, 30449 Hannover
Tel.: +49 (0)511 - 36 58 472
Fax: +49 (0)1805 - 233633 - 11044
mobil: +49 (0)173 - 83 93 417
Http: www.emma-stil.de
[-- Attachment #3: Type: text/plain, Size: 204 bytes --]
_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Fast open, what is published already
2009-02-27 15:18 Fast open, what is published already Sebastian Rose
@ 2009-02-27 15:50 ` Carsten Dominik
2009-02-28 1:04 ` Sebastian Rose
0 siblings, 1 reply; 3+ messages in thread
From: Carsten Dominik @ 2009-02-27 15:50 UTC (permalink / raw)
To: Sebastian Rose; +Cc: emacs-orgmode Org-Mode
This is pretty cool.
- Carsten
On Feb 27, 2009, at 4:18 PM, Sebastian Rose wrote:
> Hi everyone,
>
>
> I recently fell in love with org-annotation-helper.el and
> org-browser.el. I hacked together a little shell script, that uses the
> features of those two to open an already published org-file, presumed
> the local repo is configured, and a protocol handler and bookmark
> are in
> place.
>
> Also, you may do a `git pull', `mtn pull' or what ever before the
> file
> is opened in emacs. The script can easily be adjusted to work with any
> Org project. I plan to add a little function to create new
> bookmarklets,
> protocol handlers and scripts easily (or receive the protocol on stdin
> too and map protocols to repositories).
>
> This is it:
>
>
>
> #! /bin/bash
>
> # Author: Sebastian Rose <sebastian_rose at gmx de>
> #
> # The idea is roughly based on org-annotation-helper and org-browser-
> url.el,
> # written by Bastien Guerry and Ross Patterson respectively.
> #
> # AIMS
> #
> # Open already published files in emacs easily. This script is
> originally
> # geard for usage with the contents in http://orgmode.org/worg/ (and
> # Worg.git), but it can easily be changed to help with other
> projects too.
> #
> # Optionally do a `git pull', `mtn pull' or whatever.
> #
> # See `Future plans' for what is planed.
> #
> #
> # REQUIREMENTS
> #
> # * You'll need to have ssh-askpass installed, to load ssh-key
> files as needed.
> # * Firefox browser. The possibility to do somthing similar with
> Opera seems to
> # exist, but I didn't test it. For more visit opera.com.
> # * An SMCS, capable of using ssh-agent, and configured to use it.
> You might also
> # use this script for repos that are accessed without any
> authentication at all
> # (or a kind of authentication that does not require any
> interaction).
> # * zenity
> #
> # USAGE:
> #
> # 1.) Add a new protocol handler to Firefox:
> # * navigate to "about:config"
> # * right click, select "New" => "String"
> # * enter the name:
> #
> # network.protocol-handler.app.org-worg
> #
> # * leave the value blank
> #
> # See http://kb.mozillazine.org/Register_protocol for more
> details.
> #
> # 2.) Add a bookmark to Firefox. As `Location' use this here:
> #
> # javascript:location.href='org-
> worg:///'+location.href.replace(/http:\/\/orgmode.org\/worg\//, "")
> #
> # 3.) Customize all the option below.
> #
> # 4.) When browsing http://orgmode.org/worg/, click the bookmark.
> Firefox will
> # ask for the application to use with the protocol `org-
> worg://'. Enter the
> # path to this script and ensure it is executable. If
> everything is configured
> # correctly, the appropriate file is opened in emacs.
> #
>
>
> # ##########################################################
> # --- CUSTOMIZATION ---
> #
>
> # No slash at the end:
> working_dir=~/develop/org/Worg
>
>
> # Could be changed to "mtn sync" or what ever.
> pull_command="git pull"
>
> # Does the pull command require a ssh key file to be loaded?
> # Key file to add, to be able pull:
> ssh_key_file=~/.ssh/id_repo_or_cz
>
> # Does the pull command require a ssh key file to be loaded?
> # We can only ask if the fingerprint is in ssh-agent. Needed, if your
> # project requires it.
> fingerprint="b7:f5:10:43:3b:c2:fe:b5:54:18:3f:35:f1:d0:a3:6e"
>
> # Pull before editing? [always|never|ask]
> pull_policy=ask
>
> # The suffix to strip (i.e. to exchange with `.org').
> strip_suffix=".php"
>
> # Only change this, if you changed the protocol used for the
> bookmarklet!
> file=${1#org-worg:///}
>
> #
> # --- these options are less likely to change ---
> #
> working_suffix=".org"
>
> #
> # --- END OF CUSTOMIZATION ---
> # ##########################################################
>
>
>
>
>
> # Future plans:
> case "${1}" in
> --help) # Print a help message (installation...)
> echo "HELP"
> exit 0 ;;
> --create) # Create new files and bookmarklets for more projects
> interactively.
> echo "CREATE"
> exit 0 ;;
> esac
> # End of future plans.
>
>
>
>
>
> file="${file%${strip_suffix}}${working_suffix}"
>
> if [ -f "${working_dir}/${file}" ]; then
> do_pull=$pull_policy
> if [ "ask" = $pull_policy ]; then
> if zenity --question --title="Org-Worglet :: ${file}" --
> text="Shall I pull before opening\n${file}?"; then
> do_pull=always
> fi
> fi
>
> if [ "always" = $do_pull ]; then
> val=$(ssh-add -l | grep "${fingerprint}")
> if [ -z "${val}" ]; then
> ssh-add "${ssh_key_file}"
> fi
> cd "${working_dir}"
> if ! ${pull_command}; then
> if ! zenity --question --title="Org-Worglet :: $
> {pull_command}" --text="${pull_command} FAILED. Open the file
> anyway?"; then
> exit 1
> fi
> fi
> fi
> emacsclient --eval "(find-file \"${working_dir}/${file}\")"
> else
> zenity --error --title "Org-Worglet :: Error" --text "File does
> not exist: ${working_dir}/${file}"
> fi
> </#part>
>
>
>
>
>
>
> --
> Sebastian Rose, EMMA STIL - mediendesign, Niemeyerstr.6, 30449
> Hannover
> Tel.: +49 (0)511 - 36 58 472
> Fax: +49 (0)1805 - 233633 - 11044
> mobil: +49 (0)173 - 83 93 417
> Http: www.emma-stil.de
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Fast open, what is published already
2009-02-27 15:50 ` Carsten Dominik
@ 2009-02-28 1:04 ` Sebastian Rose
0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Rose @ 2009-02-28 1:04 UTC (permalink / raw)
To: Carsten Dominik; +Cc: emacs-orgmode Org-Mode
Carsten Dominik <dominik@science.uva.nl> writes:
> This is pretty cool.
I _love_ it.
The new version has the capability of interactively creating new orglets
- that's their name :) .
I already created some, to edit my local projects. Here at least, it
works like a charm. All you need is the `mother of all orglets' (the
script in it's current form) and call it like this:
org-worglet --create
The rest is asked interactively. There might be some more docs needed
though. But for hardcore worgers the in-file comments will be sufficient.
The orglets resulting from the interactive process, include their own
help. If you created an orglet and saved it to ~/bin/org-notelet, you
may do
~/bin/org-notelet --help
to get information about the orglet. The in-file comments are geared for
the very orglet, e.g. there is the the ready-for-use JavaScript in the
first comment section to copy to your browsers bookmark entry.
The `future plans' have changed now to
`Install the orglets automatically into Firefox.'
The current version is now on github:
http://github.com/SebastianRose/org-worglet/tree/master
Now I'll enjoy my new bookmark-toolbar folder full of handy orglets :)
Best Regards,
--
Sebastian Rose, EMMA STIL - mediendesign, Niemeyerstr.6, 30449 Hannover
Tel.: +49 (0)511 - 36 58 472
Fax: +49 (0)1805 - 233633 - 11044
mobil: +49 (0)173 - 83 93 417
Http: www.emma-stil.de
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-02-28 1:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-27 15:18 Fast open, what is published already Sebastian Rose
2009-02-27 15:50 ` Carsten Dominik
2009-02-28 1:04 ` Sebastian Rose
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).