Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added css & template files

  • Loading branch information...
commit accb1d82eba18727e532927c5d36a8d6c1a45927 1 parent 72133c8
@glebpopoff authored
View
BIN  static/.DS_Store
Binary file not shown
View
411 static/desktop.css
@@ -0,0 +1,411 @@
+
+div.main-content
+{
+ width:1024px;
+}
+
+div.page-top
+{
+ background-color: #dedede;
+}
+
+div.page-top.logo
+{
+ float: left;
+}
+
+div.page-top .search-box
+{
+
+}
+
+div.my-profile
+{
+ background-color: #eee;
+}
+div.my-profile span
+{
+ color: #fff;
+ background-color: navy;
+}
+div.search-form
+{
+ background-color: #eee;
+}
+div.page-nav
+{
+ width:250px;
+ float:left;
+ text-align:left;
+ vertical-align:middle;
+}
+div.page-content
+{
+ width: 700px;
+ float:left;
+ text-align:left;
+}
+div.rightcolumn
+{
+ width:150px;
+ float:right;
+ text-align:center;
+ vertical-align:middle;
+}
+hr
+{
+ clear:both;
+ display:block;
+ visibility:hidden;
+}
+
+/*----------------------------------------------------------
+The base color for this template is #5c87b2. If you'd like
+to use a different color start by replacing all instances of
+#5c87b2 with your new color.
+----------------------------------------------------------*/
+
+body#userportal
+{
+ background-color: #fff;
+ font-size: .75em;
+ font-family: Verdana, Helvetica, Sans-Serif;
+ margin-left: 10px;
+ padding: 0;
+ color: #696969;
+}
+
+body
+{
+ font-size: .75em;
+ font-family: Verdana, Helvetica, Sans-Serif;
+ margin: 0;
+ padding: 0;
+ color: #696969;
+}
+
+a:link
+{
+ color: #034af3;
+ text-decoration: underline;
+}
+a:visited
+{
+ color: #505abc;
+}
+a:hover
+{
+ color: #1d60ff;
+ text-decoration: none;
+}
+a:active
+{
+ color: #12eb87;
+}
+
+p, ul
+{
+ margin-bottom: 20px;
+ line-height: 1.6em;
+}
+
+.breadcrumbs
+{
+ font-size: 8pt;
+}
+
+.homepagebutton
+{
+ width: 200px;
+ height: 25px;
+}
+
+input[type="button"], input[type="submit"]
+{
+ border: 1px solid #CCC;
+}
+
+/* HEADINGS
+----------------------------------------------------------*/
+h1, h2, h3, h4, h5, h6
+{
+ font-size: 1.3em;
+ color: #000;
+ font-family: Arial, Helvetica, sans-serif;
+}
+
+h1
+{
+ font-size: 1.5em;
+ padding-bottom: 0;
+ margin-bottom: 0;
+}
+h2
+{
+ padding: 0 0 10px 0;
+}
+h3
+{
+ font-size: 1.2em;
+}
+h4
+{
+ font-size: 1.1em;
+}
+h5, h6
+{
+ font-size: 1em;
+}
+
+/* this rule styles <h2> tags that are the
+first child of the left and right table columns */
+.rightColumn > h1, .rightColumn > h2, .leftColumn > h1, .leftColumn > h2
+{
+ margin-top: 0;
+}
+
+/* PRIMARY LAYOUT ELEMENTS
+----------------------------------------------------------*/
+
+/* you can specify a greater or lesser percentage for the
+page width. Or, you can specify an exact pixel width. */
+.page
+{
+ width: 90%;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+#header
+{
+ position: relative;
+ margin-bottom: 0px;
+ color: #000;
+ padding: 0;
+}
+
+#header h1
+{
+ font-weight: bold;
+ padding: 5px 0;
+ margin: 0;
+ color: #FC5713;
+ border: none;
+ line-height: 1.2em;
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 20px !important;
+}
+
+#main
+{
+ border: 1px #EAF3FD solid;
+ padding: 10px 30px 15px 30px;
+ background-color: #fff;
+ margin-bottom: 30px;
+ _height: 1px; /* only IE6 applies CSS properties starting with an underscrore */
+}
+
+#footer
+{
+ color: #000;
+ padding: 10px 0;
+ text-align: center;
+ line-height: normal;
+ margin: 0;
+ font-size: .9em;
+}
+
+/* TAB MENU
+----------------------------------------------------------*/
+ul#menu
+{
+ border-bottom: 1px #EAF3FD solid;
+ padding: 0 0 2px;
+ position: relative;
+ margin: 0;
+ text-align: right;
+}
+
+ul#menu li
+{
+ display: inline;
+ list-style: none;
+}
+
+ul#menu li#greeting
+{
+ padding: 10px 20px;
+ font-weight: bold;
+ text-decoration: none;
+ line-height: 2.8em;
+ color: #fff;
+}
+
+ul#menu li a
+{
+ padding: 10px 20px;
+ font-weight: bold;
+ text-decoration: none;
+ line-height: 2.8em;
+ background-color: #73AEEB;
+ color: #fff;
+}
+
+ul#menu li a:hover
+{
+ background-color: #0D67CE;
+ text-decoration: none;
+}
+
+ul#menu li a:active
+{
+ background-color: #73AEEB;
+ text-decoration: none;
+}
+
+ul#menu li.selected a
+{
+ background-color: #0D67CE;
+ color: #fff;
+}
+
+/* FORM LAYOUT ELEMENTS
+----------------------------------------------------------*/
+
+fieldset
+{
+ margin: 1em 0;
+ padding: 1em;
+ border: 1px solid #CCC;
+}
+
+fieldset p
+{
+ margin: 2px 12px 10px 10px;
+}
+
+fieldset label
+{
+ display: block;
+}
+
+fieldset label.inline
+{
+ display: inline;
+}
+
+legend
+{
+ font-size: 1.1em;
+ font-weight: 600;
+ padding: 2px 4px 8px 4px;
+}
+
+input[type="text"]
+{
+ width: 250px;
+ border: 1px solid #CCC;
+}
+
+textarea
+{
+ width: 250px;
+}
+
+.large_textarea
+{
+ width: 889px;
+}
+
+input[type="password"]
+{
+ width: 250px;
+ border: 1px solid #CCC;
+}
+
+/* TABLE
+----------------------------------------------------------*/
+
+table
+{
+ border: solid 1px #e8eef4;
+ border-collapse: collapse;
+}
+
+table td
+{
+ padding: 5px;
+ border: solid 1px #e8eef4;
+}
+
+table th
+{
+ padding: 6px 5px;
+ text-align: left;
+ background-color: #e8eef4;
+ border: solid 1px #e8eef4;
+}
+
+/* MISC
+----------------------------------------------------------*/
+.clear
+{
+ clear: both;
+}
+
+.error
+{
+ color:Red;
+}
+
+#menucontainer
+{
+ margin-top:20px;
+}
+
+div#title
+{
+ display:block;
+ float:left;
+ text-align:left;
+}
+
+#logindisplay
+{
+ font-size:0.9em;
+ display:block;
+ text-align:right;
+ margin:10px;
+}
+
+#logindisplay a:link
+{
+ text-decoration: underline;
+}
+
+#logindisplay a:visited
+{
+ text-decoration: underline;
+}
+
+#logindisplay a:hover
+{
+ text-decoration: none;
+}
+
+.field-validation-error
+{
+ color: #ff0000;
+}
+
+.input-validation-error
+{
+ border: 1px solid #ff0000;
+ background-color: #ffeeee;
+}
+
+.validation-summary-errors
+{
+ font-weight: bold;
+ color: #ff0000;
+}
View
BIN  static/images/favicon.ico
Binary file not shown
View
BIN  templates/.DS_Store
Binary file not shown
View
408 templates/index.html
@@ -0,0 +1,408 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <title>Hacker News API</title>
+ <link rel="stylesheet" href="/static/desktop.css" type="text/css">
+ <script type="text/javascript">
+ var port = (window.location.port != 80) ? ':' + window.location.port : '';
+ var apiURL = 'http://' + window.location.hostname + port;
+
+ function getRss()
+ {
+ window.location = apiURL + '/rss/format/' + format('rss-format');
+ }
+
+ function getNewsSimple()
+ {
+ window.location = apiURL + '/news';
+ }
+
+ function getNewestSimple()
+ {
+ window.location = apiURL + '/newest';
+ }
+
+ function getLatestSimple()
+ {
+ window.location = apiURL + '/latest';
+ }
+
+ function getLatestAdvanced()
+ {
+ window.location = apiURL + '/latest/format/' + format('latest-format') + '/limit/' + elm('latest-limit')
+ }
+
+ function getBestSimple()
+ {
+ window.location = apiURL + '/best';
+ }
+
+ function getAskSimple()
+ {
+ window.location = apiURL + '/ask';
+ }
+
+ function getNewsAdvanced()
+ {
+ window.location = apiURL + '/news/format/' + format('newsadvanced-format') + '/page/' + elm('newsadvanced-pageid')
+ }
+
+ function getNewestAdvanced()
+ {
+ window.location = apiURL + '/newest/format/' + format('newestadvanced-format') + '/page/' + elm('newestadvanced-pageid')
+ }
+
+ function getAskAdvanced()
+ {
+ window.location = apiURL + '/ask/format/' + format('ask-format') + '/page/' + elm('ask-pageid')
+ }
+
+ function getBestAdvanced()
+ {
+ window.location = apiURL + '/best/format/' + format('best-format') + '/page/' + elm('best-pageid')
+ }
+
+ function getByUser()
+ {
+ window.location = apiURL + '/submitted/format/' + format('user-format') + '/user/' + elm('user-pageid')
+ }
+
+ function getComments()
+ {
+ window.location = apiURL + '/comments/format/' + format('comments-format') + '/id/' + elm('comments-pageid')
+ }
+
+ function elm(id) { return (document.getElementById(id)) ? document.getElementById(id).value : '' }
+ function format(name)
+ {
+ var elm = document.getElementsByName(name);
+ if (!elm)
+ {
+ return 'json';
+ }
+ for( i = 0; i < elm.length; i++)
+ {
+ if (elm[i].checked) return elm[i].value;
+ }
+ return 'json';
+ }
+
+ </script>
+</head>
+<h1>Hacker News API (unofficial)</h2>
+<body id="userportal">
+ <div id="main-container">
+ <div id="app-header">
+ <h3>Last updated: {{last_updated}}</h3>
+ <span>The API is currently in beta and was developed for the <a href="https://market.android.com/details?id=com.glebpopov.hackernews" target="_new">Hacker News Droid</a> app. The API is built in Python and hosted on AppEngine. I used the <a href="http://www.crummy.com/software/BeautifulSoup/">Beautiful Soup</a> library for HTML parsing/scraping.
+ <br/>
+ <br/>
+ There's five minute caching for main content entry points (/news, /best, /ask, /newest); there's no caching for paginated content (requests that require pageID).
+ <br/><br/>
+ <a href="https://github.com/glebpopov/Hacker-News-Droid-API">Full source code available on GitHub</a>.
+ For any questions please drop me a note (<script type='text/javascript'>var a='@',g='gmail',c='.',d='com';document.writeln('g' + 'p' + 'o' + 'p' + 'o' + 'v' + a + g + c + d )</script>).
+ Cheers, <a href="http://glebche.appspot.com" target="_new">Gleb Popov</a>
+ </span>
+ </div>
+ <p>
+<b>API Index</b>:
+<ul>
+ <li><a href='#homepage'>Homepage</a></li>
+ <li><a href='#latest'>Latest</a></li>
+ <li><a href='#newest'>Newest</a></li>
+ <li><a href='#best'>Best</a></li>
+ <li><a href='#ask'>Ask</a></li>
+ <li><a href='#user'>Submitted</a></li>
+ <li><a href='#user'>Comments</a></li>
+</ul>
+ </p>
+<hr >
+<a name="homepage"></a>
+<h2>Homepage: Simple API</h2>
+<fieldset>
+ <b>Returns homepage news, including author, points, number of comments, etc </b>&nbsp;<small>(JSON)</small><br /><br />
+ <table>
+ <tr>
+ <td>URL:</td>
+ <td>http://hndroidapi.appspot.com/news</td>
+ </tr>
+ <tr>
+ <td colspan='2'><input type="button" value=" Test " onclick="getNewsSimple()" /></td>
+ </tr>
+ </table>
+ <br />
+</fieldset>
+
+<h2>Homepage: Advanced API</h2>
+<fieldset>
+ <b>Returns homepage news, including author, points, number of comments, etc </b>&nbsp;<small>(returns XML or JSON)</small><br /><br />
+ <table>
+ <tr>
+ <td>URL:</td>
+ <td>http://hndroidapi.appspot.com/news/format/<em>&lt;format&gt;</em>/page/<em>&lt;page id&gt;</em></td>
+ </tr>
+ <tr>
+ <td>Page ID:</td>
+ <td><input type="text" id="newsadvanced-pageid" name="newsadvanced-pageid" />&nbsp;<small>(e.g. OTXxTSKeac)</small></td>
+ </tr>
+ <tr>
+ <td>Format:</td>
+ <td><input type="radio" name="newsadvanced-format" value="json" checked='checked'/>JSON&nbsp;<input type="radio" name="newsadvanced-format" value="xml"/>XML</td>
+ </tr>
+ <tr>
+ <td colspan='2'><input type="button" value=" Test " onclick="getNewsAdvanced()" /></td>
+ </tr>
+ </table>
+ <br />
+</fieldset>
+
+<hr >
+<a name="latest"></a>
+<h2>Latest: Simple API</h2>
+<fieldset>
+ <b>Returns a single top news story from homepage, including author, points, number of comments, etc </b>&nbsp;<small>(JSON)</small><br /><br />
+ <table>
+ <tr>
+ <td>URL:</td>
+ <td>http://hndroidapi.appspot.com/latest</td>
+ </tr>
+ <tr>
+ <td colspan='2'><input type="button" value=" Test " onclick="getLatestSimple()" /></td>
+ </tr>
+ </table>
+ <br />
+</fieldset>
+
+<h2>Latest: Advanced API</h2>
+<fieldset>
+ <b>Returns multiple news stories based on the limit parameter, including author, points, number of comments, etc </b>&nbsp;<small>(returns XML or JSON)</small><br /><br />
+ <table>
+ <tr>
+ <td>URL:</td>
+ <td>http://hndroidapi.appspot.com/latest/format/<em>&lt;format&gt;</em>/limit/<em>&lt;limit&gt;</em></td>
+ </tr>
+ <tr>
+ <td>Limit:</td>
+ <td><input type="text" id="latest-limit" name="latest-limit" value="1" />&nbsp;<small>(number of stories to return, e.g. 1)</small></td>
+ </tr>
+ <tr>
+ <td>Format:</td>
+ <td><input type="radio" name="latest-format" value="json" checked='checked'/>JSON&nbsp;<input type="radio" name="latest-format" value="xml"/>XML</td>
+ </tr>
+ <tr>
+ <td colspan='2'><input type="button" value=" Test " onclick="getLatestAdvanced()" /></td>
+ </tr>
+ </table>
+ <br />
+</fieldset>
+
+<hr >
+<a name="newest"></a>
+<h2>Newest: Simple API</h2>
+<fieldset>
+ <b>Returns new posts, including author, points, number of comments, etc </b>&nbsp;<small>(JSON)</small><br /><br />
+ <table>
+ <tr>
+ <td>URL:</td>
+ <td>http://hndroidapi.appspot.com/newest</td>
+ </tr>
+ <tr>
+ <td colspan='2'><input type="button" value=" Test " onclick="getNewestSimple()" /></td>
+ </tr>
+ </table>
+ <br />
+</fieldset>
+
+<h2>Newest: Advanced API</h2>
+<fieldset>
+ <b>Returns new posts, including author, points, number of comments, etc </b>&nbsp;<small>(returns XML or JSON)</small><br /><br />
+ <table>
+ <tr>
+ <td>URL:</td>
+ <td>http://hndroidapi.appspot.com/newest/format/<em>&lt;format&gt;</em>/page/<em>&lt;page id&gt;</em></td>
+ </tr>
+ <tr>
+ <td>Page ID:</td>
+ <td><input type="text" id="newestadvanced-pageid" name="newestadvanced-pageid" />&nbsp;<small>(e.g. OTXxTSKeac)</small></td>
+ </tr>
+ <tr>
+ <td>Format:</td>
+ <td><input type="radio" name="newestadvanced-format" value="json" checked='checked'/>JSON&nbsp;<input type="radio" name="newestadvanced-format" value="xml"/>XML</td>
+ </tr>
+ <tr>
+ <td colspan='2'><input type="button" value=" Test " onclick="getNewestAdvanced()" /></td>
+ </tr>
+ </table>
+ <br />
+</fieldset>
+
+<hr >
+<a name="best"></a>
+<h2>Best: Simple API</h2>
+<fieldset>
+ <b>Returns best content, including author, points, number of comments, etc </b>&nbsp;<small>(JSON)</small><br /><br />
+ <table>
+ <tr>
+ <td>URL:</td>
+ <td>http://hndroidapi.appspot.com/best</td>
+ </tr>
+ <tr>
+ <td colspan='2'><input type="button" value=" Test " onclick="getBestSimple()" /></td>
+ </tr>
+ </table>
+ <br />
+</fieldset>
+
+<h2>Best: Advanced API</h2>
+<fieldset>
+ <b>Returns best content, including author, points, number of comments, etc </b>&nbsp;<small>(returns XML or JSON)</small><br /><br />
+ <table>
+ <tr>
+ <td>URL:</td>
+ <td>http://hndroidapi.appspot.com/best/format/<em>&lt;format&gt;</em>/page/<em>&lt;page id&gt;</em></td>
+ </tr>
+ <tr>
+ <td>Page ID:</td>
+ <td><input type="text" id="best-pageid" name="best-pageid" />&nbsp;<small>(e.g. OTXxTSKeac)</small></td>
+ </tr>
+ <tr>
+ <td>Format:</td>
+ <td><input type="radio" name="best-format" value="json" checked='checked'/>JSON&nbsp;<input type="radio" name="best-format" value="xml"/>XML</td>
+ </tr>
+ <tr>
+ <td colspan='2'><input type="button" value=" Test " onclick="getBestAdvanced()" /></td>
+ </tr>
+ </table>
+ <br />
+</fieldset>
+
+<hr >
+<a name="ask"></a>
+<h2>Ask: Simple API</h2>
+<fieldset>
+ <b>Returns ask HN content, including author, points, number of comments, etc </b>&nbsp;<small>(JSON)</small><br /><br />
+ <table>
+ <tr>
+ <td>URL:</td>
+ <td>http://hndroidapi.appspot.com/ask</td>
+ </tr>
+ <tr>
+ <td colspan='2'><input type="button" value=" Test " onclick="getAskSimple()" /></td>
+ </tr>
+ </table>
+ <br />
+</fieldset>
+<h2>Ask HN: Advanced API</h2>
+<fieldset>
+ <b>Returns ask HN content, including author, points, number of comments, etc </b>&nbsp;<small>(returns XML or JSON)</small><br /><br />
+ <table>
+ <tr>
+ <td>URL:</td>
+ <td>http://hndroidapi.appspot.com/ask/format/<em>&lt;format&gt;</em>/page/<em>&lt;page id&gt;</em></td>
+ </tr>
+ <tr>
+ <td>Page ID:</td>
+ <td><input type="text" id="ask-pageid" name="ask-pageid" />&nbsp;<small>(e.g. OTXxTSKeac)</small></td>
+ </tr>
+ <tr>
+ <td>Format:</td>
+ <td><input type="radio" name="ask-format" value="json" checked='checked'/>JSON&nbsp;<input type="radio" name="ask-format" value="xml"/>XML</td>
+ </tr>
+ <tr>
+ <td colspan='2'><input type="button" value=" Test " onclick="getAskAdvanced()" /></td>
+ </tr>
+ </table>
+ <br />
+</fieldset>
+<!--
+<h2>RSS</h2>
+<fieldset>
+ <b>Returns Hacker News RSS feed formatted in XML or JSON</b>&nbsp;<small>(JSON or XML)</small><br /><br />
+ <table>
+ <tr>
+ <td>URL:</td>
+ <td>http://hndroidapi.appspot.com/rss</td>
+ </tr>
+ <tr>
+ <td>Format:</td>
+ <td><input type="radio" name="rss-format" value="json" checked='checked'/>JSON&nbsp;<input type="radio" name="rss-format" value="xml"/>XML</td>
+ </tr>
+ <tr>
+ <td colspan='2'><input type="button" value=" Test " onclick="getRss()" /></td>
+ </tr>
+ </table>
+ <br />
+</fieldset>
+-->
+<hr >
+<a name="user"></a>
+<h2>Submissions by User</h2>
+<fieldset>
+ <b>Returns submissions by user, including author, points, number of comments, etc </b>&nbsp;<small>(returns XML or JSON)</small><br /><br />
+ <table>
+ <tr>
+ <td>URL:</td>
+ <td>http://hndroidapi.appspot.com/submitted/format/<em>&lt;format&gt;</em>/user/<em>&lt;username&gt;</em></td>
+ </tr>
+ <tr>
+ <td>Username:</td>
+ <td><input type="text" id="user-pageid" name="user-pageid" />&nbsp;<small>(e.g. john1)</small></td>
+ </tr>
+ <tr>
+ <td>Format:</td>
+ <td><input type="radio" name="user-format" value="json" checked='checked'/>JSON&nbsp;<input type="radio" name="user-format" value="xml"/>XML</td>
+ </tr>
+ <tr>
+ <td colspan='2'><input type="button" value=" Test " onclick="getByUser()" /></td>
+ </tr>
+ </table>
+ <br />
+</fieldset>
+<hr >
+<a name="comments"></a>
+<h2>Comments by Story ID</h2>
+<fieldset>
+ <b>Returns story comments by id </b>&nbsp;<small>(returns XML or JSON)</small><br /><br />
+ <table>
+ <tr>
+ <td>URL:</td>
+ <td>http://hndroidapi.appspot.com/comments/format/<em>&lt;format&gt;</em>/id/<em>&lt;id&gt;</em></td>
+ </tr>
+ <tr>
+ <td>Story Id:</td>
+ <td><input type="text" id="comments-pageid" name="comments-pageid" />&nbsp;<small>(e.g. 3423232)</small></td>
+ </tr>
+ <tr>
+ <td>Format:</td>
+ <td><input type="radio" name="comments-format" value="json" checked='checked'/>JSON&nbsp;<input type="radio" name="comments-format" value="xml"/>XML</td>
+ </tr>
+ <tr>
+ <td colspan='2'><input type="button" value=" Test " onclick="getComments()" /></td>
+ </tr>
+ </table>
+ <br />
+</fieldset>
+
+</form>
+</div>
+<hr />
+<p>
+ Built by <a href="http://glebche.appspot.com">Gleb Popov</a>. Last updated: {{last_updated}}.
+ </p>
+<script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-24252811-3']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+</script>
+
+</body>
+</html>
Please sign in to comment.
Something went wrong with that request. Please try again.