Commits

Sean Davis committed 2a39321

Enabled flatpages and added software list

Flatpages currently uses markdown-formated pages in the pages directory
to generate content. This is useful as a static website generator-like
thing.

The software list is currently generated by a YAML file at the top level.

  • Participants
  • Parent commits 9f8074d

Comments (0)

Files changed (9)

-from flask import Flask
+from flask import Flask, url_for
 from flask import render_template
+from flask_flatpages import FlatPages
+
+from bioinformaticsncinihgov.software import SoftwareList
+
 app = Flask(__name__)
 
+# set up flatpages
+app.config.FLATPAGES_ROOT = 'pages'
+pages = FlatPages(app)
+
+app.debug = True
+
+
 @app.route("/")
 def hello():
     return render_template('index.html')
 
+@app.route('/software/')
+def software_list():
+    software = SoftwareList('software.yaml')
+    return render_template('software.html',software = software.software)
+
+@app.route('/<path:path>/')
+def page(path):
+    page = pages.get_or_404(path)
+    template = page.meta.get('template', 'index2.html')
+    return render_template(template, page=page)
+
+
 if __name__ == "__main__":
     app.run()
 

bioinformaticsncinihgov/software.py

+import yaml
+
+class SoftwareList(object):
+    def __init__(self,dbfile):
+        self.software = [software for software in yaml.load_all(open(dbfile,'r'))]
+
+
 from flask_frozen import Freezer
+from flask_flatpages import FlatPages
+
 import app
 
 freezer = Freezer(app.app)
 
+pages = FlatPages(app.app)
+
+
 if __name__ == '__main__':
+	@freezer.register_generator
+	def pages_urls():
+		for p in pages:
+			yield "page",{'path':p.path}
+	
         freezer.freeze()
+title: test
+
+# this is an h1
+
+aslkdjf;lkaj
+lskdjfasdlkfj
+
+## test2
+---
+title: GEOquery
+description: >
+    The bridge between NCBI Gene Expression Omnibus and Bioconductor.
+url: http://www.bioconductor.org/packages/release/bioc/html/GEOquery.html
+---
+title: GEOmetadb
+description: >
+    Mine NCBI GEO using the Bioconductor package or any SQLite client.
+url: http://www.bioconductor.org/packages/release/bioc/html/GEOmetadb.html
+---
+title: ACME
+description: >
+    Algorithm for Calculating Microarray Enrichment for analysis of tiling array data.
+url: http://www.bioconductor.org/packages/release/bioc/html/ACME.html
+---
+title: methylumi
+description: >
+    Read and analyze methylation data from all Illumina methylation array platforms.
+url: http://www.bioconductor.org/packages/release/bioc/html/methylumi.html
+---
+title: SRAdb
+description: >
+    Find and download data from the NCBI Sequence Read Archive from R and interact with the IGV genome browser.
+url: http://www.bioconductor.org/packages/release/bioc/html/SRAdb.html
+---
+title: ngCGH
+description: >
+    Simple count-based copy number estimation from paired samples such as tumor and normal.
+url: http://github.com/seandavi/ngCGH

templates/base.html

