Skip to content

Commit

Permalink
Merge pull request #152 from Carreau/cleanup
Browse files Browse the repository at this point in the history
cleanup nbviewer frontpage
  • Loading branch information
minrk committed Jan 5, 2014
2 parents c60214b + 35334d7 commit e3a7f5b
Show file tree
Hide file tree
Showing 26 changed files with 223 additions and 155 deletions.
5 changes: 3 additions & 2 deletions nbviewer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import os

import logging
import markdown

from cgi import escape
from concurrent.futures import ThreadPoolExecutor

Expand All @@ -21,7 +23,6 @@

from IPython.config import Config
from IPython.nbconvert.exporters import HTMLExporter
from IPython.nbconvert.filters import markdown2html

from .handlers import handlers
from .cache import DummyAsyncCache, AsyncMultipartMemcache, pylibmc
Expand Down Expand Up @@ -109,7 +110,7 @@ def main():
template_path = pjoin(here, 'templates')
static_path = pjoin(here, 'static')
env = Environment(loader=FileSystemLoader(template_path))
env.filters['markdown'] = markdown2html
env.filters['markdown'] = markdown.markdown
try:
git_data = git_info(here)
except Exception as e:
Expand Down
107 changes: 107 additions & 0 deletions nbviewer/frontpage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
[
{
"header":"Programming Languages",
"links":[
{
"text": "IPython Examples",
"target": "github/ipython/ipython/tree/master/examples/notebooks",
"img": "/static/img/example-nb/ipython-thumb.png"
},
{
"text": "IRuby Notebook",
"target": "github/minad/iruby/blob/master/IRuby-Example.ipynb",
"img": "/static/img/example-nb/iruby-nb.png"
},
{
"text": "An IJulia Preview",
"target": "url/jdj.mit.edu/~stevenj/IJulia%20Preview.ipynb",
"img": "/static/img/example-nb/ijulia-preview.png"
}
]
},
{
"header":"Books",
"links":[
{
"text": "Python for Signal Processing",
"target": "http://nbviewer.ipython.org/github/unpingco/Python-for-Signal-Processing/",
"img": "/static/img/example-nb/python-signal.png"
},
{
"text": "O'Reilly Book",
"target": "github/ptwobrussell/Mining-the-Social-Web-2nd-Edition/tree/master/ipynb",
"img": "/static/img/example-nb/mining-slice.png"
},
{
"text": "Probabilistic Programming",
"target": "github/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/blob/master/Chapter1_Introduction/Chapter1_Introduction.ipynb",
"img": "/static/img/example-nb/probabilistic-bayesian.png"
}
]
},
{
"header":"Misc",
"links":[
{
"text": "Interactive plots with Plotly",
"target": "github/plotly/IPython-plotly/tree/master/",
"img": "/static/img/example-nb/plotly.png"
},
{
"text": "XKCD Plot With Matplotlib",
"target": "url/jakevdp.github.com/downloads/notebooks/XKCD_plots.ipynb",
"img": "/static/img/example-nb/XKCD-Matplotlib.png"
},
{
"text": "Non Parametric Regression",
"target": "gist/fonnesbeck/2352771",
"img": "/static/img/example-nb/covariance.png"
},
{
"text": "Exploring R formula",
"target": "github/fperez/nipy-notebooks/blob/master/exploring_r_formula.ipynb",
"img": "/static/img/example-nb/exploring_r_formula.png"
},
{
"text": "Nose testing",
"target": "github/swcarpentry/2012-11-scripps/blob/master/python/testing-with-nose.ipynb",
"img": "/static/img/example-nb/nose_testing.png"
},
{
"text": "Working with pandas",
"target": "gist/twiecki/3962843",
"img": "/static/img/example-nb/working_with_pandas.png"
},
{
"text": "Fitting",
"target": "gist/keflavich/4042018",
"img": "/static/img/example-nb/fitting.png"
},
{
"text": "Analysis of current events",
"target": "gist/darribas/4121857",
"img": "/static/img/example-nb/gaza.png"
},
{
"text": "Jaynes-Cummings model",
"target": "github/jrjohansson/qutip-lectures/blob/master/Lecture-1-Jaynes-Cumming-model.ipynb",
"img": "/static/img/example-nb/jaynes-cummings.png"
},
{
"text": "SymPy notebook",
"target": "github/ipython/ipython/blob/master/examples/notebooks/SymPy Examples.ipynb",
"img": "/static/img/example-nb/sympy.png"
},
{
"text": "Numpy tests",
"target": "gist/Juanlu001/3914904",
"img": "/static/img/example-nb/numpy_tests.png"
},
{
"text": "R magic extension",
"target": "github/ipython/ipython/blob/master/examples/notebooks/R Magics.ipynb",
"img": "/static/img/example-nb/r_magic.png"
}
]
}
]
8 changes: 7 additions & 1 deletion nbviewer/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import base64
import hashlib
import json
import os
import io
import socket
import time

