⌈⌋ ⎇ branch:  freshcode


Artifact [0466ce14c5]

Artifact 0466ce14c54f8fd4cae50a7d368f2cbd46d39614:

  • File page_launchpadreleases.php — part of check-in [d16f5b9864] at 2015-01-18 22:31:51 on branch trunk — Introduce `launchpad-releases` page. Updated polling with less delay. (So far only 30% of projects information received, less than 12% of release infos.) (user: mario size: 3691)

     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
<?php
/**
 * api: freshcode
 * title: launchpad-releases
 * description: dump releases feed
 * version: 0.1
 *
 * Launchpad is polled by a cron script.
 * This page just displays the latest project releases.
 *
 */

#-- switch database
db(new PDO("sqlite:launchpad.db"));

include("template/header.php");
?>
  <section id=main style="width:70%">
  <h2><img src="https://help.launchpad.net/moin_static192/lp20/img/logo.png" width=28 height=31> Launchpad Releases</h2>
  <article class=launchpad-releases>
  
<style>
    /** table **/
    .launchpad-releases {
       width: 100%;
    }
    #launchpadreleases {
       table-layout: fixed;
       width: 100%;
    }
    tr.release {
       padding: 4pt 1pt;
       font-size: 95%;
       box-shadow: none;
    }
    /** long fields **/
    td.lp-release-notes,
    td.proj-desc {
       color: #444;
       font-size: 75%;
    }
    tr.release td .max-height {
       max-height: 90pt;
       overflow: hidden;
       text-overflow: ellipsis;
    }
    /** title + version **/
    .proj-title a {
       font-size: 105%;
    }
    .prog-lang {
       font-size: 60%;
       padding: 0.5pt 1pt;
       border: dotted 1px #eef;
       background: #f1f3ff;
       color: #aae;
    }
    td.proj-version {
       color: #977;
    }
    td.proj-version .version {
       font-size: 120%;
       font-weight: 600;
    }
    /** urls **/
    td.proj-urls {
       font-size: 70%;
       color: #555;
    }
    td.proj-urls a {
       font-size: 95%;
       font-weight: normal;
    }
</style>

     <table id=launchpadreleases>
     <colgroup>
        <col width="15%">
        <col width="15%">
        <col width="30%">
        <col width="20%">
        <col width="20%">
     </colgroup>
     <?php

        // query latest     
        $q = db("
             SELECT r.name, r.title, r.version, r.release_notes, SUBSTR(r.date_created, 1, 10) AS date_created,
                    r.web_link,
                    p.web_link AS launchpad_url, p.programming_language, p.homepage_url, p.display_name,
                    p.summary, p.title AS proj_title, p.description, p.screenshots_url
               FROM releases AS r
          LEFT JOIN projects AS p
                 ON p.name = r.name
           ORDER BY date_created DESC
              LIMIT 100
        ");
        
        // print in table
        foreach ($q as $row) {
            $row = array_map("input::html", $row);
            print <<<HTML

       <tr class=release>
         <td class=proj-title title="$row[summary]">
            <a href="$row[launchpad_url]"> $row[proj_title] </a><br>
            <span class=prog-lang> $row[programming_language] </span>
         </td>
         <td class=proj-version>
            <a href="$row[web_link]"> →<em class=version> $row[version] </em> </a>
            <div class=release-date>$row[date_created]</div>
         </td>
         <td class=lp-release-notes>
           <div class=max-height>
              $row[release_notes]
           </div>
         </td>
         <td class=proj-urls>
           Url <a href="$row[homepage_url]"><b> $row[homepage_url] </b></a><br>
           LP <a href="$row[launchpad_url]"> $row[launchpad_url] </a><br>
           Img <a href="$row[screenshots_url]"> $row[screenshots_url] </a><br>
         </td>
         <td class=proj-desc>
           <div class=max-height>
              $row[description]
           </div>
         </td>
       </tr>

HTML;
        }
     
     ?>
     </table>

  </article>

  <p style="break: both; clear: all; background: #f3f5f7; padding: 20pt;">
    Polled via <a href="https://launchpad.net/+apidoc/">Launchpad API</a>.
  </p>

<?php
include("template/bottom.php");