+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="utf-8">
+    <title>Bioinformatics@CCR - {% block title %}{% endblock %}</title>
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <meta name="description" content="">
+    <meta name="author" content="">
+
+    <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
+    <!--[if lt IE 9]>
+	<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
+	<![endif]-->
+
+    <!-- Le styles -->
+    <link href="{{ url_for('static',filename='css/bootstrap.min.css') }}" rel="stylesheet">
+    <link href="{{ url_for('static',filename='css/bootstrap-responsive.css') }}" rel="stylesheet">
+    <script src="http://code.jquery.com/jquery-latest.js"></script>
+    <script src="{{ url_for('static',filename='js/bootstrap.min.js') }}"></script>
+    <script src="{{ url_for('static',filename='js/page.js') }}"></script>
+    <style>
+      #main {
+      padding-top:60px;
+      }
+    </style>
+    <script>
+      $('#main-carousel').ready(function() {
+      $('#main-carousel').carousel('cycle');
+      });
+    </script>
+  </head>
+  <body>
+    <!-- Masthead
+	 ================================================== -->
+    <div class="navbar navbar-inverse navbar-fixed-top">
+      <div class="navbar-inner">
+	<div class="container">
+	  <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
+            <span class="icon-bar"></span>
+            <span class="icon-bar"></span>
+            <span class="icon-bar"></span>
+          </a>
+          <div class="nav-collapse">
+	    <a class="brand" href="#">Bioinformatics@CCR</a>
+            <ul class="nav">
+              <li><a href="/">Home</a></li>
+              <li><a href="/training">Training & Education</a></li>
+              <li><a href="{{ url_for('software_list') }}">Software</a></li>
+            </ul>
+            <ul class="nav pull-right">
+              <li class="divider-vertical"></li>
+              <li class="dropdown">
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown">Quick Links<b class="caret"></b></a>
+		<ul class="dropdown-menu">
+                  <li><a href="http://genome.ucsc.edu/">UCSC Genome Browser</a></li>
+                  <li><a href="http://bioconductor.org/">Bioconductor</a></li>
+                  <li class="divider"></li>
+		  <li><a href="http://ostp.nci.nih.gov/">Office of Science and Technology Partnerships</a></li>
+                  <li><a href="http://www.ncbi.nlm.nih.gov/">NCBI</a></li>
+                  <li><a href="http://helix.nih.gov/">NIH Helix & Biowulf</a></li>
+                  <li><a href="http://galaxy.cit.nih.gov/">NIH Galaxy Server</a></li>		
+		</ul>
+              </li>
+            </ul>
+          </div><!-- /.nav-collapse -->
+	</div>
+      </div><!-- /navbar-inner -->
+    </div><!-- /navbar -->
+
+    <div class="container" id="main">
+      <div class="row">
+	<div class="span12">
+
+	  {% block content %}{% endblock %}
+
+	</div>
+      </div>
+    </div>
+    <footer>
+      <center>
+	<a href="http://www.cancer.gov"><img src="http://ccrod.cancer.gov//confluence/images/themebuilder/foot_nci.jpg" alt="National Cancer Institute"/></a>
+	<a href="http://www.nih.gov"><img src="http://ccrod.cancer.gov//confluence/images/themebuilder/foot_nih.jpg" alt="National Institutes of Health"/></a>
+	<a href="http://www.dhhs.gov"><img src="http://ccrod.cancer.gov//confluence/images/themebuilder/foot_hhs.jpg" alt="Department of Health and Human Services"/></a>
+	<a href="http://www.usa.gov"><img src="http://ccrod.cancer.gov//confluence/images/themebuilder/foot_usa.jpg" alt="USA.gov"/></a>
+      </center>
+    </footer>
+    <script type="text/javascript">
+
+      var _gaq = _gaq || [];
+      _gaq.push(['_setAccount', 'UA-20569571-1']);
+      _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>

templates/index.html

           <div class="nav-collapse">
 	    <a class="brand" href="#">Bioinformatics@CCR</a>
             <ul class="nav">
-              <li class="active"><a href="#">Home</a></li>
-              <li><a href="training">Training & Education</a></li>
+              <li><a href="{{ url_for('hello') }}">Home</a></li>
+              <li><a href="/training">Training & Education</a></li>
+              <li><a href="{{ url_for('software_list') }}">Software</a></li>
             </ul>
             <ul class="nav pull-right">
               <li class="divider-vertical"></li>

templates/index2.html

