Hi user996015,
viewgit is pretty cool and there are already several forks.
Have you ever thought about better image handling? Many projects contain at least some images (logo, icons...).
Right now images are shown as utf8-encoded (binary) strings.
I've tested a little bit and think base64 encoded images are a quick solution.
In index.php within "elseif ($action === 'viewblob')" I added:
$ext = strtolower(pathinfo($page['path'], PATHINFO_EXTENSION));
$viewable = array('png', 'jpg', 'jpeg', 'gif', 'ico');
if (in_array($ext, $viewable)) {
$template = 'image';
$databin = run_git_string($page['project'], "cat-file blob $page[hash]");
$dataenc = base64_encode($databin);
$uri = 'data://application/octet-stream;base64,' . $dataenc;
$imginfo = getimagesize($uri);
$mime = $imginfo['mime'];
$dims = $imginfo[3];
$page['data'] = '<img ' . $dims . ' src="data:' . $mime . ';base64,' . $dataenc . '" />';
}
else {
$page['data'] = fix_encoding(join("\n", run_git($page['project'], "cat-file blob $page[hash]")));
}
In functions.php I added a function called run_git_string, which makes use of shell_exec() instead of exec() to get a string instead of a an array.
And I added a new template: templates/image.php
That template prints the image tag directly, without pre tags or geshi formatting.
What do you think?
Are you interested in this new feature? A patch?
Or is that kind of image handling too crude for you?
Cheers,
indigoxela
Hi user996015,
viewgit is pretty cool and there are already several forks.
Have you ever thought about better image handling? Many projects contain at least some images (logo, icons...).
Right now images are shown as utf8-encoded (binary) strings.
I've tested a little bit and think base64 encoded images are a quick solution.
In index.php within "elseif ($action === 'viewblob')" I added:
In functions.php I added a function called run_git_string, which makes use of shell_exec() instead of exec() to get a string instead of a an array.
And I added a new template: templates/image.php
That template prints the image tag directly, without pre tags or geshi formatting.
What do you think?
Are you interested in this new feature? A patch?
Or is that kind of image handling too crude for you?
Cheers,
indigoxela