Sha256: 3d2c876ac208de8fad034e7e1ea900000c1d68d5aea6921795972ae6fcf18780
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
# encoding: utf-8 # # This file is part of the pincerna gem. Copyright (C) 2013 and above Shogun <shogun@cowtech.it>. # Licensed under the MIT license, which can be found at https://choosealicense.com/licenses/mit. # module Pincerna # Show the list of Safari bookmarks. class SafariBookmark < Bookmark # The icon to show for each feedback item. ICON = Pincerna::Base::ROOT + "/images/safari.png" # The file with bookmarks data. BOOKMARKS_DATA = File.expand_path("~/Library/Safari/Bookmarks.plist") # Reads the list of Safari Bookmarks. def read_bookmarks data = execute_command("/usr/bin/plutil", "-convert", "xml1", "-o", "-", BOOKMARKS_DATA) if data && !data.empty? then Plist.parse_xml(data)["Children"].each do |children| scan_folder(children, "") end end end private # Scans a folder of bookmarks. # # @param node [Hash] The directory to visit. # @param path [String] The path of this node. def scan_folder(node, path) path += " #{SEPARATOR} #{node["Title"]}" (node["Children"] || []).each do |children| children["WebBookmarkType"] == "WebBookmarkTypeLeaf" ? add_bookmark(children["URIDictionary"]["title"], children["URLString"], path) : scan_folder(children, path) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pincerna-1.1.3 | lib/pincerna/safari_bookmark.rb |