+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="utf-8">
+    <title>Bioinformatics@CCR</title>
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <meta name="description" content="">
+    <meta name="author" content="">
+
+    <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
+    <!--[if lt IE 9]>
+	<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
+	<![endif]-->
+
+    <!-- Le styles -->
+    <link href="{{ url_for('static',filename='css/bootstrap.min.css') }}" rel="stylesheet">
+    <link href="{{ url_for('static',filename='css/bootstrap-responsive.css') }}" rel="stylesheet">
+    <script src="http://code.jquery.com/jquery-latest.js"></script>
+    <script src="{{ url_for('static',filename='js/bootstrap.min.js') }}"></script>
+    <script src="{{ url_for('static',filename='js/page.js') }}"></script>
+    <style>
+      #main {
+      padding-top:60px;
+      }
+    </style>
+    <script>
+      $('#main-carousel').ready(function() {
+      $('#main-carousel').carousel('cycle');
+      });
+    </script>
+  </head>
+  <body>
+    <!-- Masthead
+	 ================================================== -->
+    <div class="navbar navbar-inverse navbar-fixed-top">
+      <div class="navbar-inner">
+	<div class="container">
+	  <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
+            <span class="icon-bar"></span>
+            <span class="icon-bar"></span>
+            <span class="icon-bar"></span>
+          </a>
+          <div class="nav-collapse">
+	    <a class="brand" href="#">Bioinformatics@CCR</a>
+            <ul class="nav">
+              <li><a href="/">Home</a></li>
+              <li><a href="/training">Training & Education</a></li>
+              <li><a href="{{ url_for('software_list',path='software') }}">Software</a></li>
+            </ul>
+            <ul class="nav pull-right">
+              <li class="divider-vertical"></li>
+              <li class="dropdown">
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown">Quick Links<b class="caret"></b></a>
+		<ul class="dropdown-menu">
+                  <li><a href="http://genome.ucsc.edu/">UCSC Genome Browser</a></li>
+                  <li><a href="http://bioconductor.org/">Bioconductor</a></li>
+                  <li class="divider"></li>
+		  <li><a href="http://ostp.nci.nih.gov/">Office of Science and Technology Partnerships</a></li>
+                  <li><a href="http://www.ncbi.nlm.nih.gov/">NCBI</a></li>
+                  <li><a href="http://helix.nih.gov/">NIH Helix & Biowulf</a></li>
+                  <li><a href="http://galaxy.cit.nih.gov/">NIH Galaxy Server</a></li>		
+		</ul>
+              </li>
+            </ul>
+          </div><!-- /.nav-collapse -->
+	</div>
+      </div><!-- /navbar-inner -->
+    </div><!-- /navbar -->
+
+    <div class="container" id="main">
+      <div class="row">
+	<div class="span12">
+
+	  {{ page }}
+
+	</div>
+      </div>
+    </div>
+    <footer>
+      <center>
+	<a href="http://www.cancer.gov"><img src="http://ccrod.cancer.gov//confluence/images/themebuilder/foot_nci.jpg" alt="National Cancer Institute"/></a>
+	<a href="http://www.nih.gov"><img src="http://ccrod.cancer.gov//confluence/images/themebuilder/foot_nih.jpg" alt="National Institutes of Health"/></a>
+	<a href="http://www.dhhs.gov"><img src="http://ccrod.cancer.gov//confluence/images/themebuilder/foot_hhs.jpg" alt="Department of Health and Human Services"/></a>
+	<a href="http://www.usa.gov"><img src="http://ccrod.cancer.gov//confluence/images/themebuilder/foot_usa.jpg" alt="USA.gov"/></a>
+      </center>
+    </footer>
+    <script type="text/javascript">
+
+      var _gaq = _gaq || [];
+      _gaq.push(['_setAccount', 'UA-20569571-1']);
+      _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>

templates/software.html

+{% extends "base.html" %}
+{% block title %}Software{% endblock %}
+{% block content %}
+<ul class="thumbnails">
+  {% for s in software %}
+  <li class="span4" style="height: 100%">
+    <div class="thumbnail well">
+      <h3>{{ s.title }}</h3>
+      <p>{{ s.description }}</p>
+      <a class="btn btn-info" href="{{ s.url }}">Learn more...</a>
+    </div>
+  </li>
+  {% endfor %}
+</ul>
+{% endblock %}
+
+    
+