⌈⌋ ⎇ branch:  freshcode


Check-in [74d0a47681]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Split out some templates/ from projects/ description.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 74d0a47681b1af640f0d3c3c313ca8b033cf5f87
User & Date: mario 2014-07-11 01:27:31
Context
2014-07-11
01:28
Move preg_replace_callbacks into methods check-in: e3b0b4a94d user: mario tags: trunk
01:27
Split out some templates/ from projects/ description. check-in: 74d0a47681 user: mario tags: trunk
01:26
Workaround [END] for Apache 2.2 check-in: c6f6993121 user: mario tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to freshcode.css.

1
2
3
4
5
6
7
8
9
10
11
12
13
/**
 * api: css
 * type: stylesheet
 * title: freshcode.club layout+style
 * description: Simulates the late freecode.com layout and looks; well mostly.
 * version: 0.5.5
 *
 * Centered two-pane layout. The #main section is usually 33% of the screen width,
 * while the #sidebar floats at the right. They're repositioned only using padding:
 * to the outer html,body{}.
 *
 */






|







1
2
3
4
5
6
7
8
9
10
11
12
13
/**
 * api: css
 * type: stylesheet
 * title: freshcode.club layout+style
 * description: Simulates the late freecode.com layout and looks; well mostly.
 * version: 0.5.6
 *
 * Centered two-pane layout. The #main section is usually 33% of the screen width,
 * while the #sidebar floats at the right. They're repositioned only using padding:
 * to the outer html,body{}.
 *
 */

39
40
41
42
43
44
45





46


47
48
49
50
51
52
53
h5 { font-size: 11pt; }
a[href=""] {
    opacity: 0.20;
}
input, textarea, select {
    font-size: 107%;
}









/**
 * Page header, info bar and logo box
 *
 */
#topbar {
    background: #555599;







>
>
>
>
>
|
>
>







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
h5 { font-size: 11pt; }
a[href=""] {
    opacity: 0.20;
}
input, textarea, select {
    font-size: 107%;
}
code, var, kbd {
    background: linear-gradient(90deg,#fafafa,#fafaff);
    box-shadow: 0 0 3px 2px #ccf;
    border-radius: 3px;
    margin: 1px;
}
var { box-shadow: 0 0 3px 2px #fdd; }
kbd { box-shadow: 0 0 3px 2px #dfd; }

/**
 * Page header, info bar and logo box
 *
 */
#topbar {
    background: #555599;
308
309
310
311
312
313
314
315
316
317
318
319
320
321




322
323
324
325
326
327
328
    height: 5.55em;
    overflow: hidden;
}

/**
 * Variation for /projects/xyz detail view.
 */
#main .project .long-tags span {
    border: 1px solid #ddd;
    background: #eee;
    padding: 1pt 8pt;
    border-radius: 4pt;
    margin-right: 30pt;
    font-size: 80%;




}
#main .project .long-tags a {
    padding: 2pt 5pt;
}
#main .project .long-links a, #sidebar section .long-links {
    border: 1px solid #79f;
    background: #47d;







|


|

<

>
>
>
>







315
316
317
318
319
320
321
322
323
324
325
326

327
328
329
330
331
332
333
334
335
336
337
338
    height: 5.55em;
    overflow: hidden;
}

/**
 * Variation for /projects/xyz detail view.
 */
#main .project .long-tags th {
    border: 1px solid #ddd;
    background: #eee;
    padding: 1pt 12pt;
    border-radius: 4pt;

    font-size: 80%;
    text-align: right;
}
#main .project .long-tags {
    border-spacing: 5pt;
}
#main .project .long-tags a {
    padding: 2pt 5pt;
}
#main .project .long-links a, #sidebar section .long-links {
    border: 1px solid #79f;
    background: #47d;

