Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:jamalex/ka-lite into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jamalex committed Jan 9, 2013
2 parents bba9f1c + 381aa77 commit fceb43e
Show file tree
Hide file tree
Showing 11 changed files with 187,651 additions and 69,226 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ virtualenv/
*.pid
mergetomaster.sh
videos/
content/*
content/*.jpg
content/*.png
content/*.mp4
content/*.json
content/*.srt
35 changes: 34 additions & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ You will be completing the following steps:
4. Run the installation script to complete configuration
5. Run the server

Jump to below for [Windows installation instructions](#installing-on-windows).
Jump to below for [Windows installation instructions](#installing-on-windows) or [Mac OS X installation instructions](#installing-on-mac-os-x).

Installing on Linux
===
Expand Down Expand Up @@ -87,6 +87,39 @@ If at any point you see a "Windows Security Alert" [warning about Windows Firewa
The local KA Lite website should now be accessible at [http://127.0.0.1:8008/](http://127.0.0.1:8008/) (replace 127.0.0.1 with your computer's external ip address or domain to access it from another connected computer).


Installing on Mac OS X
===

### 1. Install Python

Python comes pre-installed on Mac OS X, but due to Apple's release cycle, it's often one or even two years old. To check that you have got a usable version, run `python -V` from the command line (in Terminal from Applications/Utilities), and ensure that the version number starts with 2.6, or 2.7. If it is not a usable version ([download Python 2.7](http://www.python.org/download/releases/2.7.3/)). On 32-bit or 64-bit non PPC Mac OS X 10.6 or higher, use the [64-bit/32-bit x86-64/i386 Installer](http://www.python.org/ftp/python/2.7.3/python-2.7.3-macosx10.6.dmg), and on PPC or 32-bit i386 Mac OS X 10.3-10.6, use the [32-bit i386/PPC Installer](http://www.python.org/ftp/python/2.7.3/python-2.7.3-macosx10.3.dmg).


### 2. Install git

Install the latest version of [Git for OS X](http://code.google.com/p/git-osx-installer/downloads/list?can=3&q=&sort=-uploaded).

### 3. Download KA Lite

Clone the repository into a directory of your choice. Use `cd` to navigate into the target directory (the files will be put into a subdirectory of your current directory named `ka-lite`), and then run:

`git clone --recursive https://github.com/jamalex/ka-lite.git`

(The `--recursive` is required because it includes [khan-exercises](https://github.com/Khan/khan-exercises) as a git submodule.)

### 4. Run the installation script

Inside the `ka-lite` directory (that you cloned above) you should find a script called `install.sh`. Use `cd ka-lite` to navigate into the directory, and run this script using `./install.sh` to initialize the server database.

### 5. Run the server

(If you're installing the server to test/develop, rather than deploy, follow the [development instructions](docs/DEVELOPMENT.md) instead.)

To start the server, run the `start.sh` script in the `ka-lite` directory.

The local KA Lite website should now be accessible at [http://127.0.0.1:8008/](http://127.0.0.1:8008/) (replace 127.0.0.1 with your computer's external ip address or domain to access it from another connected computer).


Optional: Install and configure Apache/mod_wsgi
===

Expand Down
1 change: 1 addition & 0 deletions content/note.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is where content files (jpg, mp4, png, and json) should be. If you are copying content from a downloaded torrent file or a USB stick, the files should be put in here.
11 changes: 11 additions & 0 deletions kalite/static/css/khan-lite.css
Original file line number Diff line number Diff line change
Expand Up @@ -480,3 +480,14 @@ li .progress-circle {
margin-left: -5px;
margin-right: -5px;
}

.thumb {
overflow: hidden;
position: relative;
}

.thumb .thumbimage {
position: absolute;
width: 200px;
z-index: -10;
}
25,135 changes: 16,962 additions & 8,173 deletions kalite/static/data/nodecache.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion kalite/static/data/topicdata/exponents-radicals.json

Large diffs are not rendered by default.

231,659 changes: 170,623 additions & 61,036 deletions kalite/static/data/topics.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion kalite/templates/exercise.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ <h2>
<li>
<div class="thumbnail">
<a class="related-video" href="{{ video.path }}" title="{{ video.title }}" target="_blank">
<div class="thumb" style="background-image: url({{ CONTENT_ROOT }}{{ video.youtube_id }}.jpg); ">
<div class="thumb">
<img class="thumbimage" src="{{ CONTENT_URL }}{{ video.youtube_id }}.png"/>
<div class="thumbnail_label" style="margin-top: 68px; ">
<div class="thumbnail_desc">
<span class="progress-circle" data-youtube-id="{{ video.youtube_id }}"></span>
Expand Down
2 changes: 1 addition & 1 deletion kalite/utils/subtitles.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"X-apikey": "",
}

base_url = "https://amara.org/api2/partners/videos"
base_url = "https://www.universalsubtitles.org/api2/partners/videos"

class NoSubs(Exception):

Expand Down
6 changes: 5 additions & 1 deletion kalite/utils/topic_tools.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import glob
from main import topicdata

def find_videos_by_youtube_id(youtube_id, node=topicdata.TOPICS):
Expand Down Expand Up @@ -25,4 +26,7 @@ def get_dups(threshold=2):
def print_videos(youtube_id):
print "Videos with YouTube ID '%s':" % youtube_id
for node in find_videos_by_youtube_id(youtube_id):
print " > ".join(node["path"].split("/")[1:-3] + [node["title"]])
print " > ".join(node["path"].split("/")[1:-3] + [node["title"]])

def get_downloaded_youtube_ids():
return [path.split("/")[-1].split(".")[0] for path in glob.glob("../../content/*.mp4")]
17 changes: 6 additions & 11 deletions kalite/utils/videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,14 @@ def download_video(youtube_id, format="mp4", callback=None):
filepath = download_path + video_filename
url = download_url % (video_filename, video_filename)

large_thumb_filename = "%(id)s.png" % {"id": youtube_id}
large_thumb_filepath = download_path + large_thumb_filename
large_thumb_url = download_url % (video_filename, large_thumb_filename)

thumb_filepath = download_path + youtube_id + ".jpg"
thumb_url = "http://img.youtube.com/vi/%(id)s/hqdefault.jpg" % {"id": youtube_id}

thumb_filename = "%(id)s.png" % {"id": youtube_id}
thumb_filepath = download_path + thumb_filename
thumb_url = download_url % (video_filename, thumb_filename)

try:
download_file(url, filepath, callback_percent_proxy(callback, end_percent=91))
download_file(url, filepath, callback_percent_proxy(callback, end_percent=95))

download_file(large_thumb_url, large_thumb_filepath, callback_percent_proxy(callback, start_percent=91, end_percent=96))

download_file(thumb_url, thumb_filepath, callback_percent_proxy(callback, start_percent=96, end_percent=100))
download_file(thumb_url, thumb_filepath, callback_percent_proxy(callback, start_percent=95, end_percent=100))

except DownloadCancelled:
delete_downloaded_files(youtube_id)
Expand Down

0 comments on commit fceb43e

Please sign in to comment.