Expand Down Expand Up @@ -245,11 +247,15 @@ class Custom404(BaseHandler):
def prepare(self):
raise web.HTTPError(404)

this_dir, this_filename = os.path.split(__file__)
DATA_PATH = os.path.join(this_dir , "frontpage.json")
with io.open(DATA_PATH, 'r') as datafile:
sections = json.load(datafile)

class IndexHandler(BaseHandler):
"""Render the index"""
def get(self):
self.finish(self.render_template('index.html'))
self.finish(self.render_template('index.html',sections=sections))


class FAQHandler(BaseHandler):
Expand Down
Binary file not shown.
Binary file removed nbviewer/static/img/example-nb/blogging.png
Binary file not shown.
Binary file removed nbviewer/static/img/example-nb/cython.png
Binary file not shown.
Binary file modified nbviewer/static/img/example-nb/data-cleanup.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed nbviewer/static/img/example-nb/demo.png
Binary file not shown.
Binary file modified nbviewer/static/img/example-nb/ip-examples-list.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added nbviewer/static/img/example-nb/ipython-thumb.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added nbviewer/static/img/example-nb/iruby-nb.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added nbviewer/static/img/example-nb/python-signal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions nbviewer/static/img/example-nb/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Images for frontpage

This contain images for the frontpage of nbviewer.

at most thoses images will be show with a size of 360x225 (W x H), aspect ratio
(W/H) of 1.6. As they might be show on retina display, consider using a double
resolution. Resizing will be handled by browser, so to avoid artifact images
shoudl be of size multiple of maximum size ie (720 width) by (450 height),
preferentially in png, and passed to png crusher as the number of request for
thoses images will be heigh.


Binary file removed nbviewer/static/img/example-nb/slideshow.png
Binary file not shown.
Binary file removed nbviewer/static/img/example-nb/social-web.jpg
Binary file not shown.
Binary file removed nbviewer/static/img/example-nb/tide.png
Binary file not shown.
Binary file removed nbviewer/static/img/example-nb/xkcd2.png
Binary file not shown.
2 changes: 1 addition & 1 deletion nbviewer/templates/400.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<p>We couldn't render your notebook</p>
<p class="marketing-byline">Perhaps it is not valid JSON, or not the right URL?</p>
<p class="marketing-byline"> If this should be a working notebook, please send us a bug report!</p>
<p class="marketing-byline">If this should be a working notebook, please send us a bug report! Don't forget to read the <a href='/faq'>FAQ</a> if you are not sure !</p>
{% if message %}
<p class="marketing-byline">The error was: {{message}}</p>
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions nbviewer/templates/404.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{% extends "error.html" %}
{% block error_detail %}
<p>You are requesting a page that does not exist!</p>
<p>You are requesting a page that does not exist! Read the <a href='/faq'>FAQ</a> for more information.</p>
{% if 'HTTP 404' in message %}
<p class="marketing-byline">The remote resource was not found.</p>
<p class="marketing-byline">The remote resource was not found. </p>
{% elif message %}
<p class="marketing-byline">{{message}}</p>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion nbviewer/templates/500.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{% block error_detail %}
<p>You broke the internet!</p>
<p class="marketing-byline">Kidding, this might just be an intermittent failure in nbviewer.</p>
<p class="marketing-byline"> If this is reproducible, please <a href="https://github.com/ipython/nbviewer/issues">send us a bug report</a>!</p>
<p class="marketing-byline"> If this is reproducible, please <a href="https://github.com/ipython/nbviewer/issues">send us a bug report</a>! Don't forget to read the <a href='/faq'>FAQ</a> before!</p>
{% if message %}
<p class="marketing-byline">The upstream error was {{message}}</p>
{% endif %}
Expand Down
95 changes: 68 additions & 27 deletions nbviewer/templates/faq.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,57 @@
{% extends "layout.html" %}

{% block body %}
{% filter markdown %}

<style>

.container{
max-width:700px;
}

p {
text-align:justify;
}

</style>

{% filter markdown(extensions=['headerid(level=3)','toc'], extension_configs= {'toc' : [('anchorlink', True)]}) %}

