Skip to content

Commit

Permalink
Trying to start bringing in the links parser from the old iMedia. At …
Browse files Browse the repository at this point in the history
…least it builds now!

Also fixed some NSLocalizedString calls to use instead NSLocalizedStringWithDefaultValue which allows the strings to come from the iMedia bundle.
  • Loading branch information
Dan Wood committed Sep 18, 2009
1 parent 5a89b01 commit aee959f
Show file tree
Hide file tree
Showing 15 changed files with 1,111 additions and 56 deletions.
18 changes: 15 additions & 3 deletions IMBFlickrParser.m
Expand Up @@ -320,7 +320,11 @@ - (IMBNode*) createInterestingPhotosNodeForRoot: (IMBNode*) root {
node.icon = [self smartFolderIcon];
node.identifier = [self identifierWithMethod:@"interestingness" argument:@"30"];
node.mediaSource = node.identifier;
node.name = NSLocalizedString (@"Most Interesting", @"Flickr parser standard node name.");
node.name = NSLocalizedStringWithDefaultValue(
@"Most Interesting",
nil,IMBBundle(),
@"Most Interesting",
@"Flickr parser standard node name");

[node setFlickrMethod:@"flickr.interestingness.getList"
arguments:[NSDictionary dictionaryWithObjectsAndKeys:@"30", @"per_page", nil]];
Expand All @@ -333,7 +337,11 @@ - (IMBNode*) createRecentPhotosNodeForRoot: (IMBNode*) root {
node.icon = [self smartFolderIcon];
node.identifier = [self identifierWithMethod:@"recent" argument:@"30"];
node.mediaSource = node.identifier;
node.name = NSLocalizedString (@"Recent", @"Flickr parser standard node name.");
node.name = NSLocalizedStringWithDefaultValue(
@"Recent",
nil,IMBBundle(),
@"Recent",
@"Flickr parser standard node name");

[node setFlickrMethod:@"flickr.photos.getRecent"
arguments:[NSDictionary dictionaryWithObjectsAndKeys:@"30", @"per_page", nil]];
Expand Down Expand Up @@ -489,7 +497,11 @@ - (BOOL) populateNode: (IMBNode*) inNode options: (IMBOptions) inOptions error:

- (void) willShowContextMenu: (NSMenu*) inMenu forObject: (IMBObject*) inObject {
// 'Open Flickr Page'...
NSMenuItem* showWebPageItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString (@"Open Flickr Page", @"Flickr parser context menu title.")
NSMenuItem* showWebPageItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedStringWithDefaultValue(
@"Open Flickr Page",
nil,IMBBundle(),
@"Open Flickr Page",
@"Flickr parser context menu title")
action:@selector(openFlickrPage:)
keyEquivalent:@""];
[showWebPageItem setTarget:self];
Expand Down
7 changes: 6 additions & 1 deletion IMBImageCaptureParser.m
Expand Up @@ -143,7 +143,12 @@ - (IMBNode *) nodeCopy:(const IMBNode*)inOldNode
newNode.mediaSource = path;
newNode.identifier = [self identifierForICAObject:self.mediaSource];

NSString* name = NSLocalizedString( @"Devices", @"Caption for Image Capture Root node" );
NSString* name = NSLocalizedStringWithDefaultValue(
@"Devices",
nil,IMBBundle(),
@"Devices",
@"Caption for Image Capture Root node");

if (showsGroupNodes) name = [name uppercaseString];
newNode.name = name;

Expand Down
2 changes: 2 additions & 0 deletions IMBParser.h
Expand Up @@ -133,6 +133,8 @@
NSString* _mediaSource;
NSString* _mediaType;
BOOL _custom;
NSString *_database; // optional, for single-library database files to parse and watch

}

// Helper methods...
Expand Down
1 change: 1 addition & 0 deletions IMBParser.m
Expand Up @@ -91,6 +91,7 @@ - (void) dealloc
{
IMBRelease(_mediaSource);
IMBRelease(_mediaType);
IMBRelease(_database);
[super dealloc];
}

Expand Down
1 change: 1 addition & 0 deletions OmniwebBookmarksToXBEL.xslt
@@ -0,0 +1 @@
<?xml version="1.0" encoding="iso-8859-1"?><!-- Written by Jon Wight --><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml"> <xsl:output method="xml" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="xhtml:html"> <xbel version="1.0"> <xsl:apply-templates/> </xbel> </xsl:template> <xsl:template match="xhtml:dl/xhtml:dd"> <folder> <title><xsl:value-of select="xhtml:h3/xhtml:a/text()"/></title> <xsl:apply-templates select="xhtml:dl"/> </folder> </xsl:template> <xsl:template match="xhtml:dd/xhtml:dl/xhtml:dt"> <bookmark> <xsl:attribute name="href"><xsl:value-of select="xhtml:a/@href"/></xsl:attribute> <title><xsl:value-of select="xhtml:a/text()"/></title> <description/> </bookmark> </xsl:template> <xsl:template match="text()"></xsl:template></xsl:stylesheet>
Expand Down
140 changes: 140 additions & 0 deletions WebIconDatabase.h
@@ -0,0 +1,140 @@
/*
* Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#import <Cocoa/Cocoa.h>

// Sent whenever a site icon has changed. The object of the notification is the icon database.
// The userInfo contains the site URL whose icon has changed.
// It can be accessed with the key WebIconNotificationUserInfoURLKey.
extern NSString *WebIconDatabaseDidAddIconNotification;

extern NSString *WebIconNotificationUserInfoURLKey;

extern NSString *WebIconDatabaseDirectoryDefaultsKey;
extern NSString *WebIconDatabaseEnabledDefaultsKey;

extern NSSize WebIconSmallSize; // 16 x 16
extern NSSize WebIconMediumSize; // 32 x 32
extern NSSize WebIconLargeSize; // 128 x 128

@class WebIconDatabasePrivate;

/*!
@class WebIconDatabase
@discussion Features:
- memory cache icons at different sizes
- disk storage
- icon update notification
Uses:
- WebIconLoader to cache icon images
- UI elements to retrieve icons that represent site URLs.
- Save icons to disk for later use.
Every icon in the database has a retain count. If an icon has a retain count greater than 0, it will be written to disk for later use. If an icon's retain count equals zero it will be removed from disk. The retain count is not persistent across launches. If the WebKit client wishes to retain an icon it should retain the icon once for every launch. This is best done at initialization time before the database begins removing icons. To make sure that the database does not remove unretained icons prematurely, call delayDatabaseCleanup until all desired icons are retained. Once all are retained, call allowDatabaseCleanup.
Note that an icon can be retained after the database clean-up has begun. This just has to be done before the icon is removed. Icons are removed from the database whenever new icons are added to it.
Retention methods can be called for icons that are not yet in the database.
*/
@interface WebIconDatabase : NSObject {

@private
WebIconDatabasePrivate *_private;
}


/*!
@method sharedIconDatabase
@abstract Returns a shared instance of the icon database
*/
+ (WebIconDatabase *)sharedIconDatabase;

/*!
@method iconForURL:withSize:
@discussion Calls iconForURL:withSize:cache: with YES for cache.
@param URL
@param size
*/
- (NSImage *)iconForURL:(NSString *)URL withSize:(NSSize)size;

/*!
@method iconForURL:withSize:cache:
@discussion Returns an icon for a web site URL from memory or disk. nil if none is found.
Usually called by a UI element to determine if a site URL has an associated icon.
Often called by the observer of WebIconChangedNotification after the notification is sent.
@param URL
@param size
@param cache If yes, caches the returned image in memory if not already cached
*/
- (NSImage *)iconForURL:(NSString *)URL withSize:(NSSize)size cache:(BOOL)cache;

/*!
@method iconURLForURL:withSize:cache:
@discussion Returns an icon URL for a web site URL from memory or disk. nil if none is found.
@param URL
*/
- (NSString *)iconURLForURL:(NSString *)URL;

/*!
@method defaultIconWithSize:
@param size
*/
- (NSImage *)defaultIconWithSize:(NSSize)size;

/*!
@method retainIconForURL:
@abstract Increments the retain count of the icon.
@param URL
*/
- (void)retainIconForURL:(NSString *)URL;

/*!
@method releaseIconForURL:
@abstract Decrements the retain count of the icon.
@param URL
*/
- (void)releaseIconForURL:(NSString *)URL;

/*!
@method delayDatabaseCleanup:
@discussion Only effective if called before the database begins removing icons.
delayDatabaseCleanUp increments an internal counter that when 0 begins the database clean-up.
The counter equals 0 at initialization.
*/
- (void)delayDatabaseCleanup;

/*!
@method allowDatabaseCleanup:
@discussion Informs the database that it now can begin removing icons.
allowDatabaseCleanup decrements an internal counter that when 0 begins the database clean-up.
The counter equals 0 at initialization.
*/
- (void)allowDatabaseCleanup;

@end
57 changes: 57 additions & 0 deletions iMBFireFoxParser.h
@@ -0,0 +1,57 @@
/*
iMedia Browser Framework <http://karelia.com/imedia/>
Copyright (c) 2005-2009 by Karelia Software et al.
iMedia Browser is based on code originally developed by Jason Terhorst,
further developed for Sandvox by Greg Hulands, Dan Wood, and Terrence Talbot.
The new architecture for version 2.0 was developed by Peter Baumgartner.
Contributions have also been made by Matt Gough, Martin Wennerberg and others
as indicated in source files.
The iMedia Browser Framework is licensed under the following terms:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in all or substantial portions of the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following
conditions:
Redistributions of source code must retain the original terms stated here,
including this list of conditions, the disclaimer noted below, and the
following copyright notice: Copyright (c) 2005-2009 by Karelia Software et al.
Redistributions in binary form must include, in an end-user-visible manner,
e.g., About window, Acknowledgments window, or similar, either a) the original
terms stated here, including this list of conditions, the disclaimer noted
below, and the aforementioned copyright notice, or b) the aforementioned
copyright notice and a link to karelia.com/imedia.
Neither the name of Karelia Software, nor Sandvox, nor the names of
contributors to iMedia Browser may be used to endorse or promote products
derived from the Software without prior and express written permission from
Karelia Software or individual contributors, as appropriate.
Disclaimer: THE SOFTWARE IS PROVIDED BY THE COPYRIGHT OWNER AND CONTRIBUTORS
"AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH, THE
SOFTWARE OR THE USE OF, OR OTHER DEALINGS IN, THE SOFTWARE.
*/


#import <Cocoa/Cocoa.h>
#import "IMBParser.h"

@class WebView, IMBNode;

@interface iMBFireFoxParser : IMBParser
{

}

@end

0 comments on commit aee959f

Please sign in to comment.