Changes to page_projects.php.

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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
/**
 * type: page
 * title: Project detail view
 * description: List project entry with all URLs and releases
 * license: AGPL
 * version 0.3
 * 
 * Shows:
 *   → General project description
 *   → Sidebar with project links, submitter, management links, social share count
 *   → Release history and changelogs
 * Adds:
 *   → RSS/Atom links to header template
 *
 */

// current project id
$name = $_REQUEST->proj_name["name"];


// inject RSS/Atom links
$header_add = "<link rel=alternate type=application/rss+xml href=/feed/$name.rss>\n"
            . "<link rel=alternate type=application/atom+xml href=/feed/$name.atom>\n"
            . "<link rel=alternate type=json/vnd.freshcode.club href=/feed/$name.json>";
include("template/header.php");



// fetch most current project/release entry
$releases = db("
    SELECT *
      FROM release_versions
     WHERE name = ?
       AND NOT deleted
     LIMIT 1
", $name);

// show
if ($entry = $releases->fetch()) {

    prepare_output($entry);   // HTML preparation and some auto-generated fields
    $_ = "trim";    // callback for varexpression function calls in heredoc
    
    // Output
    print <<<SIDEBAR
      <aside id=sidebar>
         <section>
           <h5>Links</h5>
           <a href="$entry[homepage]"><img src="img/home.png" width=11 height=11> Project Website</a><br>
           <a href="$entry[download]"><img src="img/disk.png" width=11 height=11> Download</a><br>
           {$_(proj_links($entry["urls"], $entry))} 
         </section>

         <section>
           <h5>Submitted by</h5>
           <a class=submitter href="/?user=$entry[submitter]">$entry[submitter_img]$entry[submitter]</a><br>
         </section>

         <section style="font-size:90%">
           <h5>Manage</h5>
         You can also help out here by:<br>
         <a class=long-links href="/submit/$entry[name]" style="display:inline-block; margin: 3pt 1pt;">&larr; Updating infos</a><br>
         or <a href="/flag/$entry[name]">flagging</a> this entry for moderator attention.
         </section>

         <section style="font-size:90%">
           <h5>Share project {$_(social_share_count($entry["social_links"]))}</h5>
           {$_(social_share_links($entry["name"], $entry["homepage"]))}
         </section>
      </aside>
      <section id=main>
SIDEBAR;
      
    // Output
    print <<<PROJECT
      <article class=project>
        <h3>
            <a href="projects/$entry[name]">$entry[title]
            <em class=version>$entry[version]</em></a>
        </h3>
        <a href="$entry[homepage]"><img class=preview src="$entry[image]" align=right width=120 height=90 border=0></a>
        <p class=description style="border:0">$entry[description]</p>
        <p class=long-tags><span>Tags</span> {$_(wrap_tags($entry["tags"]))}</p>
        <p class=long-tags><span>License</span> <a class=license>$entry[license]</a></p>
        <p class=long-links>
            <a href="$entry[homepage]"><img src="img/home.png" width=20 height=20 border=0 align=middle> Homepage</a>
            <a href="$entry[download]"><img src="img/disk.png" width=20 height=20 border=0 align=middle> Download</a>
        </p>
      </article>
PROJECT;

}


// retrieve all released versions
$releases = db("
    SELECT *, MAX(t_changed)
      FROM release
     WHERE name = ?
       AND flag < 5
       AND NOT deleted
  GROUP BY version
  ORDER BY t_published DESC, t_changed DESC
", $name);


// show
?> <article class=release-list>  <h3>Recent Releases</h3> <?php
while ($entry = $releases->fetch()) {
    prepare_output($entry);
    
    // output
    print <<<VERSION_ENTRY
       <div class=release-entry>
          <span class=version>$entry[version]</span><span class=published_date>{$_(strftime("%d %b %Y %H:%M", $entry["t_published"]))}</span>
          <span class=release-notes>
             <b>$entry[scope]:</b>
             $entry[changes]
          </span>
       </div>
VERSION_ENTRY;

}
?> </article> <?php


// html tail
include("template/bottom.php");



/**
 * Convert "url1=, url2=, url3=" list into titled hyperlinks.
 *
 */
function proj_links($urls, $entry, $r="") {
    foreach (p_key_value($urls) as $title=>$url) {
        $title = ucwords($title);
        $url = versioned_url($url, $entry["version"]);
        $r .= "&rarr; <a href=\"$url\">$title</a><br>\n";
    }
    return $r;
}


?>






|










|


>
|






>
|








|

|
<
<
<

<
<
<
<
<
<
<
<
|
<
<
<
<
|
<
<
<
<
<
<
|
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|


|










<
<


<

|
<
<
<
<
<
|
<
<
<
|









<
<
<
<
<
<
<
<
<
<
<
<
<
<

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

















47
48
49
50
51
52
53
54
55
56
57
58
59
60
61


62
63

64
65





66



67
68
69
70
71
72
73
74
75
76














77
<?php
/**
 * type: page
 * title: Project detail view
 * description: List project entry with all URLs and releases
 * license: AGPL
 * version 0.4
 * 
 * Shows:
 *   → General project description
 *   → Sidebar with project links, submitter, management links, social share count
 *   → Release history and changelogs
 * Adds:
 *   → RSS/Atom links to header template
 *
 */

// Current project id
$name = $_REQUEST->proj_name["name"];


// HTML header with injected RSS/Atom links
$header_add = "<link rel=alternate type=application/rss+xml href=/feed/$name.rss>\n"
            . "<link rel=alternate type=application/atom+xml href=/feed/$name.atom>\n"
            . "<link rel=alternate type=json/vnd.freshcode.club href=/feed/$name.json>";
include("template/header.php");



#-- Fetch most current project/release entry
$releases = db("
    SELECT *
      FROM release_versions
     WHERE name = ?
       AND NOT deleted
     LIMIT 1
", $name);

// Show sidebar + long project description
if ($entry = $releases->fetch()) {
    



    // Output








    prepare_output($entry);




    $_ = "trim";






    include("template/projects_sidebar.php");







    include("template/projects_description.php");

















}



#-- Retrieve all released versions
$releases = db("
    SELECT *, MAX(t_changed)
      FROM release
     WHERE name = ?
       AND flag < 5
       AND NOT deleted
  GROUP BY version
  ORDER BY t_published DESC, t_changed DESC
", $name);



?> <article class=release-list>  <h3>Recent Releases</h3> <?php
while ($entry = $releases->fetch()) {

    
    // Output





    prepare_output($entry);



    include("template/projects_release_entry.php");
}
?> </article> <?php


// html tail
include("template/bottom.php");

















?>

Changes to template/header.php.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<!DOCTYPE html>
<html>
<head> 
    <title>freshcode.club</title>
    <meta name=version content=0.4.5>
    <meta charset=UTF-8>
    <link rel=stylesheet href="/freshcode.css?0.5.3">
    <link rel="shortcut icon" href="/img/changes.png">
    <base href="http://<?= HTTP_HOST ?>/">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script>
       $(function(){
          $(".project .trimmed").one("click", function(){  
              $(this).animate({"max-height": "20em"});






|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
<!DOCTYPE html>
<html>
<head> 
    <title>freshcode.club</title>
    <meta name=version content=0.4.5>
    <meta charset=UTF-8>
    <link rel=stylesheet href="/freshcode.css?0.5.6">
    <link rel="shortcut icon" href="/img/changes.png">
    <base href="http://<?= HTTP_HOST ?>/">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script>
       $(function(){
          $(".project .trimmed").one("click", function(){  
              $(this).animate({"max-height": "20em"});

Added template/projects_description.php.





































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
47
48
49
50
<?php
/**
 * api: include
 * type: template
 * title: Project description
 * description: Displays title, version, description, tags, homepage + download button
 *
 * Each projects/ page description contains
 *
 *   → Headline of project title and current version
 *   → Screenshot image
 *   → Description
 *   → Tag list (tags, license, state)
 *   → [Homepage] and [Download] link buttons
 *
 */


print <<<PROJECT
      <article class=project>

        <h3>
            <a href="projects/$entry[name]">
               $entry[title]
               <em class=version>$entry[version]</em>
            </a>
        </h3>

        <a href="$entry[homepage]">
           <img class=preview src="$entry[image]" align=right width=120 height=90 border=0>
        </a>

        <p class=description style="border:0">$entry[description]</p>

        <table class=long-tags border=0>
           <tr> <th>Tags</th>     <td>{$_(wrap_tags($entry["tags"]))}</td>           </tr>
           <tr> <th>License</th>  <td><a class=license>$entry[license]</a></td>      </tr>
           <tr> <th>State</th>    <td><a class=license>$entry[state]</a></td>        </tr>
        </table>

        <p class=long-links>
            <a href="$entry[homepage]"><img src="img/home.png" width=20 height=20 border=0 align=middle> Homepage</a>
            <a href="$entry[download]"><img src="img/disk.png" width=20 height=20 border=0 align=middle> Download</a>
        </p>

      </article>
PROJECT;


?>

Added template/projects_release_entry.php.



























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
<?php
/**
 * api: include
 * type: template
 * title: Project version entry
 * description: Displays a release, with scope and changes
 *
 * Shows versioning history of projects/
 *   → Date and Version
 *   → Scope and Changes
 *
 * This template, obviously, gets iterated over to output all
 * release entries.
 *
 */


print <<<VERSION_ENTRY
       <div class=release-entry>
          <span class=version>$entry[version]</span><span class=published_date>{$_(strftime("%d %b %Y %H:%M", $entry["t_published"]))}</span>
          <span class=release-notes>
             <b>$entry[scope]:</b>
             $entry[changes]
          </span>
       </div>
VERSION_ENTRY;


?>

Added template/projects_sidebar.php.































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/**
 * api: include
 * type: template
 * title: Sidebar links for project
 * description: Shows project URLs, submitter, submit/ and flag/ link, social bookmarks
 *
 * Creates #sidebar with four <section>s:
 *   → Project links (homepage, download, other URLs)
 *   → Submitter with gravatar/identicon
 *   → Submission edit button, and flag/ link
 *   → Social sharing links and ★ star count.
 *
 */


print <<<SIDEBAR
      <aside id=sidebar>
         <section>
           <h5>Links</h5>
           <a href="$entry[homepage]"><img src="img/home.png" width=11 height=11> Project Website</a><br>
           <a href="$entry[download]"><img src="img/disk.png" width=11 height=11> Download</a><br>
           {$_(proj_links($entry["urls"], $entry))} 
         </section>

         <section>
           <h5>Submitted by</h5>
           <a class=submitter href="/?user=$entry[submitter]">$entry[submitter_img]$entry[submitter]</a><br>
         </section>

         <section style="font-size:90%">
           <h5>Manage</h5>
         You can also help out here by:<br>
         <a class=long-links href="/submit/$entry[name]" style="display:inline-block; margin: 3pt 1pt;">&larr; Updating infos</a><br>
         or <a href="/flag/$entry[name]">flagging</a> this entry for moderator attention.
         </section>

         <section style="font-size:90%">
           <h5>Share project {$_(social_share_count($entry["social_links"]))}</h5>
           {$_(social_share_links($entry["name"], $entry["homepage"]))}
         </section>
      </aside>
      <section id=main>
SIDEBAR;



/**
 * Convert "url1=, url2=, url3=" list into titled hyperlinks.
 *
 */
function proj_links($urls, $entry, $r="") {
    foreach (p_key_value($urls) as $title=>$url) {
        $title = ucwords($title);
        $url = versioned_url($url, $entry["version"]);
        $r .= "&rarr; <a href=\"$url\">$title</a><br>\n";
    }
    return $r;
}



?>