diff --git a/Anthill Cocoa/AnthillBugReporter.h b/Anthill Cocoa/AnthillBugReporter.h index e85e935..c0419bb 100644 --- a/Anthill Cocoa/AnthillBugReporter.h +++ b/Anthill Cocoa/AnthillBugReporter.h @@ -3,7 +3,7 @@ // AnthillReporter // // Created by Alex Gordon on 14/02/2009. -// Copyright 2009 Fileability. All rights reserved. +// Copyright 2009 Fileability. Written in 2010 by Fileability.. // #import diff --git a/Anthill Cocoa/AnthillBugReporter.m b/Anthill Cocoa/AnthillBugReporter.m index ed84eef..ce6aaf2 100644 --- a/Anthill Cocoa/AnthillBugReporter.m +++ b/Anthill Cocoa/AnthillBugReporter.m @@ -3,7 +3,7 @@ // AnthillReporter // // Created by Alex Gordon on 14/02/2009. -// Copyright 2009 Fileability. All rights reserved. +// Copyright 2009 Fileability. Written in 2010 by Fileability.. // #import "AnthillBugReporter.h" diff --git a/CHLeftSplitVIew.h b/CHLeftSplitVIew.h index 5c53398..5a3e844 100644 --- a/CHLeftSplitVIew.h +++ b/CHLeftSplitVIew.h @@ -3,7 +3,7 @@ // Chocolat // // Created by Alex Gordon on 29/10/2009. -// Copyright 2009 __MyCompanyName__. All rights reserved. +// Copyright 2009 Fileability. Written in 2010 by Fileability.. // #import diff --git a/CHLeftSplitView.m b/CHLeftSplitView.m index 56286ca..6eb78df 100644 --- a/CHLeftSplitView.m +++ b/CHLeftSplitView.m @@ -3,7 +3,7 @@ // Chocolat // // Created by Alex Gordon on 29/10/2009. -// Copyright 2009 __MyCompanyName__. All rights reserved. +// Copyright 2009 Fileability. Written in 2010 by Fileability.. // #import "CHLeftSplitView.h" diff --git a/CHSymbolButtonImage.h b/CHSymbolButtonImage.h index 2436ae6..46d3a76 100644 --- a/CHSymbolButtonImage.h +++ b/CHSymbolButtonImage.h @@ -3,7 +3,7 @@ // Chocolat // // Created by Alex Gordon on 11/09/2009. -// Copyright 2009 Fileability. All rights reserved. +// Copyright 2009 Fileability. Written in 2010 by Fileability.. // #import diff --git a/CHSymbolButtonImage.m b/CHSymbolButtonImage.m index 7a8aa26..a94cdc2 100644 --- a/CHSymbolButtonImage.m +++ b/CHSymbolButtonImage.m @@ -3,7 +3,7 @@ // Chocolat // // Created by Alex Gordon on 11/09/2009. -// Copyright 2009 Fileability. All rights reserved. +// Copyright 2009 Fileability. Written in 2010 by Fileability.. // #import "CHSymbolButtonImage.h" diff --git a/English.lproj/MainMenu.xib b/English.lproj/MainMenu.xib index 18ab784..0212b35 100644 --- a/English.lproj/MainMenu.xib +++ b/English.lproj/MainMenu.xib @@ -796,6 +796,7 @@ YES YES + YES 2147483647 @@ -804,6 +805,7 @@ + YES Previous Symbol 1572864 @@ -813,6 +815,7 @@ + YES Next Symbol 1572864 diff --git a/HTML_Example/main.css b/HTML_Example/main.css index 0a45204..bcb28f0 100644 --- a/HTML_Example/main.css +++ b/HTML_Example/main.css @@ -17,6 +17,8 @@ code .category { margin-top: -4px; + margin-bottom: 0; + padding-bottom: 8px; text-indent: 20px; font-style: italic; font-size: 13px; @@ -134,6 +136,10 @@ code border-top-style: none; } +.methods div.description +{ + margin-top: -12px; +} .methods .info h3 { diff --git a/IGKAnnotation.h b/IGKAnnotation.h index fa9603f..51d32fd 100644 --- a/IGKAnnotation.h +++ b/IGKAnnotation.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Jean-Nicolas Jolivet on 10-04-30. -// Copyright 2010 SilverCocoa. All rights reserved. +// Written in 2010 by SilverCocoa. // #import diff --git a/IGKAnnotation.m b/IGKAnnotation.m index 69885b8..873c249 100644 --- a/IGKAnnotation.m +++ b/IGKAnnotation.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Jean-Nicolas Jolivet on 10-04-30. -// Copyright 2010 SilverCocoa. All rights reserved. +// Written in 2010 by SilverCocoa. // #import "IGKAnnotation.h" diff --git a/IGKAnnotationManager.h b/IGKAnnotationManager.h index eacb1e7..7115eb6 100644 --- a/IGKAnnotationManager.h +++ b/IGKAnnotationManager.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Jean-Nicolas Jolivet on 10-04-30. -// Copyright 2010 SilverCocoa. All rights reserved. +// Written in 2010 by SilverCocoa. // #import diff --git a/IGKAnnotationManager.m b/IGKAnnotationManager.m index 90a2d4a..6391705 100644 --- a/IGKAnnotationManager.m +++ b/IGKAnnotationManager.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Jean-Nicolas Jolivet on 10-04-30. -// Copyright 2010 SilverCocoa. All rights reserved. +// Written in 2010 by SilverCocoa. // #import "IGKAnnotationManager.h" diff --git a/IGKApplicationDelegate.h b/IGKApplicationDelegate.h index 7c0ce62..0b0f1f4 100644 --- a/IGKApplicationDelegate.h +++ b/IGKApplicationDelegate.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 23/01/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKApplicationDelegate.m b/IGKApplicationDelegate.m index 3d5ee9e..44550ab 100644 --- a/IGKApplicationDelegate.m +++ b/IGKApplicationDelegate.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 23/01/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKApplicationDelegate.h" diff --git a/IGKArrayController.h b/IGKArrayController.h index 446d4d4..bd8899b 100644 --- a/IGKArrayController.h +++ b/IGKArrayController.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 13/02/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKArrayController.m b/IGKArrayController.m index d9a426a..8eb6965 100644 --- a/IGKArrayController.m +++ b/IGKArrayController.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 13/02/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKArrayController.h" diff --git a/IGKBackForwardManager.h b/IGKBackForwardManager.h index 0f8fe87..b8d77ed 100644 --- a/IGKBackForwardManager.h +++ b/IGKBackForwardManager.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 07/03/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKBackForwardManager.m b/IGKBackForwardManager.m index 631528b..003499a 100644 --- a/IGKBackForwardManager.m +++ b/IGKBackForwardManager.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 07/03/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKBackForwardManager.h" diff --git a/IGKBackgroundProgressBar.h b/IGKBackgroundProgressBar.h index 4164489..5df118f 100644 --- a/IGKBackgroundProgressBar.h +++ b/IGKBackgroundProgressBar.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 17/04/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKBackgroundProgressBar.m b/IGKBackgroundProgressBar.m index fd7edf1..163783c 100644 --- a/IGKBackgroundProgressBar.m +++ b/IGKBackgroundProgressBar.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 17/04/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKBackgroundProgressBar.h" diff --git a/IGKCircularBuffer.h b/IGKCircularBuffer.h index b9c3ee9..01e9c6d 100644 --- a/IGKCircularBuffer.h +++ b/IGKCircularBuffer.h @@ -2,37 +2,44 @@ typedef struct { // 0 <= elementCount <= actualSize <= targetSize //The number of elements in the buffer - size_t elementCount; + CFIndex elementCount; //The amount of elements that we have allocated enough memory to hold. Must not be 0 - size_t allocatedCount; + CFIndex allocatedCount; //The maximum number of elements that the buffer will grow to hold before it starts discarding things - size_t maximumCount; + CFIndex maximumCount; //The size in bytes of each element in the buffer - size_t elementSize; + CFIndex elementSize; //A pointer to all the elements void* items; //The offset of the element that was added the longest time ago - size_t oldestElement; + CFIndex oldestElement; //The offset of the element that was added most recently - size_t youngestElement; + CFIndex youngestElement; } IGKCircularBuffer; +//Create a buffer and fill it with data +IGKCircularBuffer IGKCircularBufferCreateFromData(const void *data, CFIndex dataLength, CFIndex maximumCount, CFIndex elementSize); + //Create an empty buffer with a specified size -IGKCircularBuffer IGKCircularBufferCreate(size_t maximumCount, size_t elementSize, size_t initialSize); +IGKCircularBuffer IGKCircularBufferCreate(CFIndex maximumCount, CFIndex elementSize, CFIndex initialSize); //Add elementSize bytes of *pointerToData to the buffer. void IGKCircularBufferAdd(IGKCircularBuffer buffer, void* pointerToData); //Get a pointer to the raw data and the length of the data, eg to pass to NSData -IGKCircularBuffer IGKCircularBufferRawData(IGKCircularBuffer buffer); -size_t IGKCircularBufferRawDataLength(IGKCircularBuffer buffer); +void* IGKCircularBufferRawData(IGKCircularBuffer buffer); +CFIndex IGKCircularBufferRawDataLength(IGKCircularBuffer buffer); + +//Get data in a format suitable for writing out to disk +NSData* IGKCircularBufferOrderedData(IGKCircularBuffer buffer); +CFIndex IGKCircularBufferOrderedDataLength(IGKCircularBuffer buffer); //Delete the buffer void IGKCircularBufferFree(IGKCircularBuffer buffer); diff --git a/IGKCircularBuffer.m b/IGKCircularBuffer.m index 09adca4..8317872 100644 --- a/IGKCircularBuffer.m +++ b/IGKCircularBuffer.m @@ -1,28 +1,22 @@ -typedef struct { - // 0 <= elementCount <= actualSize <= targetSize - - //The number of elements in the buffer - CFIndex elementCount; - - //The amount of elements that we have allocated enough memory to hold. Must not be 0 - CFIndex allocatedCount; - - //The maximum number of elements that the buffer will grow to hold before it starts discarding things - CFIndex maximumCount; - - //The size in bytes of each element in the buffer - CFIndex elementSize; +#import "IGKCircularBuffer.h" + +IGKCircularBuffer IGKCircularBufferCreateFromData(const void *data, CFIndex dataLength, CFIndex maximumCount, CFIndex elementSize) +{ + IGKCircularBuffer buffer; - //A pointer to all the elements - void* items; + buffer.elementCount = 0; + buffer.allocatedCount = dataLength / elementSize; + buffer.maximumCount = maximumCount; + buffer.elementSize = elementSize; - //The offset of the element that was added the longest time ago - int64_t oldestElement; + buffer.items = malloc(dataLength * elementSize); + memcpy(buffer.items, data, dataLength); - //The offset of the element that was added most recently - CFIndex youngestElement; + buffer.oldestElement = -1; + buffer.youngestElement = -1; -} IGKCircularBuffer; + return buffer; +} //Create an empty buffer with a specified size IGKCircularBuffer IGKCircularBufferCreate(CFIndex maximumCount, CFIndex elementSize, CFIndex initialSize) @@ -47,7 +41,7 @@ IGKCircularBuffer IGKCircularBufferCreate(CFIndex maximumCount, CFIndex elementS } //Add elementSize bytes of *pointerToData to the buffer. -void* IGKCircularBufferAdd(IGKCircularBuffer buffer, void* pointerToData) +void IGKCircularBufferAdd(IGKCircularBuffer buffer, void* pointerToData) { //If the buffer needs to grow if (buffer.elementCount + 1 > buffer.allocatedCount && buffer.allocatedCount < buffer.maximumCount) @@ -65,7 +59,7 @@ IGKCircularBuffer IGKCircularBufferCreate(CFIndex maximumCount, CFIndex elementS if (!newItems) { //Do something if reallocf fails - return NULL; + return; } //Set our variables @@ -114,7 +108,7 @@ IGKCircularBuffer IGKCircularBufferCreate(CFIndex maximumCount, CFIndex elementS } //Get a pointer to the raw data and the length of the data, eg to pass to NSData -IGKCircularBuffer* IGKCircularBufferRawData(IGKCircularBuffer buffer) +void* IGKCircularBufferRawData(IGKCircularBuffer buffer) { return buffer.items; } @@ -125,6 +119,34 @@ CFIndex IGKCircularBufferRawDataLength(IGKCircularBuffer buffer) return 0; } +//Get data in a format suitable for writing out to disk +NSData* IGKCircularBufferOrderedData(IGKCircularBuffer buffer) +{ + NSMutableData *data = [[NSMutableData alloc] initWithCapacity:IGKCircularBufferOrderedDataLength(buffer)]; + + if (buffer.elementCount == 0) + return data; + + for (CFIndex i = buffer.oldestElement; ; i = (i + 1) % buffer.elementCount) + { + if (buffer.items + i == NULL) + continue; + + [data appendBytes:buffer.items + i * buffer.elementSize length:buffer.elementSize]; + + if (i == buffer.youngestElement) + break; + } + + return data; +} +CFIndex IGKCircularBufferOrderedDataLength(IGKCircularBuffer buffer) +{ + if (buffer.items) + return buffer.elementCount * buffer.elementSize; + return 0; +} + //Delete the buffer void IGKCircularBufferFree(IGKCircularBuffer buffer) { diff --git a/IGKDocRecordManagedObject.h b/IGKDocRecordManagedObject.h index 2dff855..02ec6ac 100644 --- a/IGKDocRecordManagedObject.h +++ b/IGKDocRecordManagedObject.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 25/01/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKDocRecordManagedObject.m b/IGKDocRecordManagedObject.m index 20b7949..aca37b4 100644 --- a/IGKDocRecordManagedObject.m +++ b/IGKDocRecordManagedObject.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 25/01/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKDocRecordManagedObject.h" @@ -552,5 +552,9 @@ - (NSImage *)iconForSelectedState:(BOOL)isSelected return [[CHSymbolButtonImage symbolImageWithMask:mask] objectAtIndex:index]; } +- (NSNumber *)lengthOfContent +{ + return [self valueForKey:@"contentsLength"]; +} @end diff --git a/IGKDocSetManagedObject.h b/IGKDocSetManagedObject.h index bb31c2c..7412f3d 100644 --- a/IGKDocSetManagedObject.h +++ b/IGKDocSetManagedObject.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 04/03/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKDocSetManagedObject.m b/IGKDocSetManagedObject.m index 35bf2dd..af4c90c 100644 --- a/IGKDocSetManagedObject.m +++ b/IGKDocSetManagedObject.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 04/03/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKDocSetManagedObject.h" diff --git a/IGKEaseInOutAnimatedView.h b/IGKEaseInOutAnimatedView.h index 004bc5b..c69f298 100644 --- a/IGKEaseInOutAnimatedView.h +++ b/IGKEaseInOutAnimatedView.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 11/03/2010. -// Copyright 2010 __MyCompanyName__. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKEaseInOutAnimatedView.m b/IGKEaseInOutAnimatedView.m index 6f5a0eb..0770b21 100644 --- a/IGKEaseInOutAnimatedView.m +++ b/IGKEaseInOutAnimatedView.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 11/03/2010. -// Copyright 2010 __MyCompanyName__. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKEaseInOutAnimatedView.h" diff --git a/IGKFilterBarTableView.h b/IGKFilterBarTableView.h index a577d01..84787d5 100644 --- a/IGKFilterBarTableView.h +++ b/IGKFilterBarTableView.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 17/04/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKFilterBarTableView.m b/IGKFilterBarTableView.m index 9ba0f36..e7ca635 100644 --- a/IGKFilterBarTableView.m +++ b/IGKFilterBarTableView.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 17/04/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKFilterBarTableView.h" diff --git a/IGKFindBackgroundView.h b/IGKFindBackgroundView.h index 407c095..f372907 100644 --- a/IGKFindBackgroundView.h +++ b/IGKFindBackgroundView.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 17/04/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKFindBackgroundView.m b/IGKFindBackgroundView.m index 90ccd3d..fee2edc 100644 --- a/IGKFindBackgroundView.m +++ b/IGKFindBackgroundView.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 17/04/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKFindBackgroundView.h" diff --git a/IGKFindWindow.h b/IGKFindWindow.h index 9757cdd..29111b8 100644 --- a/IGKFindWindow.h +++ b/IGKFindWindow.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 18/04/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKFindWindow.m b/IGKFindWindow.m index 94cb753..105eb1c 100644 --- a/IGKFindWindow.m +++ b/IGKFindWindow.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 18/04/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKFindWindow.h" diff --git a/IGKForwardView.h b/IGKForwardView.h index 74b168f..8d35646 100644 --- a/IGKForwardView.h +++ b/IGKForwardView.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Jean-Nicolas Jolivet on 10-05-06. -// Copyright 2010 SilverCocoa. All rights reserved. +// Written in 2010 by SilverCocoa. // #import diff --git a/IGKForwardView.m b/IGKForwardView.m index 28d7447..36e5b29 100644 --- a/IGKForwardView.m +++ b/IGKForwardView.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Jean-Nicolas Jolivet on 10-05-06. -// Copyright 2010 SilverCocoa. All rights reserved. +// Written in 2010 by SilverCocoa. // #import "IGKForwardView.h" diff --git a/IGKFrecencyStore.h b/IGKFrecencyStore.h new file mode 100644 index 0000000..e484257 --- /dev/null +++ b/IGKFrecencyStore.h @@ -0,0 +1,24 @@ +// +// IGKFrecencyStore.h +// Ingredients +// +// Created by Alex Gordon on 01/07/2010. +// Written in 2010 by Fileability. +// + +#import +#import "IGKCircularBuffer.h" + +@interface IGKFrecencyStore : NSObject { + NSString *identifier; + IGKCircularBuffer buffer; + + BOOL hasChanges; +} + ++ (id)storeWithIdentifier:(NSString *)identifier; + +- (void)recordItem:(NSString *)item; +- (NSArray *)timestampsForItem:(NSString *)item count:(uint64_t *)count; + +@end diff --git a/IGKFrecencyStore.m b/IGKFrecencyStore.m new file mode 100644 index 0000000..25eea88 --- /dev/null +++ b/IGKFrecencyStore.m @@ -0,0 +1,197 @@ +// +// IGKFrecencyStore.m +// Ingredients +// +// Created by Alex Gordon on 01/07/2010. +// Written in 2010 by Fileability. +// + +#import "IGKFrecencyStore.h" + + +typedef struct { + int64_t timestamp; + NSString *item; + + // IF YOU MODIFY THIS STRUCT YOU ******MUST****** INCREMENT IGKFrecencyStoreBufferRecordVersion !!!!!!1!1!!!!1!ONE!1!!ELEVENTY1 + +} IGKFrecencyStoreBufferRecord; + +// vvvvv THAT'S THIS THING vvvvv +const int IGKFrecencyStoreBufferRecordVersion = 1; +// ^^^^^^ ^^^^^^^^^^^^^^^^ ^^^^^ + + +@interface IGKFrecencyStore () + +- (NSString *)storeDirectory; +- (NSString *)storeExtension; +- (NSString *)path; +- (void)readFromDisk; +- (void)writeToDisk; +- (void)heartbeat; + +@end + + +@implementation IGKFrecencyStore + +#pragma mark Life Cycle + +static NSMutableDictionary *stores = nil; + ++ (id)storeWithIdentifier:(NSString *)ident +{ + return nil; + + if ([stores objectForKey:ident]) + return [stores objectForKey:ident]; + + if (!stores) + stores = [[NSMutableDictionary alloc] initWithCapacity:5]; + + IGKFrecencyStore *store = [[[self alloc] initWithIdentifier:ident] autorelease]; + [stores setValue:store forKey:ident]; + + return store; +} +- (id)initWithIdentifier:(NSString *)ident +{ + if (self = [super init]) + { + identifier = [ident copy]; + + [self readFromDisk]; + + [self heartbeat]; + } + + return self; +} +- (void)finalize +{ + IGKCircularBufferFree(buffer); + + [super finalize]; +} + + +#pragma mark Recording and Reading + +- (void)recordItem:(NSString *)item +{ + int64_t timestamp = (int64_t)[NSDate timeIntervalSinceReferenceDate]; + + IGKFrecencyStoreBufferRecord record; + record.timestamp = timestamp; + record.item = item; + + IGKCircularBufferAdd(buffer, &record); + + hasChanges = YES; +} +- (NSArray *)timestampsForItem:(NSString *)item count:(uint64_t *)count +{ + //If no variable to put count in is specified, they can't do anything but crash, so return NULL + if (!count) + return NULL; + + CFIndex length = IGKCircularBufferRawDataLength(buffer); + IGKFrecencyStoreBufferRecord* data = (IGKFrecencyStoreBufferRecord*)IGKCircularBufferRawData(buffer); + + NSMutableArray *timestamps = [[NSMutableArray alloc] initWithCapacity:100]; + + if (buffer.elementCount > 0) + { + for (CFIndex i = buffer.oldestElement; ; i = (i + 1) % buffer.elementCount) + { + if (data + i == NULL) + continue; + + IGKFrecencyStoreBufferRecord record = data[i]; + if ([record.item isEqual:item]) + { + [timestamps addObject:[NSNumber numberWithLongLong:record.timestamp]]; + } + + if (i == buffer.youngestElement) + break; + } + } + + return timestamps; +} + +#pragma mark File IO + +const CFIndex IGKFrecencyStoreMaximumCount = 1000; +const CFIndex IGKFrecencyStoreInitialCount = 100; + +- (NSString *)storeDirectory +{ + // /Frecency/ + + NSString *appSupport = [[[NSApp delegate] kitController] applicationSupportDirectory]; + + return [appSupport stringByAppendingPathComponent:@"Frecency"]; +} +- (NSString *)storeExtension +{ + return [NSString stringWithFormat:@"igkfrecencystore%d", IGKFrecencyStoreBufferRecordVersion]; +} +- (NSString *)path +{ + return [[[self storeDirectory] stringByAppendingPathComponent:identifier] stringByAppendingPathExtension:[self storeExtension]]; +} +- (void)readFromDisk +{ + NSString *path = [self path]; + + NSError *err = nil; + NSData *data = [[NSData alloc] initWithContentsOfFile:path options:NSDataReadingUncached error:&err]; + + if (!data || err) + { + buffer = IGKCircularBufferCreate(IGKFrecencyStoreMaximumCount, sizeof(IGKFrecencyStoreBufferRecord), IGKFrecencyStoreInitialCount); + return; + } + + //Read from data + buffer = IGKCircularBufferCreateFromData([data bytes], [data length], IGKFrecencyStoreMaximumCount, sizeof(IGKFrecencyStoreBufferRecord)); +} +- (void)writeToDisk +{ + NSLog(@"Writing IGKFrecencyStore %@ to disk. It has%@ changes", identifier, hasChanges ? @"" : @" no"); + + if (!hasChanges) + return; + hasChanges = NO; + + NSString *path = [self path]; + NSLog(@"\t path = '%@'", path); + + //Create the directory + [[NSFileManager defaultManager] createDirectoryAtPath:[self storeDirectory] withIntermediateDirectories:YES attributes:nil error:nil]; + + //Get data from buffer + if (buffer.elementCount == 0) + return; + NSData *data = IGKCircularBufferOrderedData(buffer); + NSLog(@"\t data [%ud] %@", [data length], data); + + //Write to disk + NSError *err = nil; + [data writeToFile:path options:NSDataWritingAtomic error:&err]; + NSLog(@"\t err = %@", err); +} +- (void)heartbeat +{ + NSLog(@"Heartbeat on IGKFrecencyStore %@", identifier); + + [self writeToDisk]; + + //We want to do a write every 20 seconds + [self performSelector:@selector(heartbeat) withObject:nil afterDelay:5.0]; +} + +@end diff --git a/IGKHTMLGenerator.h b/IGKHTMLGenerator.h index fd654c0..8fd3d15 100644 --- a/IGKHTMLGenerator.h +++ b/IGKHTMLGenerator.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 26/01/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKHTMLGenerator.m b/IGKHTMLGenerator.m index 4bf7c78..ca7017a 100644 --- a/IGKHTMLGenerator.m +++ b/IGKHTMLGenerator.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 26/01/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKHTMLGenerator.h" diff --git a/IGKLaunchController.h b/IGKLaunchController.h index 81af4f8..dde6341 100644 --- a/IGKLaunchController.h +++ b/IGKLaunchController.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 10/02/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKLaunchController.m b/IGKLaunchController.m index 5dd2d9d..54e1e76 100644 --- a/IGKLaunchController.m +++ b/IGKLaunchController.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 10/02/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKLaunchController.h" diff --git a/IGKManagedObject.h b/IGKManagedObject.h index b1ab218..b1663db 100644 --- a/IGKManagedObject.h +++ b/IGKManagedObject.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 08/04/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKManagedObject.m b/IGKManagedObject.m index 2fac737..7a48b04 100644 --- a/IGKManagedObject.m +++ b/IGKManagedObject.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 08/04/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKManagedObject.h" diff --git a/IGKMatteButton.h b/IGKMatteButton.h index e6af86c..02828a5 100644 --- a/IGKMatteButton.h +++ b/IGKMatteButton.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 19/06/2010. -// Copyright 2010 __MyCompanyName__. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKMatteButton.m b/IGKMatteButton.m index ba97483..8529ca4 100644 --- a/IGKMatteButton.m +++ b/IGKMatteButton.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 19/06/2010. -// Copyright 2010 __MyCompanyName__. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKMatteButton.h" diff --git a/IGKMatteFocusedGradientBox.h b/IGKMatteFocusedGradientBox.h index 31553a7..0977b03 100644 --- a/IGKMatteFocusedGradientBox.h +++ b/IGKMatteFocusedGradientBox.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 20/04/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKMatteFocusedGradientBox.m b/IGKMatteFocusedGradientBox.m index 3985f22..2061b1b 100644 --- a/IGKMatteFocusedGradientBox.m +++ b/IGKMatteFocusedGradientBox.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 20/04/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKMatteFocusedGradientBox.h" diff --git a/IGKMattePopUpButton.h b/IGKMattePopUpButton.h index d7483b0..f7d4028 100644 --- a/IGKMattePopUpButton.h +++ b/IGKMattePopUpButton.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 09/03/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKMattePopUpButton.m b/IGKMattePopUpButton.m index f946fcf..638a5d8 100644 --- a/IGKMattePopUpButton.m +++ b/IGKMattePopUpButton.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 09/03/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKMattePopUpButton.h" diff --git a/IGKMattePopUpButtonView.h b/IGKMattePopUpButtonView.h index 5a5639b..9d14701 100644 --- a/IGKMattePopUpButtonView.h +++ b/IGKMattePopUpButtonView.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 20/04/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKMattePopUpButtonView.m b/IGKMattePopUpButtonView.m index d0052b8..96ab4bf 100644 --- a/IGKMattePopUpButtonView.m +++ b/IGKMattePopUpButtonView.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 20/04/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKMattePopUpButtonView.h" diff --git a/IGKMatteSegmentedControl.h b/IGKMatteSegmentedControl.h index 0298410..822b941 100644 --- a/IGKMatteSegmentedControl.h +++ b/IGKMatteSegmentedControl.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 27/02/2010. -// Copyright 2010 __MyCompanyName__. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKMatteSegmentedControl.m b/IGKMatteSegmentedControl.m index fdc3b39..9f748a1 100644 --- a/IGKMatteSegmentedControl.m +++ b/IGKMatteSegmentedControl.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 27/02/2010. -// Copyright 2010 __MyCompanyName__. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKMatteSegmentedControl.h" diff --git a/IGKMultiSelector.h b/IGKMultiSelector.h index 2285c3b..b064a9e 100644 --- a/IGKMultiSelector.h +++ b/IGKMultiSelector.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 22/02/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKMultiSelector.m b/IGKMultiSelector.m index c4d012a..2fd0ddd 100644 --- a/IGKMultiSelector.m +++ b/IGKMultiSelector.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 22/02/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKMultiSelector.h" diff --git a/IGKNoSelectionInnerView.h b/IGKNoSelectionInnerView.h index 04844de..f1aaebf 100644 --- a/IGKNoSelectionInnerView.h +++ b/IGKNoSelectionInnerView.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 13/02/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKNoSelectionInnerView.m b/IGKNoSelectionInnerView.m index c67fc57..e2c8b06 100644 --- a/IGKNoSelectionInnerView.m +++ b/IGKNoSelectionInnerView.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 13/02/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKNoSelectionInnerView.h" diff --git a/IGKNoSelectionOuterView.h b/IGKNoSelectionOuterView.h index bc07a91..73721aa 100644 --- a/IGKNoSelectionOuterView.h +++ b/IGKNoSelectionOuterView.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 13/02/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKNoSelectionOuterView.m b/IGKNoSelectionOuterView.m index b26acab..b3f89af 100644 --- a/IGKNoSelectionOuterView.m +++ b/IGKNoSelectionOuterView.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 13/02/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKNoSelectionOuterView.h" diff --git a/IGKOutputStream.h b/IGKOutputStream.h index f1e2348..9c33d2a 100644 --- a/IGKOutputStream.h +++ b/IGKOutputStream.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 09/06/2010. -// Copyright 2010 __MyCompanyName__. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKOutputStream.m b/IGKOutputStream.m index 304dd37..10547c2 100644 --- a/IGKOutputStream.m +++ b/IGKOutputStream.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 09/06/2010. -// Copyright 2010 __MyCompanyName__. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKOutputStream.h" diff --git a/IGKPredicateEditor.h b/IGKPredicateEditor.h index 6c86751..58a75c1 100644 --- a/IGKPredicateEditor.h +++ b/IGKPredicateEditor.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 23/03/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKPredicateEditor.m b/IGKPredicateEditor.m index d033ca8..7a6cd48 100644 --- a/IGKPredicateEditor.m +++ b/IGKPredicateEditor.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 23/03/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKPredicateEditor.h" diff --git a/IGKPreferencesController.h b/IGKPreferencesController.h index 6911f1f..800c167 100644 --- a/IGKPreferencesController.h +++ b/IGKPreferencesController.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 07/03/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKPreferencesController.m b/IGKPreferencesController.m index 42b8ec5..396acaf 100644 --- a/IGKPreferencesController.m +++ b/IGKPreferencesController.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 07/03/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKPreferencesController.h" diff --git a/IGKResizeDelegatedView.h b/IGKResizeDelegatedView.h index 0c66ccb..ff8d0f5 100644 --- a/IGKResizeDelegatedView.h +++ b/IGKResizeDelegatedView.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 18/04/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKResizeDelegatedView.m b/IGKResizeDelegatedView.m index f12568d..c7af697 100644 --- a/IGKResizeDelegatedView.m +++ b/IGKResizeDelegatedView.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 18/04/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKResizeDelegatedView.h" diff --git a/IGKScraper.h b/IGKScraper.h index 230b9c7..e7b2db1 100644 --- a/IGKScraper.h +++ b/IGKScraper.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 24/01/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKScraper.m b/IGKScraper.m index f1c7a5d..073cb59 100644 --- a/IGKScraper.m +++ b/IGKScraper.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 24/01/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKScraper.h" @@ -277,6 +277,7 @@ - (NSManagedObject *)extractPath:(NSString *)extractPath relativeExtractPath:(NS //Let's try to extract the class's name (assuming it is a class of course) NSError *error = nil; NSString *contents = [NSString stringWithContentsOfFile:extractPath encoding:NSUTF8StringEncoding error:&error]; + NSUInteger contentsLength = [contents length]; if (error || !contents) { return nil; @@ -430,6 +431,7 @@ - (NSManagedObject *)extractPath:(NSString *)extractPath relativeExtractPath:(NS { obj = [self addRecordNamed:name entityName:entityName desc:@"" sourcePath:relativeExtractPath]; [obj setValue:docset forKey:@"docset"]; + [obj setValue:[NSNumber numberWithUnsignedInteger:contentsLength] forKey:@"contentsLength"]; if ([superclass length]) [obj setValue:superclass forKey:@"superclassName"]; diff --git a/IGKShyTableView.h b/IGKShyTableView.h index 545854f..a2be870 100644 --- a/IGKShyTableView.h +++ b/IGKShyTableView.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 22/02/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKShyTableView.m b/IGKShyTableView.m index 95a11b2..2d2092e 100644 --- a/IGKShyTableView.m +++ b/IGKShyTableView.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 22/02/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKShyTableView.h" diff --git a/IGKSometimesCenteredTextCell.h b/IGKSometimesCenteredTextCell.h index 3b54a73..680ce6b 100644 --- a/IGKSometimesCenteredTextCell.h +++ b/IGKSometimesCenteredTextCell.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 04/03/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKSometimesCenteredTextCell.m b/IGKSometimesCenteredTextCell.m index ca261e5..2a70fb5 100644 --- a/IGKSometimesCenteredTextCell.m +++ b/IGKSometimesCenteredTextCell.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 04/03/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKSometimesCenteredTextCell.h" diff --git a/IGKSourceListWallpaperView.h b/IGKSourceListWallpaperView.h index 799e639..61294f1 100644 --- a/IGKSourceListWallpaperView.h +++ b/IGKSourceListWallpaperView.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 10/02/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKSourceListWallpaperView.m b/IGKSourceListWallpaperView.m index b087ac0..2e830a4 100644 --- a/IGKSourceListWallpaperView.m +++ b/IGKSourceListWallpaperView.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 10/02/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKSourceListWallpaperView.h" diff --git a/IGKTableOfContentsView.h b/IGKTableOfContentsView.h index f893996..0ac3ad7 100644 --- a/IGKTableOfContentsView.h +++ b/IGKTableOfContentsView.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 06/03/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKTableOfContentsView.m b/IGKTableOfContentsView.m index 77f725a..c8688c5 100644 --- a/IGKTableOfContentsView.m +++ b/IGKTableOfContentsView.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 06/03/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKTableOfContentsView.h" diff --git a/IGKWindow.h b/IGKWindow.h index 4ee67c8..01f392b 100644 --- a/IGKWindow.h +++ b/IGKWindow.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 22/02/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKWindow.m b/IGKWindow.m index cdf30ae..ecd30d2 100644 --- a/IGKWindow.m +++ b/IGKWindow.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 22/02/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKWindow.h" diff --git a/IGKWindowController.h b/IGKWindowController.h index 0f3cddb..1ced23d 100644 --- a/IGKWindowController.h +++ b/IGKWindowController.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 23/01/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import @@ -150,7 +150,9 @@ typedef enum { BOOL shouldIndex; BOOL isIndexing; BOOL isInFullscreen; - + + long frecencyToken; + NSManagedObjectID *currentObjectIDInBrowser; NSArray *selectedFilterDocset; diff --git a/IGKWindowController.m b/IGKWindowController.m index 19a5ff3..980fc9a 100644 --- a/IGKWindowController.m +++ b/IGKWindowController.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 23/01/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKWindowController.h" @@ -16,6 +16,7 @@ #import "IGKDocRecordManagedObject.h" #import "CHSymbolButtonImage.h" #import "IGKSometimesCenteredTextCell.h" +#import "IGKFrecencyStore.h" @interface IGKWindowController () @@ -32,7 +33,7 @@ - (void)sideSearchTableChangedSelection; - (void)tableOfContentsChangedSelection; - (void)registerDisplayTypeInTableView:(IGKHTMLDisplayType)type title:(NSString *)title; -- (void)loadManagedObject:(IGKDocRecordManagedObject *)mo tableOfContentsMask:(IGKHTMLDisplayTypeMask)tm; +- (void)loadManagedObject:(IGKDocRecordManagedObject *)mo tableOfContentsMask:(IGKHTMLDisplayTypeMask)tm URL:(NSURL *)url; - (void)setMode:(int)modeIndex; - (IGKArrayController *)currentArrayController; @@ -620,6 +621,7 @@ - (void)loadURLRequest:(NSURLRequest *)urlRequest recordHistory:(BOOL)recordHist NSURL *url = [urlRequest URL]; isNonFilterBarType = YES; + frecencyToken = 0; // set default title [[self window] setTitle:@"Documentation"]; @@ -643,22 +645,24 @@ - (void)loadURLRequest:(NSURLRequest *)urlRequest recordHistory:(BOOL)recordHist [[browserWebView mainFrame] loadHTMLString:html baseURL:[[NSBundle mainBundle] resourceURL]]; } - - NSLog(@"Load URL = %@, record history = %d", url, recordHistory); - NSManagedObjectContext *ctx = [[[NSApp delegate] valueForKey:@"kitController"] managedObjectContext]; - - tableOfContentsMask = IGKHTMLDisplayType_None; - IGKDocRecordManagedObject *result = [IGKDocRecordManagedObject resolveURL:url inContext:ctx tableOfContentsMask:&tableOfContentsMask]; - - if (result) - { - [self setBrowserActive:YES]; - [self loadManagedObject:result tableOfContentsMask:tableOfContentsMask]; - if (recordHistory) - [self recordHistoryForURL:url title:[result valueForKey:@"name"]]; + else + { + NSLog(@"Load URL = %@, record history = %d", url, recordHistory); + NSManagedObjectContext *ctx = [[[NSApp delegate] valueForKey:@"kitController"] managedObjectContext]; + + tableOfContentsMask = IGKHTMLDisplayType_None; + IGKDocRecordManagedObject *result = [IGKDocRecordManagedObject resolveURL:url inContext:ctx tableOfContentsMask:&tableOfContentsMask]; + + if (result) + { + [self setBrowserActive:YES]; + [self loadManagedObject:result tableOfContentsMask:tableOfContentsMask URL:url]; + if (recordHistory) + [self recordHistoryForURL:url title:[result valueForKey:@"name"]]; + } + + [self reloadTableOfContents]; } - - [self reloadTableOfContents]; } else { @@ -668,8 +672,9 @@ - (void)loadURLRequest:(NSURLRequest *)urlRequest recordHistory:(BOOL)recordHist [[browserWebView mainFrame] loadRequest:urlRequest]; } } -- (void)loadManagedObject:(IGKDocRecordManagedObject *)mo tableOfContentsMask:(IGKHTMLDisplayTypeMask)tm +- (void)loadManagedObject:(IGKDocRecordManagedObject *)mo tableOfContentsMask:(IGKHTMLDisplayTypeMask)tm URL:(NSURL *)url { + frecencyToken = 0; currentObjectIDInBrowser = [mo objectID]; IGKHTMLGenerator *generator = [[IGKHTMLGenerator alloc] init]; @@ -705,7 +710,30 @@ - (void)loadManagedObject:(IGKDocRecordManagedObject *)mo tableOfContentsMask:(I [self reloadRightFilterBarTable:mo transient:[generator transientObject]]; [generator finish]; + + + //Find out if we're still here in 5 seconds + + if (url) + { + frecencyToken = random(); + + NSArray *frecencyData = [NSArray arrayWithObjects:[NSNumber numberWithLong:frecencyToken], url, nil]; + [self performSelector:@selector(checkIfStillAlive:) withObject:frecencyData afterDelay:5.0]; + } } +- (void)checkIfStillAlive:(NSArray *)frecencyData +{ + if ([[frecencyData objectAtIndex:0] longValue] == frecencyToken) + { + //This was a triumph + IGKFrecencyStore *frecencyStore = [IGKFrecencyStore storeWithIdentifier:@"net.fileability.ingredients.DocumentationArticleURLFrecency"]; + + //I'm making a note here + [frecencyStore recordItem:[[frecencyData objectAtIndex:1] absoluteString]]; + } +} + - (void)recordHistoryForURL:(NSURL *)url title:(NSString *)title { WebHistoryItem *item = [[WebHistoryItem alloc] initWithURLString:[url absoluteString] title:title lastVisitedTimeInterval:[NSDate timeIntervalSinceReferenceDate]]; @@ -835,6 +863,7 @@ - (void)startIndexing [twoPaneSplitView setColorIsEnabled:YES]; [twoPaneSplitView setColor:[NSColor colorWithCalibratedRed:0.166 green:0.166 blue:0.166 alpha:1.000]]; + frecencyToken = 0; [[browserWebView mainFrame] loadRequest:[NSURLRequest requestWithURL: [NSURL fileURLWithPath: [[NSBundle mainBundle] pathForResource:@"tictactoe" ofType:@"html"] @@ -1736,7 +1765,7 @@ - (void)sideSearchTableChangedSelection [self restoreAdvancedSearchStateIntoTwoUp:YES]; //Open in two up - //TODO: Make which view this switched to a preference. It could switch to either Two Up or Browser Only + //TODO: Record a preference for whichever view this switched to. It could switch to either Two Up or Browser Only [self setMode:CHDocumentationBrowserUIMode_TwoUp]; } @@ -1816,6 +1845,8 @@ - (IGKArrayController *)currentArrayController } - (void)loadDocIntoBrowser { + frecencyToken = 0; + //Generate the HTML if (![[self currentArrayController] selection]) return; @@ -1834,9 +1865,10 @@ - (void)loadDocIntoBrowser tableOfContentsMask = dtmask; - [self loadManagedObject:(IGKDocRecordManagedObject *)currentSelectionObject tableOfContentsMask:[self tableOfContentsSelectedDisplayTypeMask]]; + NSURL *url = [(IGKDocRecordManagedObject *)currentSelectionObject docURL:[self tableOfContentsSelectedDisplayTypeMask]]; + [self loadManagedObject:(IGKDocRecordManagedObject *)currentSelectionObject tableOfContentsMask:[self tableOfContentsSelectedDisplayTypeMask] URL:url]; - [self recordHistoryForURL:[(IGKDocRecordManagedObject *)currentSelectionObject docURL:[self tableOfContentsSelectedDisplayTypeMask]] title:[currentSelectionObject pageTitle:[self tableOfContentsSelectedDisplayTypeMask]]]; + [self recordHistoryForURL:url title:[currentSelectionObject pageTitle:[self tableOfContentsSelectedDisplayTypeMask]]]; } - (IBAction)openInSafari:(id)sender @@ -1914,7 +1946,6 @@ - (NSURLRequest *)webView:(WebView *)sender resource:(id)identifier willSendRequ if ([[[[request URL] host] lowercaseString] isEqual:@"ingr-doc"]) { - NSLog(@"ingr-doc: %@", url); if ([[url path] containsString:@"headerfile"]) { NSLog(@"FOUND HEADER"); @@ -1925,9 +1956,7 @@ - (NSURLRequest *)webView:(WebView *)sender resource:(id)identifier willSendRequ { NSArray *newcomps = [[NSArray arrayWithObject:@"/"] arrayByAddingObjectsFromArray:[comps subarrayWithRange:NSMakeRange(2, [comps count] - 2)]]; NSURL *newURL = [[NSURL alloc] initWithScheme:@"ingr-doc" host:[comps objectAtIndex:1] path:[NSString pathWithComponents:newcomps]]; - - NSLog(@"\t Now loading: %@", newURL); - + [self performSelector:@selector(loadURLRecordHistory:) withObject:newURL afterDelay:0.0]; return nil; } diff --git a/IGKWordMembership.h b/IGKWordMembership.h index f120f29..ef65fd5 100644 --- a/IGKWordMembership.h +++ b/IGKWordMembership.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 02/05/2010. -// Copyright 2010 __MyCompanyName__. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/IGKWordMembership.m b/IGKWordMembership.m index 8af6edb..5ebbb69 100644 --- a/IGKWordMembership.m +++ b/IGKWordMembership.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 02/05/2010. -// Copyright 2010 __MyCompanyName__. All rights reserved. +// Written in 2010 by Fileability. // #import "IGKWordMembership.h" diff --git a/Ingredients-Info.plist b/Ingredients-Info.plist index 47801e5..4a9ec70 100644 --- a/Ingredients-Info.plist +++ b/Ingredients-Info.plist @@ -19,9 +19,9 @@ CFBundleSignature ???? CFBundleVersion - 0.6 + 0.7 CFBundleShortVersionString - 0.6 + 0.7 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSMainNibFile diff --git a/Ingredients.xcodeproj/project.pbxproj b/Ingredients.xcodeproj/project.pbxproj index 5762c1a..c2e9c8b 100644 --- a/Ingredients.xcodeproj/project.pbxproj +++ b/Ingredients.xcodeproj/project.pbxproj @@ -35,6 +35,8 @@ 751E45D61125E6CE00CD544A /* tictactoe_style.css in Resources */ = {isa = PBXBuildFile; fileRef = 751E45D51125E6CE00CD544A /* tictactoe_style.css */; }; 752321CA1179DE5400BAEA90 /* IGKBackgroundProgressBar.h in Headers */ = {isa = PBXBuildFile; fileRef = 752321C81179DE5400BAEA90 /* IGKBackgroundProgressBar.h */; }; 752321CB1179DE5400BAEA90 /* IGKBackgroundProgressBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 752321C91179DE5400BAEA90 /* IGKBackgroundProgressBar.m */; }; + 7529260511DDA65C0003CE54 /* IGKFrecencyStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 7529260311DDA65C0003CE54 /* IGKFrecencyStore.h */; }; + 7529260611DDA65C0003CE54 /* IGKFrecencyStore.m in Sources */ = {isa = PBXBuildFile; fileRef = 7529260411DDA65C0003CE54 /* IGKFrecencyStore.m */; }; 75301F6D11B2F04A006DA0E3 /* annotations.js in Sources */ = {isa = PBXBuildFile; fileRef = 75301F6C11B2F04A006DA0E3 /* annotations.js */; }; 75301FA911B2F55D006DA0E3 /* annotations.js in Resources */ = {isa = PBXBuildFile; fileRef = 75301F6C11B2F04A006DA0E3 /* annotations.js */; }; 754AA3FA1140267300321EAF /* AnthillBugReporter.m in Sources */ = {isa = PBXBuildFile; fileRef = 754AA3F91140267300321EAF /* AnthillBugReporter.m */; }; @@ -247,6 +249,8 @@ 751E45D51125E6CE00CD544A /* tictactoe_style.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = tictactoe_style.css; sourceTree = ""; }; 752321C81179DE5400BAEA90 /* IGKBackgroundProgressBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IGKBackgroundProgressBar.h; sourceTree = ""; }; 752321C91179DE5400BAEA90 /* IGKBackgroundProgressBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IGKBackgroundProgressBar.m; sourceTree = ""; }; + 7529260311DDA65C0003CE54 /* IGKFrecencyStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IGKFrecencyStore.h; sourceTree = ""; }; + 7529260411DDA65C0003CE54 /* IGKFrecencyStore.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IGKFrecencyStore.m; sourceTree = ""; }; 75301F6C11B2F04A006DA0E3 /* annotations.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = annotations.js; path = HTML_Example/annotations.js; sourceTree = ""; }; 754AA3F81140267300321EAF /* AnthillBugReporter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AnthillBugReporter.h; path = "Anthill Cocoa/AnthillBugReporter.h"; sourceTree = ""; }; 754AA3F91140267300321EAF /* AnthillBugReporter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AnthillBugReporter.m; path = "Anthill Cocoa/AnthillBugReporter.m"; sourceTree = ""; }; @@ -445,6 +449,8 @@ 0C35D86D118B65920013DDFD /* IGKAnnotation.m */, 75ADECE8118E0B9500C57C77 /* IGKWordMembership.h */, 75ADECE9118E0B9500C57C77 /* IGKWordMembership.m */, + 7529260311DDA65C0003CE54 /* IGKFrecencyStore.h */, + 7529260411DDA65C0003CE54 /* IGKFrecencyStore.m */, 75BD17791143E92700E67594 /* Preferences */, 756F9FF6110C803D00E6F291 /* Scraping */, 0C7C02E3110DFFF300412666 /* Views & Cells */, @@ -815,6 +821,7 @@ 75BC565611CDD5900012800F /* IGKMatteButton.h in Headers */, 756EFCFE11DA5CB800BC978A /* IGKCircularBuffer.h in Headers */, 75E747D211DC2CF3009B89CB /* smartcmp.h in Headers */, + 7529260511DDA65C0003CE54 /* IGKFrecencyStore.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1006,6 +1013,7 @@ 75BC565711CDD5900012800F /* IGKMatteButton.m in Sources */, 756EFCFF11DA5CB800BC978A /* IGKCircularBuffer.m in Sources */, 75E747D511DC2DEB009B89CB /* smartcmp.m in Sources */, + 7529260611DDA65C0003CE54 /* IGKFrecencyStore.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/IngredientsKit.h b/IngredientsKit.h index de75b6e..651b65a 100644 --- a/IngredientsKit.h +++ b/IngredientsKit.h @@ -3,7 +3,7 @@ * Ingredients * * Created by Alex Gordon on 23/01/2010. - * Copyright 2010 Fileability. All rights reserved. + * Written in 2010 by Fileability. * */ diff --git a/Ingredients_AppDelegate.h b/Ingredients_AppDelegate.h index a5042a3..a5fd86d 100644 --- a/Ingredients_AppDelegate.h +++ b/Ingredients_AppDelegate.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 23/01/2010. -// Copyright Fileability 2010 . All rights reserved. +// Copyright Fileability 2010 . Written in 2010 by Fileability.. // #import diff --git a/Ingredients_AppDelegate.m b/Ingredients_AppDelegate.m index c3c9d00..f526c86 100644 --- a/Ingredients_AppDelegate.m +++ b/Ingredients_AppDelegate.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 23/01/2010. -// Copyright Fileability 2010 . All rights reserved. +// Copyright Fileability 2010 . Written in 2010 by Fileability.. // #import "Ingredients_AppDelegate.h" @@ -13,6 +13,7 @@ @implementation Ingredients_AppDelegate - (void)applicationDidFinishLaunching:(NSNotification *)notification { + srandom((unsigned long)[NSDate timeIntervalSinceReferenceDate]); PFMoveToApplicationsFolderIfNecessary(); [kitController showWindow:nil]; diff --git a/Ingredients_DataModel.xcdatamodel/elements b/Ingredients_DataModel.xcdatamodel/elements index 3ee5ce1..47d0e11 100644 Binary files a/Ingredients_DataModel.xcdatamodel/elements and b/Ingredients_DataModel.xcdatamodel/elements differ diff --git a/Ingredients_DataModel.xcdatamodel/layout b/Ingredients_DataModel.xcdatamodel/layout index ffcc04d..6094a0f 100644 Binary files a/Ingredients_DataModel.xcdatamodel/layout and b/Ingredients_DataModel.xcdatamodel/layout differ diff --git a/NSArray+IGKAdditions.h b/NSArray+IGKAdditions.h index 4dee9fe..1671e21 100644 --- a/NSArray+IGKAdditions.h +++ b/NSArray+IGKAdditions.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 18/06/2010. -// Copyright 2010 __MyCompanyName__. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/NSArray+IGKAdditions.m b/NSArray+IGKAdditions.m index 5acdf51..1b54e64 100644 --- a/NSArray+IGKAdditions.m +++ b/NSArray+IGKAdditions.m @@ -3,12 +3,21 @@ // Ingredients // // Created by Alex Gordon on 18/06/2010. -// Copyright 2010 __MyCompanyName__. All rights reserved. +// Written in 2010 by Fileability. // #import "NSArray+IGKAdditions.h" #import "smartcmp.h" +NSComparisonResult IGKInverseComparisonResult(NSComparisonResult result) +{ + if (result == NSOrderedAscending) + return NSOrderedDescending; + if (result == NSOrderedDescending) + return NSOrderedAscending; + return NSOrderedSame; +} + @implementation NSArray (IGKAdditions) - (NSArray *)igk_map:(id (^)(id obj))rule @@ -96,12 +105,19 @@ - (NSArray *)smartSort:(NSString *)query //Sort the scores NSArray *sortedScores = [scores sortedArrayUsingComparator:^ NSComparisonResult (id a, id b) { - NSComparisonResult comparisonResult = [[a objectAtIndex:0] compare:[b objectAtIndex:0]]; - if (comparisonResult == NSOrderedAscending) - return NSOrderedDescending; - else if (comparisonResult == NSOrderedDescending) - return NSOrderedAscending; - return NSOrderedSame; + NSComparisonResult comparisonResult = IGKInverseComparisonResult([[a objectAtIndex:0] compare:[b objectAtIndex:0]]); + if (comparisonResult == NSOrderedSame) + { + //If we're really desperate we can compare the lengths of the contents + if ([[a objectAtIndex:1] respondsToSelector:@selector(lengthOfContent)]) + { + return IGKInverseComparisonResult([[[a objectAtIndex:1] lengthOfContent] compare:[[b objectAtIndex:1] lengthOfContent]]); + } + + return [[[a objectAtIndex:1] valueForKey:@"name"] compare:[[b objectAtIndex:1] valueForKey:@"name"]]; + } + + return comparisonResult; }]; diff --git a/NSBezierPath+MCAdditions.h b/NSBezierPath+MCAdditions.h index 972856d..209a051 100644 --- a/NSBezierPath+MCAdditions.h +++ b/NSBezierPath+MCAdditions.h @@ -2,7 +2,7 @@ // NSBezierPath+MCAdditions.h // // Created by Sean Patrick O'Brien on 4/1/08. -// Copyright 2008 MolokoCacao. All rights reserved. +// Copyright 2008 MolokoCacao. Written in 2010 by Fileability.. // #import diff --git a/NSBezierPath+MCAdditions.m b/NSBezierPath+MCAdditions.m index acc4951..dc9516a 100644 --- a/NSBezierPath+MCAdditions.m +++ b/NSBezierPath+MCAdditions.m @@ -2,7 +2,7 @@ // NSBezierPath+MCAdditions.m // // Created by Sean Patrick O'Brien on 4/1/08. -// Copyright 2008 MolokoCacao. All rights reserved. +// Copyright 2008 MolokoCacao. Written in 2010 by Fileability.. // #import "NSBezierPath+MCAdditions.h" @@ -97,7 +97,7 @@ - (CGPathRef)cgPath break; }; } - return thePath; + return NSMakeCollectable(thePath); } - (NSBezierPath *)pathWithStrokeWidth:(CGFloat)strokeWidth diff --git a/NSShadow+MCAdditions.h b/NSShadow+MCAdditions.h index 5870d51..c69e14c 100644 --- a/NSShadow+MCAdditions.h +++ b/NSShadow+MCAdditions.h @@ -2,7 +2,7 @@ // NSShadow+MCAdditions.h // // Created by Sean Patrick O'Brien on 4/3/08. -// Copyright 2008 MolokoCacao. All rights reserved. +// Copyright 2008 MolokoCacao. Written in 2010 by Fileability.. // #import diff --git a/NSShadow+MCAdditions.m b/NSShadow+MCAdditions.m index bfb15cc..ded44f0 100644 --- a/NSShadow+MCAdditions.m +++ b/NSShadow+MCAdditions.m @@ -2,7 +2,7 @@ // NSShadow+MCAdditions.m // // Created by Sean Patrick O'Brien on 4/3/08. -// Copyright 2008 MolokoCacao. All rights reserved. +// Copyright 2008 MolokoCacao. Written in 2010 by Fileability.. // #import "NSShadow+MCAdditions.h" diff --git a/NSString+Utilities.h b/NSString+Utilities.h index 7c7580e..e2d95bf 100644 --- a/NSString+Utilities.h +++ b/NSString+Utilities.h @@ -3,7 +3,7 @@ // Chocolat // // Created by Alex Gordon on 13/07/2009. -// Copyright 2009 Fileability. All rights reserved. +// Copyright 2009 Fileability. Written in 2010 by Fileability.. // #import diff --git a/NSString+Utilities.m b/NSString+Utilities.m index 5b08b00..467593d 100644 --- a/NSString+Utilities.m +++ b/NSString+Utilities.m @@ -3,7 +3,7 @@ // Chocolat // // Created by Alex Gordon on 13/07/2009. -// Copyright 2009 Fileability. All rights reserved. +// Copyright 2009 Fileability. Written in 2010 by Fileability.. // #import "NSString+Utilities.h" diff --git a/NSXMLNode+IGKAdditions.h b/NSXMLNode+IGKAdditions.h index 4c4722f..d1f5910 100644 --- a/NSXMLNode+IGKAdditions.h +++ b/NSXMLNode+IGKAdditions.h @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 05/03/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import diff --git a/NSXMLNode+IGKAdditions.m b/NSXMLNode+IGKAdditions.m index 977a7b2..689eb26 100644 --- a/NSXMLNode+IGKAdditions.m +++ b/NSXMLNode+IGKAdditions.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 05/03/2010. -// Copyright 2010 Fileability. All rights reserved. +// Written in 2010 by Fileability. // #import "NSXMLNode+IGKAdditions.h" diff --git a/RegexKitLite.h b/RegexKitLite.h index 920cb43..8691473 100644 --- a/RegexKitLite.h +++ b/RegexKitLite.h @@ -7,7 +7,7 @@ /* Copyright (c) 2008-2009, John Engelhart - All rights reserved. + Written in 2010 by Fileability.. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/RegexKitLite.m b/RegexKitLite.m index d8e4ba2..67a1138 100644 --- a/RegexKitLite.m +++ b/RegexKitLite.m @@ -7,7 +7,7 @@ /* Copyright (c) 2008-2009, John Engelhart - All rights reserved. + Written in 2010 by Fileability.. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/Remaining bugs.txt b/Remaining bugs.txt index 31518b4..58dd66d 100644 --- a/Remaining bugs.txt +++ b/Remaining bugs.txt @@ -1,5 +1,5 @@ -When typing in the right filter search field, the best match (selected by smartcmp) should be selected and the webview should scroll to its anchor The webview shouldn't scroll when resizing: Let x be the number of pixels to the nearest anchor, then x should be invariant when resizing. +Fullscreen then Find doesn't work Needs key combos for selecting the next and previous method in the webview Switch to smartcmp algorithm Implement frecency diff --git a/SQPreferencesBackgroundComponent.h b/SQPreferencesBackgroundComponent.h index 9a2b0ee..ccd7b81 100644 --- a/SQPreferencesBackgroundComponent.h +++ b/SQPreferencesBackgroundComponent.h @@ -3,7 +3,7 @@ // Squish // // Created by Alex Gordon on 09/04/2009. -// Copyright 2009 Fileability. All rights reserved. +// Copyright 2009 Fileability. Written in 2010 by Fileability.. // #import diff --git a/SQPreferencesBackgroundComponent.m b/SQPreferencesBackgroundComponent.m index ec785af..dedb3d5 100644 --- a/SQPreferencesBackgroundComponent.m +++ b/SQPreferencesBackgroundComponent.m @@ -3,7 +3,7 @@ // Squish // // Created by Alex Gordon on 09/04/2009. -// Copyright 2009 Fileability. All rights reserved. +// Copyright 2009 Fileability. Written in 2010 by Fileability.. // #import "SQPreferencesBackgroundComponent.h" diff --git a/XBNewSourceListCell.h b/XBNewSourceListCell.h index c06d068..992e5ce 100644 --- a/XBNewSourceListCell.h +++ b/XBNewSourceListCell.h @@ -3,7 +3,7 @@ // SourceList3 // // Created by Alex Gordon on 16/01/2009. -// Copyright 2009 Fileability. All rights reserved. +// Copyright 2009 Fileability. Written in 2010 by Fileability.. // #import diff --git a/XBNewSourceListCell.m b/XBNewSourceListCell.m index 09ee75b..3afc36e 100644 --- a/XBNewSourceListCell.m +++ b/XBNewSourceListCell.m @@ -3,7 +3,7 @@ // SourceList3 // // Created by Alex Gordon on 16/01/2009. -// Copyright 2009 Fileability. All rights reserved. +// Copyright 2009 Fileability. Written in 2010 by Fileability.. // #import "XBNewSourceListCell.h" diff --git a/main.m b/main.m index c7f4246..cd5e0d7 100644 --- a/main.m +++ b/main.m @@ -3,7 +3,7 @@ // Ingredients // // Created by Alex Gordon on 23/01/2010. -// Copyright Fileability 2010. All rights reserved. +// Copyright Fileability 2010. Written in 2010 by Fileability.. // #import diff --git a/smartcmp.h b/smartcmp.h index c93ca8c..813a36f 100644 --- a/smartcmp.h +++ b/smartcmp.h @@ -3,7 +3,7 @@ * Ingredients * * Created by Alex Gordon on 30/06/2010. - * Copyright 2010 __MyCompanyName__. All rights reserved. + * Written in 2010 by Fileability. * */ diff --git a/smartcmp.m b/smartcmp.m index 3000365..d2324fc 100644 --- a/smartcmp.m +++ b/smartcmp.m @@ -147,8 +147,22 @@ SmartCmpScore categoryScore(id resultObject) if ([resultObject respondsToSelector:@selector(priorityval)]) { SmartCmpScore maximumPriorityValue = (SmartCmpScore)(CHPriorityMaximum - 1); - score += ((SmartCmpScore)[resultObject priorityval]) / maximumPriorityValue; - } + score += (((SmartCmpScore)[resultObject priorityval]) / maximumPriorityValue); + } + + //Content length + //The hypothesis is that longer documentation articles are more important than shorter ones. More commonly used classes get expanded more and end up being longer + + //I'm commenting this out because, while it works in theory, we really need to get the maximum and minimum-nonzero content length and do a proper quotient to get good weighting + //This would solve the problem of constants, methods, etc having zero content lengths, which screws up their weighting + /* + if ([resultObject respondsToSelector:@selector(lengthOfContent)]) + { + SmartCmpScore x = (SmartCmpScore)[[resultObject lengthOfContent] doubleValue]; + score += 1.0 - 1.0 / log(x + M_E); + NSLog(@"content length score = %lf : '%@'", 1.0 - 1.0 / log(x + M_E), [resultObject valueForKey:@"name"]); + } + */ //Docsets //TODO: Record most used docsets and score appropriately @@ -174,7 +188,7 @@ SmartCmpScore smartcmpScore(NSString *query, NSString *lowercaseQuery, unichar + 0.75 * case_s + anchor_s + frecency_s - + 2.0 * category_s + + 1.5 * category_s ; //NSLog(@"d %lf, c %lf, a %lf, f %lfm k %lf; t %lf; '%@'", distance_s, case_s, anchor_s, frecency_s, category_s, s, result);