# Frequently Asked Questions

[TOC]

### What is nbviewer?

IPython Notebook Viewer (or nbviewer in short) is a free webservice that allows you
to see **static html** versions of hosted notebook files.
As long as a notebook is **publicly** available,
by giving its url to nbviewer you should be able to view it.
IPython Notebook Viewer (or nbviewer in short) is a free webservice that allows
you to see **static html** versions of hosted notebook files. As long as a
notebook is **publicly** available, by giving its url to nbviewer you should be
able to view it.

You can also directly browse collections of notebooks through github repositories directly on nbviewer


### I've got a 5xx/4xx error on a notebook.

Nbviewer tries to get notebooks from the url given. If the remote location
doesn't respond or the file nbviewer receives is not valid, you will get an
error (4xx). Check that the remote file still exists and that you can convert
it locally with nbconvert.


### How do you render notebooks?

Nbviewer uses IPython's `nbconvert` to export `.ipynb` to HTML.

If you have IPython installed you can have access to the same functionality
and many more formats by invoking
`ipython nbconvert` at a command line. Starting in IPython 2.0 you should be
able to export notebooks in other formats using the `file` menu in the IPython
notebook application.

### Where is nbviewer hosted?

Nbviewer is hosted on [Rackspace](http://rackspace.com) who kindly gives the IPython open source
project hosting. Thanks to them we are able to offer nbconvert as a service for free.

### I want to remove/update a notebook on nbviewer.

Expand All @@ -31,16 +72,24 @@ which are full blown [git](http://git-scm.com/) repositories.
### Can I share notebooks from a private GitHub repository?

No, you can't, but we are working on it. We'll be happy to have any help you can give us.
In the meantime, you can use a secret gist if you wish.
In the meantime, you can use a secret gist if you wish. You might be interested in running nbviewer
on your own machine or inside your network.

### Images do not show in nbviewer!
### Can I run my own nbviewer?

Did you upload your images next to the ipynb file you are sharing? Perhaps
you used the incorrect absolute `/files/` prefix instead of the relative `files/`?
We do our best so that you can run it locally or on the cloud.
Please visit the [nbviewer github repository](https://github.com/ipython/nbviewer) for instructions.

### Can I access nbviewer over https?

You can, but you will probably get a warning that the website does not have a valid
certificate. We are not sure it is worth paying for an SSL certificate as
nbviewer should not expose any sensitive information. If you need to embed an html notebook
on another site, please use local export with nbconvert.

### There is a broken link.

Is the broken link on a notebook? If so, I suggest you contact the original author.
Is the broken link on a notebook? If so, we suggest you contact the original author.
Otherwise, please open an issue on [our issue tracker](https://github.com/ipython/nbviewer/issues)
with the link to the broken page, and tell us which link is broken.
We'll do our best to fix it.
Expand All @@ -51,28 +100,20 @@ Featured notebooks are notebooks we found that we like. If you think some
should be removed, or others that should be added, feel free to contact us.
The best way would be to directly submit a pull request on GitHub.

### Can I convert my notebook to something other than HTML?

If you want to convert a notebook file to another format,
you should have a look at [nbconvert](https://github.com/ipython/nbconvert).
It is the notebook conversion library used by nbviewer,
and supports many more customizations and formats than what is used by nbviewer.

## More questions

### Can I run my own nbviewer?

Yes, please visit the [nbviewer github repository](https://github.com/ipython/nbviewer) for instructions.

### How can I contribute?

You can submit pull request to [nbviewer github repository](https://github.com/ipython/nbviewer),
or [make a donation to ipython] so that we can pay for hosting and work on awesome features.
You can submit a pull request to [the nbviewer github repository](https://github.com/ipython/nbviewer),
or [make a donation to ipython](http://ipython.org/donate.html) so that we can work on more awesome features.

### Can I use nbviewer to convert my notebook to something else than html?

### Are there easter eggs on nbviewer?
For the time being, no. We would like to allow that in the future. You can
already use a `ipython nbconvert` to export to most formats. You can still help
us by making a donation or contributing with your time.

Yes, you'll probably need more than your mouse to find them.
# I have more questions...

If something was not clear or not present, do not hesitate to reach out to the [IPython mailing list](http://mail.scipy.org/mailman/listinfo/ipython-dev) or [make an issue on github](http://github.com/ipython/nbviewer/issues).

{% endfilter %}
{% endblock %}

0 comments on commit e3a7f5b

Please sign in to comment.