Skip to content
This repository
Browse code

Added script by Hubert Campan to create a webloc file from a dragged URL

  • Loading branch information...
commit f1c97e3ba8a5d6a598553e2bd52a6d07275755e3 1 parent 430d8bc
aptonic authored

Showing 1 changed file with 44 additions and 0 deletions. Show diff stats Hide diff stats

  1. +44 0 Create URL Shortcut file.dropzone
44 Create URL Shortcut file.dropzone
... ... @@ -0,0 +1,44 @@
  1 +#!/usr/bin/env ruby
  2 +
  3 +# Dropzone Destination Info
  4 +# Name: Create URL Shortcut File
  5 +# Description: Creates webloc file of the dragged URL
  6 +# Handles: NSStringPboardType
  7 +# Creator: Hubert CAMPAN
  8 +# URL: http://omnimaki.com
  9 +# IconURL: http://omnimaki.com/imagespool/icones/link.png
  10 +# OptionsNIB: ChooseFolder
  11 +
  12 +def dragged
  13 + destination = "#{ENV['EXTRA_PATH']}"
  14 +
  15 + $dz.determinate(false)
  16 + $dz.begin("Creating URL Shortcut File...")
  17 +
  18 + # variables
  19 + title = ''
  20 + url = $items[0]
  21 + title = url.gsub('http://', '').gsub('https://', '').gsub("\/", '_')
  22 +
  23 + # creating the webloc file
  24 + File.open("#{destination}/#{title}.webloc", "a") { |f|
  25 + f << %Q{<?xml version="1.0" encoding="UTF-8"?>
  26 + <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  27 + <plist version="1.0">
  28 + <dict>
  29 + <key>URL</key>
  30 + <string>#{url}</string>
  31 + </dict>
  32 + </plist>}
  33 + }
  34 +
  35 + # hiding the webloc extension
  36 + system "/usr/bin/SetFile -a E \"#{destination}/#{title}.webloc\""
  37 +
  38 + $dz.finish("URL Shortcut File created")
  39 + $dz.url(false)
  40 +end
  41 +
  42 +def clicked
  43 + system("open \"#{ENV['EXTRA_PATH']}\"")
  44 +end

0 comments on commit f1c97e3

Please sign in to comment.
Something went wrong with that request. Please try again.