diff --git a/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index f14ed1a..a024fa0 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -23,6 +23,7 @@ /* Begin PBXBuildFile section */ 056438B70ED0C40B00985397 /* DetailViewTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = 056438B60ED0C40B00985397 /* DetailViewTemplate.png */; }; 314E974611C17BB4007E9610 /* blame.css in Resources */ = {isa = PBXBuildFile; fileRef = 314E974511C17BB4007E9610 /* blame.css */; }; + 31D5F72511C21F7500BC94E4 /* shBrushObjC.js in Sources */ = {isa = PBXBuildFile; fileRef = 31D5F72411C21F7500BC94E4 /* shBrushObjC.js */; }; 31F8A73611C0CE5300517F78 /* index.html in Resources */ = {isa = PBXBuildFile; fileRef = 31F8A73511C0CE5300517F78 /* index.html */; }; 31F8A75411C0D0F800517F78 /* blame.js in Sources */ = {isa = PBXBuildFile; fileRef = 31F8A75311C0D0F800517F78 /* blame.js */; }; 3BC07F4C0ED5A5C5009A7768 /* HistoryViewTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = 3BC07F4A0ED5A5C5009A7768 /* HistoryViewTemplate.png */; }; @@ -265,6 +266,7 @@ 29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; 29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; 314E974511C17BB4007E9610 /* blame.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = blame.css; sourceTree = ""; }; + 31D5F72411C21F7500BC94E4 /* shBrushObjC.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = shBrushObjC.js; sourceTree = ""; }; 31F8A73511C0CE5300517F78 /* index.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = index.html; sourceTree = ""; }; 31F8A75311C0D0F800517F78 /* blame.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = blame.js; sourceTree = ""; }; 32CA4F630368D1EE00C91783 /* GitX_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GitX_Prefix.pch; sourceTree = ""; }; @@ -782,6 +784,7 @@ C3F4790811C1F0260020E7C1 /* shBrushXml.js */, C3F4790911C1F0260020E7C1 /* shCore.js */, C3F4790A11C1F0260020E7C1 /* shLegacy.js */, + 31D5F72411C21F7500BC94E4 /* shBrushObjC.js */, ); path = scripts; sourceTree = ""; @@ -1427,6 +1430,7 @@ C3F4793711C1F0260020E7C1 /* shLegacy.js in Sources */, C3F4793811C1F0260020E7C1 /* shCore.js in Sources */, C3F4793911C1F0260020E7C1 /* shLegacy.js in Sources */, + 31D5F72511C21F7500BC94E4 /* shBrushObjC.js in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/PBGitTree.m b/PBGitTree.m index 5c69a61..b4fc226 100644 --- a/PBGitTree.m +++ b/PBGitTree.m @@ -281,8 +281,6 @@ { string=[string stringByReplacingOccurrencesOfString:@"<" withString:@"<"]; string=[string stringByReplacingOccurrencesOfString:@">" withString:@">"]; - - NSString *codeLineFormat=@"\t%@
%@
\n"; NSArray *lines = [string componentsSeparatedByString:@"\n"]; NSString *line; @@ -312,12 +310,13 @@ } [res appendString:[headers objectForKey:[header objectAtIndex:0]]]; - [res appendString:@"\n"]; + NSMutableString *code=[NSMutableString string]; do{ line=[lines objectAtIndex:i++]; }while([line characterAtIndex:0]!='\t'); line=[line stringByReplacingOccurrencesOfString:@"\t" withString:@"    "]; - [res appendFormat:codeLineFormat,[header objectAtIndex:2],line]; + [code appendString:line]; + [code appendString:@"\n"]; int n; for(n=1;n\n\n"]; + [res appendFormat:@"
%@
",[header objectAtIndex:2],code]; + [res appendString:@"\n"]; }else{ break; } [res appendString:@"\n"]; } [res appendString:@"
\n"]; - NSLog(res); + NSLog(@"%@",res); return (NSString *)res; } diff --git a/html/lib/syntaxhighlighter_2.1.364/styles/shCore.css b/html/lib/syntaxhighlighter_2.1.364/styles/shCore.css index a513aaa..415ab48 100644 --- a/html/lib/syntaxhighlighter_2.1.364/styles/shCore.css +++ b/html/lib/syntaxhighlighter_2.1.364/styles/shCore.css @@ -51,10 +51,10 @@ height: auto !important; width: auto !important; line-height: 1.1em !important; - font-family: "Consolas", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; + -font-family: "Consolas", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: normal !important; font-style: normal !important; - font-size: 1em !important; + -font-size: 1em !important; min-height: inherit !important; /* For IE8, FF & WebKit */ min-height: auto !important; /* For IE7 */ } @@ -62,7 +62,7 @@ .syntaxhighlighter { width: 99% !important; /* 99% fixes IE8 horizontal scrollbar */ - margin: 1em 0 1em 0 !important; + margin: 0 !important; padding: 1px !important; /* adds a little border on top and bottom */ position: relative !important; } diff --git a/html/views/blame/blame.css b/html/views/blame/blame.css index c180553..a020e8a 100644 --- a/html/views/blame/blame.css +++ b/html/views/blame/blame.css @@ -3,7 +3,7 @@ table { border-spacing: 0; } -th, td { +body,th, td { margin: 0; padding: 0; border: 0; @@ -18,38 +18,29 @@ p{ padding: 0; } +tr.block.l2 p.summary, +tr.block.l3 p.summary, tr.block.l1 p.summary{ display: none; } -table td { +table.blocks td { vertical-align: top; - white-space: nowrap; } -table { - font: 11px "Menlo"; +p.author { + white-space: nowrap; } -table.code td:nth-of-type(2) { - width: 100%; - padding-right: 5px; - padding-left: 5px; +table.blocks { + font: 11px "Menlo" !important; } -table.code td:nth-of-type(1) { - text-align: right; - border-right: 1px solid black; - padding-right: 5px; - padding-left: 5px; - background-color: #f3f3f3; -} table tr.block{ - border-top: 1px solid black; + border-top: 1px solid #c9c9c9; } table.blocks{ - border-left: 1px solid black; - border-bottom: 1px solid black; + border-bottom: 1px solid #c9c9c9; width: 100%; } @@ -57,17 +48,6 @@ table.blocks tr td:nth-of-type(2) { width: 100%; } --table.blocks tr.block:nth-of-type(even) td:nth-of-type(1), --table.code tr:nth-of-type(even) td:nth-of-type(2) { - background-color: #efefff; -} - -table.code { - border-left: 1px solid black; - border-right: 1px solid black; - width: 100%; -} - table.blocks tr.block td:nth-of-type(1){ padding-right: 5px; padding-left: 5px; diff --git a/html/views/blame/blame.js b/html/views/blame/blame.js index 5f76db1..a89326b 100644 --- a/html/views/blame/blame.js +++ b/html/views/blame/blame.js @@ -1,6 +1,9 @@ var showFile = function(txt) { $("txt").style.display = ""; $("txt").innerHTML="
"+txt+"
"; + + SyntaxHighlighter.defaults['toolbar'] = false; + SyntaxHighlighter.highlight(); return; } diff --git a/html/views/blame/index copy.html b/html/views/blame/index copy.html index 4f2ef86..af371b6 100644 --- a/html/views/blame/index copy.html +++ b/html/views/blame/index copy.html @@ -8,34 +8,719 @@ - + + - - + + +
    //
+    //  PBGitTree.m
+    //  GitTest
+    //
+    //  Created by Pieter de Bie on 15-06-08.
+    //  Copyright 2008 __MyCompanyName__. All rights reserved.
+    //
+    
+    #import "PBGitTree.h"
+    #import "PBGitCommit.h"
+    #import "NSFileHandleExt.h"
+
-

author Pieter de Bie

summary Add a search field and subject

author Pieter de Bie

summary Add a Tree displayer

- - - - - - - - - - - - - - - - - - - - - -
1
    /*
2
     *  Extension for NSFileHandle to make it capable of easy network programming
3
     *
4
     *  Version 1.0, get the newest from http://michael.stapelberg.de/NSFileHandleExt.php
5
     *
6
     *  Copyright 2007 Michael Stapelberg
7
     *
8
     *  Distributed under BSD-License, see http://michael.stapelberg.de/BSD.php
9
     *
10
     */
11
    
12
    #import <Cocoa/Cocoa.h>
13
    #include <netinet/in.h>
14
    #include <arpa/inet.h>
15
    #include <netdb.h>
16
    #include <fcntl.h>
17
    
18
    @interface NSFileHandle(NSFileHandleExt)
19
    -(NSString*)readLine;
20
    @end
-
+ +

author Pieter de Bie

summary Allow double click to open file

+ +
    #import "PBEasyPipe.h"
+
+ + +

author Pieter de Bie

summary Delete temporary files when they are deallocated

+ +
    #import "PBEasyFS.h"
+
+ + +

author Pieter de Bie

summary Add a Tree displayer

+ +
    
+    @implementation PBGitTree
+    
+    @synthesize sha, path, repository, leaf, parent;
+    
+    + (PBGitTree*) rootForCommit:(id) commit
+    {
+
+ + +

author Pieter de Bie

summary Add a Tree displayer

+ +
        PBGitCommit* c = commit;
+        PBGitTree* tree = [[self alloc] init];
+        tree.parent = nil;
+        tree.leaf = NO;
+
+ + +

author Pieter de Bie

summary Include libgit2 as submodule and use it to store sha's

+ +
        tree.sha = [c realSha];
+
+ + +

author Pieter de Bie

summary Add a Tree displayer

+ +
        tree.repository = c.repository;
+        tree.path = @"";
+        return tree;
+    }
+    
+    + (PBGitTree*) treeForTree: (PBGitTree*) prev andPath: (NSString*) path;
+    {
+        PBGitTree* tree = [[self alloc] init];
+        tree.parent = prev;
+        tree.sha = prev.sha;
+        tree.repository = prev.repository;
+        tree.path = path;
+        return tree;
+    }
+    
+    - init
+    {
+        children = nil;
+
+ + +

author Pieter de Bie

summary Delete temporary files when they are deallocated

+ +
        localFileName = nil;
+
+ + +

author Pieter de Bie

summary Add a Tree displayer

+ +
        leaf = YES;
+        return self;
+    }
+    
+
+ + +

author Pieter de Bie

summary Use unified interface and display tree contents

+ +
    - (NSString*) refSpec
+    {
+        return [NSString stringWithFormat:@"%@:%@", self.sha, self.fullPath];
+    }
+    
+
+ + +

author Pieter de Bie

summary Delete temporary files when they are deallocated

+ +
    - (BOOL) isLocallyCached
+    {
+        NSFileManager* fs = [NSFileManager defaultManager];
+        if (localFileName && [fs fileExistsAtPath:localFileName])
+        {
+            NSDate* mtime = [[fs attributesOfItemAtPath:localFileName error: nil] objectForKey:NSFileModificationDate];
+            if ([mtime compare:localMtime] == 0)
+                return YES;
+        }
+        return NO;
+    }
+    
+
+ + +

author Johannes Gilger

summary PBGitTree: Improve binary-file decision

+ +
    - (BOOL)hasBinaryHeader:(NSString*)contents
+
+ + +

author Johannes Gilger

summary PBGitTree: Don't try to print binary-file contents

+ +
    {
+
+ + +

author Johannes Gilger

summary PBGitTree: Improve binary-file decision

+ +
        if(!contents)
+
+ + +

author Johannes Gilger

summary PBGitTree: Don't try to print binary-file contents

+ +
            return NO;
+    
+
+ + +

author Johannes Gilger

summary PBGitTree: Improve binary-file decision

+ +
        return [contents rangeOfString:@"\0" options:0 range:NSMakeRange(0, ([contents length] >= 8000) ? 7999 : [contents length])].location != NSNotFound;
+
+ + +

author Johannes Gilger

summary PBGitTree: Don't try to print binary-file contents

+ +
    }
+    
+    - (BOOL)hasBinaryAttributes
+    {
+        // First ask git check-attr if the file has a binary attribute custom set
+        NSFileHandle *handle = [repository handleInWorkDirForArguments:[NSArray arrayWithObjects:@"check-attr", @"binary", [self fullPath], nil]];
+        NSData *data = [handle readDataToEndOfFile];
+        NSString *string = [[NSString alloc] initWithData:data encoding:NSISOLatin1StringEncoding];
+    
+        if (!string)
+            return NO;
+        string = [string stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];
+    
+        if ([string hasSuffix:@"binary: set"])
+            return YES;
+    
+        if ([string hasSuffix:@"binary: unset"])
+            return NO;
+    
+        // Binary state unknown, do a check on common filename-extensions
+        for (NSString *extension in [NSArray arrayWithObjects:@".pdf", @".jpg", @".jpeg", @".png", @".bmp", @".gif", @".o", nil]) {
+            if ([[self fullPath] hasSuffix:extension])
+                return YES;
+        }
+    
+        return NO;
+    }
+    
+
+ + +

author Pieter de Bie

summary Use unified interface and display tree contents

+ +
    - (NSString*) contents
+    {
+        if (!leaf)
+
+ + +

author dbr

summary When selecting a folder in tree-view, display the

+ +
            return [NSString stringWithFormat:@"This is a tree with path %@", [self fullPath]];
+
+ + +

author German Laullon

summary initial blame functionality on tree view

+ +
        
+
+ + +

author Johannes Gilger

summary PBGitTree: Don't try to print binary-file contents

+ +
        if ([self isLocallyCached]) {
+            NSData *data = [NSData dataWithContentsOfFile:localFileName];
+            NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
+            if (!string)
+                string = [[NSString alloc] initWithData:data encoding:NSISOLatin1StringEncoding];
+            return string;
+
+ + +

author Pieter de Bie

summary Delete temporary files when they are deallocated

+ +
        }
+        
+
+ + +

author German Laullon

summary initial blame functionality on tree view

+ +
        //return [repository outputForArguments:[NSArray arrayWithObjects:@"show", [self refSpec], nil]];
+        return [repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"blame", self.path, nil]];
+    }
+    
+
+ + +

author German Laullon

summary HTML Blame

+ +
    // XXX: create img tag for images.
+
+ + +

author German Laullon

summary initial blame functionality on tree view

+ +
    - (NSString*) contents:(NSInteger)option
+    {
+
+ + +

author German Laullon

summary HTML Blame

+ +
        NSString* contents;
+    
+
+ + +

author German Laullon

summary initial blame functionality on tree view

+ +
        if (!leaf)
+            return [NSString stringWithFormat:@"This is a tree with path %@", [self fullPath]];
+        
+
+ + +

author German Laullon

summary HTML Blame

+ +
        if ([self hasBinaryAttributes])
+            return [NSString stringWithFormat:@"%@ appears to be a binary file of %d bytes", [self fullPath], [self fileSize]];
+        
+        if ([self fileSize] > 52428800) // ~50MB
+            return [NSString stringWithFormat:@"%@ is too big to be displayed (%d bytes)", [self fullPath], [self fileSize]];
+        
+
+ + +

author German Laullon

summary initial blame functionality on tree view

+ +
        if(option==0)
+
+ + +

author German Laullon

summary HTML Blame

+ +
            contents= [repository outputForArguments:[NSArray arrayWithObjects:@"show", [self refSpec], nil]];
+
+ + +

author German Laullon

summary initial blame functionality on tree view

+ +
        else
+
+ + +

author German Laullon

summary HTML Blame

+ +
            contents=[PBGitTree parseBlame:[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"blame", @"-p", self.fullPath, nil]]];
+        
+        if ([self hasBinaryHeader:contents])
+            return [NSString stringWithFormat:@"%@ appears to be a binary file of %d bytes", [self fullPath], [self fileSize]];
+        
+        return contents;
+
+ + +

author Johannes Gilger

summary PBGitTree: Don't try to print binary-file contents

+ +
    }
+    
+    - (long long)fileSize
+    {
+        if (_fileSize)
+            return _fileSize;
+    
+        NSFileHandle *handle = [repository handleForArguments:[NSArray arrayWithObjects:@"cat-file", @"-s", [self refSpec], nil]];
+        NSString *sizeString = [[NSString alloc] initWithData:[handle readDataToEndOfFile] encoding:NSISOLatin1StringEncoding];
+    
+        if (!sizeString)
+            _fileSize = -1;
+        else
+            _fileSize = [sizeString longLongValue];
+    
+        return _fileSize;
+    }
+    
+    - (NSString *)textContents
+    {
+        if (!leaf)
+            return [NSString stringWithFormat:@"This is a tree with path %@", [self fullPath]];
+    
+        if ([self hasBinaryAttributes])
+            return [NSString stringWithFormat:@"%@ appears to be a binary file of %d bytes", [self fullPath], [self fileSize]];
+    
+
+ + +

author Johannes Gilger

summary PBGitTree: Improve binary-file decision

+ +
        if ([self fileSize] > 52428800) // ~50MB
+            return [NSString stringWithFormat:@"%@ is too big to be displayed (%d bytes)", [self fullPath], [self fileSize]];
+
+ + +

author Johannes Gilger

summary PBGitTree: Don't try to print binary-file contents

+ +
    
+
+ + +

author Johannes Gilger

summary PBGitTree: Improve binary-file decision

+ +
        NSString* contents = [self contents];
+
+ + +

author Johannes Gilger

summary PBGitTree: Don't try to print binary-file contents

+ +
    
+
+ + +

author Johannes Gilger

summary PBGitTree: Improve binary-file decision

+ +
        if ([self hasBinaryHeader:contents])
+            return [NSString stringWithFormat:@"%@ appears to be a binary file of %d bytes", [self fullPath], [self fileSize]];
+
+ + +

author Johannes Gilger

summary PBGitTree: Don't try to print binary-file contents

+ +
    
+        return contents;
+
+ + +

author Pieter de Bie

summary Use unified interface and display tree contents

+ +
    }
+    
+
+ + +

author Pieter de Bie

summary Delete temporary files when they are deallocated

+ +
    - (void) saveToFolder: (NSString *) dir
+    {
+        NSString* newName = [dir stringByAppendingPathComponent:path];
+    
+        if (leaf) {
+            NSFileHandle* handle = [repository handleForArguments:[NSArray arrayWithObjects:@"show", [self refSpec], nil]];
+            NSData* data = [handle readDataToEndOfFile];
+            [data writeToFile:newName atomically:YES];
+        } else { // Directory
+            [[NSFileManager defaultManager] createDirectoryAtPath:newName attributes:nil];
+
+ + +

author Michael Stephens

summary Fix saving tree to folder

+ +
            for (PBGitTree* child in [self children])
+
+ + +

author Pieter de Bie

summary Delete temporary files when they are deallocated

+ +
                [child saveToFolder: newName];
+        }
+    }
+    
+    - (NSString*) tmpDirWithContents
+    {
+        if (leaf)
+            return nil;
+    
+        if (!localFileName)
+            localFileName = [PBEasyFS tmpDirWithPrefix: path];
+    
+
+ + +

author Pieter de Bie

summary Delete temporary files when they are deallocated

+ +
        for (PBGitTree* child in [self children]) {
+
+ + +

author Pieter de Bie

summary Delete temporary files when they are deallocated

+ +
            [child saveToFolder: localFileName];
+        }
+        
+        return localFileName;
+    }
+    
+        
+    
+
+ + +

author Pieter de Bie

summary Allow double click to open file

+ +
    - (NSString*) tmpFileNameForContents
+    {
+        if (!leaf)
+
+ + +

author Pieter de Bie

summary Delete temporary files when they are deallocated

+ +
            return [self tmpDirWithContents];
+        
+        if ([self isLocallyCached])
+            return localFileName;
+        
+        if (!localFileName)
+
+ + +

author Ciar‡n Walsh

summary Prevent confusing filenames when quick-looking files.

+ +
            localFileName = [[PBEasyFS tmpDirWithPrefix: sha] stringByAppendingPathComponent:path];
+
+ + +

author Pieter de Bie

summary Delete temporary files when they are deallocated

+ +
        
+
+ + +

author Pieter de Bie

summary Allow double click to open file

+ +
        NSFileHandle* handle = [repository handleForArguments:[NSArray arrayWithObjects:@"show", [self refSpec], nil]];
+        NSData* data = [handle readDataToEndOfFile];
+
+ + +

author Pieter de Bie

summary Delete temporary files when they are deallocated

+ +
        [data writeToFile:localFileName atomically:YES];
+        
+        NSFileManager* fs = [NSFileManager defaultManager];
+        localMtime = [[fs attributesOfItemAtPath:localFileName error: nil] objectForKey:NSFileModificationDate];
+    
+        return localFileName;
+
+ + +

author Pieter de Bie

summary Allow double click to open file

+ +
    }
+    
+
+ + +

author Pieter de Bie

summary Add a Tree displayer

+ +
    - (NSArray*) children
+    {
+
+ + +

author Pieter de Bie

summary Use unified interface and display tree contents

+ +
        if (children != nil)
+
+ + +

author Pieter de Bie

summary Add a Tree displayer

+ +
            return children;
+        
+
+ + +

author Pieter de Bie

summary Use unified interface and display tree contents

+ +
        NSString* ref = [self refSpec];
+
+ + +

author Pieter de Bie

summary Add a Tree displayer

+ +
    
+        NSFileHandle* handle = [repository handleForArguments:[NSArray arrayWithObjects:@"show", ref, nil]];
+        [handle readLine];
+        [handle readLine];
+        
+        NSMutableArray* c = [NSMutableArray array];
+        
+        NSString* p = [handle readLine];
+        while (p.length > 0) {
+
+ + +

author Nathan Kinsinger

summary Bugfix: Avoid looping while parsing the children of a tree

+ +
            if ([p isEqualToString:@"\r"])
+                break;
+    
+
+ + +

author Pieter de Bie

summary Add a Tree displayer

+ +
            BOOL isLeaf = ([p characterAtIndex:p.length - 1] != '/');
+            if (!isLeaf)
+                p = [p substringToIndex:p.length -1];
+    
+            PBGitTree* child = [PBGitTree treeForTree:self andPath:p];
+            child.leaf = isLeaf;
+            [c addObject: child];
+            
+            p = [handle readLine];
+        }
+        children = c;
+        return c;
+    }
+    
+    - (NSString*) fullPath
+    {
+        if (!parent)
+            return @"";
+        
+        if ([parent.fullPath isEqualToString:@""])
+            return self.path;
+        
+        return [parent.fullPath stringByAppendingPathComponent: self.path];
+    }
+    
+
+ + +

author Pieter de Bie

summary Delete temporary files when they are deallocated

+ +
    - (void) finalize
+    {
+        if (localFileName)
+            [[NSFileManager defaultManager] removeFileAtPath:localFileName handler:nil];
+        [super finalize];
+    }
+
+ + +

author German Laullon

summary HTML Blame

+ +
    
+    +(NSString *)parseBlame:(NSString *)string
+    {
+        string=[string stringByReplacingOccurrencesOfString:@"<" withString:@"<"];
+        string=[string stringByReplacingOccurrencesOfString:@">" withString:@">"];
+
+ + +

author German Laullon

summary HTML Blame

+ +
        
+        NSArray *lines = [string componentsSeparatedByString:@"\n"];
+        NSString *line;
+        NSMutableDictionary *headers=[NSMutableDictionary dictionary];
+        NSMutableString *res=[NSMutableString string];
+        
+        [res appendString:@"<table class='blocks'>\n"];
+        int i=0;
+        while(i<[lines count]){
+            line=[lines objectAtIndex:i];
+            NSArray *header=[line componentsSeparatedByString:@" "];
+            if([header count]==4){
+                int nLines=[(NSString *)[header objectAtIndex:3] intValue];
+                [res appendFormat:@"<tr class='block l%d'>\n",nLines];
+                line=[lines objectAtIndex:++i];
+                if([[[line componentsSeparatedByString:@" "] objectAtIndex:0] isEqual:@"author"]){
+                    NSString *author=line;
+                    NSString *summary=nil;
+                    while(summary==nil){
+                        line=[lines objectAtIndex:i++];
+                        if([[[line componentsSeparatedByString:@" "] objectAtIndex:0] isEqual:@"summary"]){
+                            summary=line;
+                        }
+                    }
+                    NSString *block=[NSString stringWithFormat:@"<td><p class='author'>%@</p><p class='summary'>%@</p></td>\n<td>\n",author,summary];
+                    [headers setObject:block forKey:[header objectAtIndex:0]];
+                }
+                [res appendString:[headers objectForKey:[header objectAtIndex:0]]];
+                
+
+ + +

author Not Committed Yet

summary Version of PBGitTree.m from PBGitTree.m

+ +
                NSMutableString *code=[NSMutableString string];
+
+ + +

author German Laullon

summary HTML Blame

+ +
                do{
+                    line=[lines objectAtIndex:i++];
+                }while([line characterAtIndex:0]!='\t');
+                line=[line stringByReplacingOccurrencesOfString:@"\t" withString:@"    "];
+
+ + +

author Not Committed Yet

summary Version of PBGitTree.m from PBGitTree.m

+ +
                [code appendString:line];
+                [code appendString:@"\n"];
+
+ + +

author German Laullon

summary HTML Blame

+ +
                
+                int n;
+                for(n=1;n<nLines;n++){
+                    line=[lines objectAtIndex:i++];
+                    NSArray *h=[line componentsSeparatedByString:@" "];
+                    do{
+                        line=[lines objectAtIndex:i++];
+                    }while([line characterAtIndex:0]!='\t');
+                    line=[line stringByReplacingOccurrencesOfString:@"\t" withString:@"    "];
+
+ + +

author Not Committed Yet

summary Version of PBGitTree.m from PBGitTree.m

+ +
                    [code appendString:line];
+                    [code appendString:@"\n"];
+
+ + +

author German Laullon

summary HTML Blame

+ +
                }
+
+ + +

author Not Committed Yet

summary Version of PBGitTree.m from PBGitTree.m

+ +
                [res appendFormat:@"<pre class='first-line: %@;brush: js'>%@</pre>",[header objectAtIndex:2],code];
+                [res appendString:@"</td>\n"];
+
+ + +

author German Laullon

summary HTML Blame

+ +
            }else{
+                break;
+            }
+            [res appendString:@"</tr>\n"];
+        }  
+        [res appendString:@"</table>\n"];
+
+ + +

author Not Committed Yet

summary Version of PBGitTree.m from PBGitTree.m

+ +
        NSLog(@"%@",res);
+
+ + +

author German Laullon

summary HTML Blame

+ +
    
+        return (NSString *)res;
+    }
+
+ + +

author Pieter de Bie

summary Add a Tree displayer

+ +
    @end
+
+ + + + \ No newline at end of file diff --git a/html/views/blame/index.html b/html/views/blame/index.html index 6d79f18..8be6a6f 100644 --- a/html/views/blame/index.html +++ b/html/views/blame/index.html @@ -2,7 +2,7 @@ - +