srchub

srchub Commit Details


Date:2016-03-05 21:32:34 (8 years 9 months ago)
Author:Natalie Adams
Branch:master
Commit:57641e1661a66c36a345c18342644ca1243dcca2
Parents: b8d6c17308cc60649e154e30118395fbc0bb8765
Message:Issue 133: Add lazy loading for images support

Changes:

File differences

.gitignore
1
.idea
indefero/src/IDF/Views/Project.php
3232
3333
3434
35
35
3636
3737
3838
......
5353
5454
5555
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
5675
5776
5877
class IDF_Views_Project
{
/**
* Home page of a project.
* Logo of a project.
*/
public $logo_precond = array('IDF_Precondition::baseAccess');
public function logo($request, $match)
}
/**
* Logo of a project.
*/
public $logo64_precond = array('IDF_Precondition::baseAccess');
public function logo64($request, $match)
{
$prj = $request->project;
$logo = $prj->getConf()->getVal('logo');
if (empty($logo)) {
$file = "./media/idf/img/no_logo.png";
$info = IDF_FileUtil::getMimeType($file);
return new Pluf_HTTP_Response("data:" . $info[0] . ";base64," . base64_encode(file_get_contents($file)), "text/text");
}
$info = IDF_FileUtil::getMimeType($logo);
return new Pluf_HTTP_Response("data:" . $info[0] . ";base64," . base64_encode(file_get_contents(Pluf::f('upload_path') . '/' . $prj->shortname . $logo)), "text/text");
}
/**
* Home page of a project.
*/
public $home_precond = array('IDF_Precondition::baseAccess');
indefero/src/IDF/conf/urls.php
9797
9898
9999
100
101
102
103
104
100105
101106
102107
103108
104109
110
111
105112
106113
107114
'model' => 'IDF_Views_Project',
'method' => 'home');
$ctl[] = array('regex' => '#^/p/([\-\w]+)/logo64/$#',
'base' => $base,
'model' => 'IDF_Views_Project',
'method' => 'logo64');
$ctl[] = array('regex' => '#^/p/([\-\w]+)/logo/$#',
'base' => $base,
'model' => 'IDF_Views_Project',
'method' => 'logo');
$ctl[] = array('regex' => '#^/p/([\-\w]+)/timeline/(\w+)/$#',
'base' => $base,
'model' => 'IDF_Views_Project',
indefero/src/IDF/templates/idf/base-full.html
3232
3333
3434
35
36
3537
3638
3739
3840
3941
40
42
4143
4244
4345
{block extraheader}{/block}
<title>{block pagetitle}{$page_title|strip_tags}{/block}{if $project} - {$project.shortdesc}{/if}</title>
<script type="text/javascript" src="{media '/idf/js/jquery-1.7.2.min.js'}"></script>
<script type="text/javascript" src="{media '/idf/js/logo.cache.js'}"></script>
{appversion}
</head>
<body>
<div id="{block docid}doc3{/block}">
<div id="hd">
{if $project}<h1 class="project-title">{$project}<img class="logo" src="{url 'IDF_Views_Project::logo', array($project.shortname)}" alt="{trans 'Project logo'}" />{if $project.private}<img class="lock" src="{media '/idf/img/lock.png'}" alt="{trans 'Private project'}" />{/if}{$p}{assign $url = $project.external_project_url}{if $url != ''}<a href="{$url}" target="_blank" class="external-link" title="{trans 'External link to project'}" />&nbsp;</a>{/if}</h1>{/if}
{if $project}<h1 class="project-title">{$project}<img class="logo" data-logo="{$project.logo}" data-original="{url 'IDF_Views_Project::logo', array($project.shortname)}" alt="{trans 'Project logo'}" />{if $project.private}<img class="lock" src="{media '/idf/img/lock.png'}" alt="{trans 'Private project'}" />{/if}{$p}{assign $url = $project.external_project_url}{if $url != ''}<a href="{$url}" target="_blank" class="external-link" title="{trans 'External link to project'}" />&nbsp;</a>{/if}</h1>{/if}
{include 'idf/main-menu.html'}
<div id="header">
<div id="main-tabs">
indefero/src/IDF/templates/idf/base-simple.html
3232
3333
3434
35
36
3537
3638
3739
{block extraheader}{/block}
<title>{block pagetitle}{$page_title|strip_tags}{/block}</title>
<script type="text/javascript" src="{media '/idf/js/jquery-1.7.2.min.js'}"></script>
<script type="text/javascript" src="{media '/idf/js/logo.cache.js'}"></script>
{appversion}
</head>
<body>
indefero/src/IDF/templates/idf/base.html
3636
3737
3838
39
3940
4041
4142
......
5253
5354
5455
56
57
5558
5659
5760
......
99102
100103
101104
102
105
103106
104107
105108
{block extraheader}{/block}
<title>{block pagetitle}{$page_title|strip_tags}{/block}{if $project} - {$project.shortdesc}{/if}</title>
<script type="text/javascript" src="{media '/idf/js/jquery-1.7.2.min.js'}"></script>
<script type="text/javascript" src="{media '/idf/js/logo.cache.js'}"></script>
<script type="text/javascript" src="{media '/idf/js/syntaxhighlight/shCore.js'}"></script>
<script type="text/javascript" src="{media '/idf/js/syntaxhighlight/shAutoloader.js'}"></script>
{literal}
<script type="text/javascript">
$.event.special.tripleclick = {
setup: function(data, namespaces) {
<div id="{block docid}doc3{/block}" class="{block docclass}yui-t3{/block}">
<div id="hd">
{if $project}
<h1 class="project-title">{$project}<img class="logo" src="{url 'IDF_Views_Project::logo', array($project.shortname)}" alt="{trans 'Project logo'}" />{if $project.private}<img class="lock" src="{media '/idf/img/lock.png'}" alt="{trans 'Private project'}" />{/if}{$p}{assign $url = $project.external_project_url}{if $url != ''}<a href="{$url}" target="_blank" class="external-link" title="{trans 'External link to project'}" />&nbsp;</a>{/if}</h1>{/if}
<h1 class="project-title">{$project}<img data-logo="{$project.logo}" class="logo" src="{url 'IDF_Views_Project::logo', array($project.shortname)}" alt="{trans 'Project logo'}" />{if $project.private}<img class="lock" src="{media '/idf/img/lock.png'}" alt="{trans 'Private project'}" />{/if}{$p}{assign $url = $project.external_project_url}{if $url != ''}<a href="{$url}" target="_blank" class="external-link" title="{trans 'External link to project'}" />&nbsp;</a>{/if}</h1>{/if}
{include 'idf/main-menu.html'}
<div id="header">
<div id="main-tabs">
indefero/src/IDF/templates/idf/main-menu.html
1515
1616
1717
18
18
1919
2020
2121
<ul class="prjlistclass">
<li id="searchkeep"><input size="15" type="text" id="prjname" name="prjname" placeholder="Project Name..." /></li>
{foreach $allProjects as $p}
<li class="projectitem"><a href="{url 'IDF_Views_Project::home', array($p.shortname)}"><img class="logo" src="{url 'IDF_Views_Project::logo', array($p.shortname)}" alt="{trans 'Project logo'}" />{if $p.private}<img class="lock" src="{media '/idf/img/lock.png'}" alt="{trans 'Private project'}" />{/if}{$p}</a></li>
<li class="projectitem"><a href="{url 'IDF_Views_Project::home', array($p.shortname)}"><img src="{media '/idf/img/no_logo.png'}" data-logo="{$p.logo}" class="logo" data-src="{url 'IDF_Views_Project::logo64', array($p.shortname)}" alt="{trans 'Project logo'}" />{if $p.private}<img class="lock" src="{media '/idf/img/lock.png'}" alt="{trans 'Private project'}" />{/if}{$p}</a></li>
{/foreach}</ul>
{/if}</li>{if $isAdmin}<li><a href="{url 'IDF_Views_Admin::forge'}">{trans 'Forge Management'}</a></li>{/if}<li>
<a href="{url 'IDF_Views::faq'}" title="{trans 'Help and accessibility features'}">{trans 'Help'}</a></li>
indefero/src/IDF/templates/idf/project-list.html
33
44
55
6
6
77
88
99
<div class="p-list-prj">
<div class="logo">
<a href="{url 'IDF_Views_Project::home', array($p.shortname)}">
<img src="{url 'IDF_Views_Project::logo', array($p.shortname)}" alt="{trans 'Project logo'}" />
<img src="{media '/idf/img/no_logo.png'}" data-logo="{$p.logo}" class="logo" data-src="{url 'IDF_Views_Project::logo', array($p.shortname)}" alt="{trans 'Project logo'}" />
</a>
{if $p.private}
<div class="private">
indefero/www/media/idf/js/logo.cache.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
$(function () {
var logoCache = {};
var waiting = 0;
function logoUpdate() {
if (waiting == 0) {
$(".logo").each(function () {
var self = $(this);
var logo = $(this).data("logo");
if (logo == "") {
logo = undefined;
}
self.attr("src", logoCache[logo]);
});
} else {
waiting -= 1;
}
}
$(".logo").each(function () {
var logoSrc = $(this).data("src");
var logo = $(this).data("logo");
var self = $(this);
if (!logoSrc) {
return;
}
if (logo == "") {
logo = undefined;
}
if (!(logo in logoCache)) {
logoCache[logo] = logoSrc;
}
});
waiting = Object.keys(logoCache).length - 1;
$.each(logoCache, function (index, element) {
$.ajax({
url: logoCache[index],
success: function(data) {
logoCache[index] = data;
logoUpdate();
},
async: true
});
});
});

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.07440s using 20 queries.