コード例 #1
0
ファイル: views.py プロジェクト: okute/ProfessionalWebsite
def blog_post(request, name):
    """
      Builds a page containing a single blog post

        @param  name    The name of the post
    """

    # Get all posts, from most recent to least recent
    post = Post.objects.get(name=name)

    # The HTML template
    template = get_template('pages/blog_post.html')

    # HTML Data for this page
    html = template.render(
        Context({
            'meta_description':
            'Jon Tedesco\'s blog · Jon Tedesco\'s collection of thoughts and experiences of his geeky endeavors.',
            'meta_keywords':
            ' '.join([
                "blog", "discussion", "geek", "projects", "software",
                "projects"
            ] + get_generic_keywords()),
            'page_title':
            'Blog · Jon Tedesco · ' + post.title,
            'word_cloud_name':
            'blog',
            'server_root':
            get_server_root(),
            'post':
            post
        }))

    return HttpResponse(html)
コード例 #2
0
ファイル: views.py プロジェクト: okute/ProfessionalWebsite
def research(request):
    """
      Builds and returns the research page of the site
    """

    # The HTML template
    template = get_template('pages/research.html')

    # HTML Data for this page
    html = template.render(
        Context({
            'meta_description':
            'Jon Tedesco\'s research · Research interests, projects, and papers',
            'meta_keywords':
            ' '.join(["research", "papers", "interests", "projects"] +
                     get_generic_keywords()),
            'page_title':
            'Research · Jon Tedesco',
            'word_cloud_name':
            'research',
            'server_root':
            get_server_root()
        }))

    return HttpResponse(html)
コード例 #3
0
ファイル: views.py プロジェクト: okute/ProfessionalWebsite
def about_me(request):
    """
      Builds and returns the homepage of the site
    """

    # The HTML template
    template = get_template('pages/about_me.html')

    # HTML Data for this page
    html = template.render(
        Context({
            'meta_description':
            'Information for Jon Tedesco, a dedicated student and avid software developer at University'
            + 'of Illinois at Urbana-Champaign',
            'meta_keywords':
            ' '.join(get_generic_keywords()),
            'page_title':
            'About Me · Jon Tedesco',
            'word_cloud_name':
            'about_me',
            'static':
            True,
            'server_root':
            get_server_root()
        }))

    return HttpResponse(html)
コード例 #4
0
ファイル: views.py プロジェクト: jtedesco/ProfessionalWebsite
def project(request, name):
    """
      Builds a page containing information about a given project

        @param  name    The name of the project
    """

    project = Project.objects.get(name=name)

    # The HTML template
    template = get_template('pages/project.html')

    # HTML Data for this page
    html = template.render(Context({
        'meta_description': 'Jon Tedesco\'s "%s" project · Description, demos, and source code of Jon Tedesco\'s geeky projects' % project.title
        ,
        'meta_keywords': ' '.join(["projects", "experience", "technology", "current", "past", "github", "sockit",
                                   "skills"] + get_generic_keywords()),
        'page_title': 'Projects · Jon Tedesco ·' + project.title,
        'word_cloud_name': 'projects',
        'server_root': get_server_root(),
        'static': True,
        'project': project
    }))

    return HttpResponse(html)
コード例 #5
0
ファイル: views.py プロジェクト: jtedesco/ProfessionalWebsite
def blog_post(request, name):
    """
      Builds a page containing a single blog post

        @param  name    The name of the post
    """

    # Get all posts, from most recent to least recent
    post = Post.objects.get(name=name)

    # The HTML template
    template = get_template('pages/blog_post.html')

    # HTML Data for this page
    html = template.render(Context({
        'meta_description': 'Jon Tedesco\'s blog · Jon Tedesco\'s collection of thoughts and experiences of his geeky endeavors.'
        ,
        'meta_keywords': ' '.join(
            ["blog", "discussion", "geek", "projects", "software", "projects"] + get_generic_keywords()),
        'page_title': 'Blog · Jon Tedesco · ' + post.title,
        'word_cloud_name': 'blog',
        'server_root': get_server_root(),
        'post': post
    }))

    return HttpResponse(html)
コード例 #6
0
def insert_document(index_writer, title, url, name):
    """
        Insert a given document into the index.

            @param  index_writer    A writer to access the text index
            @param  title           The title of this document
            @param  url             The url of this page
            @param  name
    """

    # Grab the content of the file
    subprocess.call(["wget", url])
    content = subprocess.check_output(["cat", name])
    subprocess.call(["rm", name])

    # Remove all HTML tags from content (clean to plain text)
    parsed_content = content.replace("<br/>", "\n")
    closing_tag_re = re.compile("</.*?>")
    tag_re = re.compile("<.*?>")
    white_space_re = re.compile("\s+")
    parsed_content = closing_tag_re.sub("\n", parsed_content)
    parsed_content = tag_re.sub(" ", parsed_content)
    parsed_content = white_space_re.sub(" ", parsed_content)
    parsed_content = unicode(parsed_content, 'utf-8')

    # Parse out the title
    try:
        title = unicode(title.replace(".html", ""), 'utf-8')
    except Exception:
        pass

    # Put this content into index
    actualUrl = url.replace(get_server_root(), 'http://jontedesco.net/')
    index_writer.add_document(content=parsed_content, title=title.title(), url=unicode(actualUrl))
コード例 #7
0
ファイル: views.py プロジェクト: okute/ProfessionalWebsite
def resume(request):
    """
      Builds and returns the resume page of the site
    """

    # The HTML template
    template = get_template('pages/resume.html')

    # HTML Data for this page
    html = template.render(
        Context({
            'meta_description':
            "Jon Tedesco's r&eacute;sum&eacute; (resume) &#183; My education, experience,skills, coursework, papers, and awards",
            'meta_keywords':
            ' '.join([
                "resume", "education", "experience", "skills", "coursework",
                "papers", "awards"
            ] + get_generic_keywords()),
            'page_title':
            'R&eacute;sum&eacute; &#183; Jon Tedesco',
            'word_cloud_name':
            'resume',
            'server_root':
            get_server_root()
        }))

    return HttpResponse(html)
コード例 #8
0
def navigate_source(request, path, project):
    """
        View the contents of a directory, and provide a simple interface with which to navigate the directory
        structure, and view the source of files in the hierarchy.

            @param  path    The path, relative to the root of the site, to display
            @param  project The name of the source project we're viewing
    """

    # Setup data structures
    root = get_root_directory() + '/code/'
    files = []
    directories = []

    # Collect the files & directories separately
    for file in os.listdir(root + path):
        # Add directories and files to separate lists
        if os.path.isfile(root + path + "/" + file):
            files.append((path + "/" + file, file))
        elif os.path.isdir(root + path):
            directories.append((path + "/" + file, file))

    try:
        # Try to read the 'exclude' file
        if os.path.exists(root + path + '/' + '.exclude'):
            exclude_file = open(root + path + '/' + '.exclude', 'r')

            # Remove the files or directories from the list gathered
            for exclude_file_name in exclude_file:
                exclude_file_name = exclude_file_name.strip()
                exclude_path = path + '/' + exclude_file_name
                if os.path.exists(root + exclude_path):
                    if os.path.isdir(root + exclude_path):
                        directories.remove(exclude_path)
                    else:
                        files.remove(exclude_path)
                else:
                    print "Error parsing exclude file, could not open path '%s'" % exclude_path

    except Exception:
        print "Error parsing 'exclude' file: '%s'" % str(sys.exc_info()[1])

    # Fill HTML template
    template = get_template('pages/navigate_source.html')
    html = template.render(Context({
        'meta_description': 'Homepage of Jon Tedesco, a dedicated student and avid software developer at University' +
                            'of Illinois at Urbana-Champaign',
        'meta_keywords': ' '.join(get_generic_keywords()),
        'page_title': 'Navigate Source &#183; ' + project,
        'word_cloud_name': 'about_me',
        'server_root': get_server_root(),
        'path': path,
        'project': project,
        'files': files,
        'static': True,
        'directories': directories
    }))
    return HttpResponse(html)
コード例 #9
0
ファイル: views.py プロジェクト: okute/ProfessionalWebsite
def projects(request):
    """
      Builds the projects page
    """

    # Get all projects, ordered by ID & grouped by active/inactive
    projects = list(Project.objects.extra(order_by=['-active', '-id']))

    # Split the projects ilnto chunks of 5 and add 'next' pointers
    chunkedProjects = list(chunks(projects, 5))
    for projectChunk in chunkedProjects:
        for projectIndex in xrange(0, len(projectChunk) - 1):
            projectChunk[projectIndex].next = projectChunk[projectIndex + 1]
        projectChunk[len(projectChunk) - 1].next = None

    # Split projects into numbered pages
    pages = []
    num = 1
    for projectChunk in chunkedProjects:
        pages.append({'projects_list': projectChunk, 'number': num})
        num += 1

    # The HTML template
    template = get_template('pages/projects.html')

    # HTML Data for this page
    html = template.render(
        Context({
            'meta_description':
            'Jon Tedesco\'s projects &#183; Description, demos, and source code of Jon Tedesco\'s geeky projects',
            'meta_keywords':
            ' '.join([
                "projects", "experience", "technology", "github", "sockit",
                "skills"
            ] + get_generic_keywords()),
            'page_title':
            'Projects &#183; Jon Tedesco',
            'word_cloud_name':
            'projects',
            'server_root':
            get_server_root(),
            'pages':
            pages,
            'number_of_pages':
            len(list(pages))
        }))

    return HttpResponse(html)
コード例 #10
0
ファイル: views.py プロジェクト: jtedesco/ProfessionalWebsite
def research(request):
    """
      Builds and returns the research page of the site
    """

    # The HTML template
    template = get_template('pages/research.html')

    # HTML Data for this page
    html = template.render(Context({
        'meta_description': 'Jon Tedesco\'s research &#183; Research interests, projects, and papers',
        'meta_keywords': ' '.join(["research", "papers", "interests", "projects"] + get_generic_keywords()),
        'page_title': 'Research &#183; Jon Tedesco',
        'word_cloud_name': 'research',
        'server_root': get_server_root()
    }))

    return HttpResponse(html)
コード例 #11
0
ファイル: views.py プロジェクト: okute/ProfessionalWebsite
def blog(request):
    """

    """

    # Get all posts, from most recent to least recent
    posts = list(Post.objects.extra(order_by=['-timestamp']))

    chunkedPosts = chunks(posts, 2)

    # Split posts into numbered pages
    pages = []
    num = 1
    for postChunk in chunkedPosts:
        pages.append({'posts_list': postChunk, 'number': num})
        num += 1

    # The HTML template
    template = get_template('pages/blog.html')

    # HTML Data for this page
    html = template.render(
        Context({
            'meta_description':
            'Jon Tedesco\'s blog &#183; Jon Tedesco\'s collection of thoughts and experiences of his geeky endeavors.',
            'meta_keywords':
            ' '.join([
                "blog", "discussion", "geek", "projects", "software",
                "projects"
            ] + get_generic_keywords()),
            'page_title':
            'Blog &#183; Jon Tedesco',
            'word_cloud_name':
            'blog',
            'server_root':
            get_server_root(),
            'pages':
            pages,
            'number_of_pages':
            len(list(pages))
        }))

    return HttpResponse(html)
コード例 #12
0
ファイル: views.py プロジェクト: jtedesco/ProfessionalWebsite
def projects(request):
    """
      Builds the projects page
    """

    # Get all projects, ordered by ID & grouped by active/inactive
    projects = list(Project.objects.extra(order_by=['-active', '-id']))

    # Split the projects ilnto chunks of 5 and add 'next' pointers
    chunkedProjects = list(chunks(projects, 5))
    for projectChunk in chunkedProjects:
        for projectIndex in xrange(0, len(projectChunk)-1):
            projectChunk[projectIndex].next = projectChunk[projectIndex+1]
        projectChunk[len(projectChunk)-1].next = None

    # Split projects into numbered pages
    pages = []
    num = 1
    for projectChunk in chunkedProjects:
        pages.append({
            'projects_list': projectChunk,
            'number': num
        })
        num += 1

    # The HTML template
    template = get_template('pages/projects.html')

    # HTML Data for this page
    html = template.render(Context({
        'meta_description': 'Jon Tedesco\'s projects &#183; Description, demos, and source code of Jon Tedesco\'s geeky projects'
        ,
        'meta_keywords': ' '.join(["projects", "experience", "technology", "github", "sockit",
                                   "skills"] + get_generic_keywords()),
        'page_title': 'Projects &#183; Jon Tedesco',
        'word_cloud_name': 'projects',
        'server_root': get_server_root(),
        'pages': pages,
        'number_of_pages': len(list(pages))
    }))

    return HttpResponse(html)
コード例 #13
0
ファイル: views.py プロジェクト: jtedesco/ProfessionalWebsite
def about_me(request):
    """
      Builds and returns the homepage of the site
    """

    # The HTML template
    template = get_template('pages/about_me.html')

    # HTML Data for this page
    html = template.render(Context({
        'meta_description': 'Information for Jon Tedesco, a dedicated student and avid software developer at University' +
                            'of Illinois at Urbana-Champaign',
        'meta_keywords': ' '.join(get_generic_keywords()),
        'page_title': 'About Me &#183; Jon Tedesco',
        'word_cloud_name': 'about_me',
        'static': True,
        'server_root': get_server_root()
    }))

    return HttpResponse(html)
コード例 #14
0
ファイル: views.py プロジェクト: jtedesco/ProfessionalWebsite
def resume(request):
    """
      Builds and returns the resume page of the site
    """

    # The HTML template
    template = get_template('pages/resume.html')

    # HTML Data for this page
    html = template.render(Context({
        'meta_description': "Jon Tedesco's r&eacute;sum&eacute; (resume) &#183; My education, experience,skills, coursework, papers, and awards"
        ,
        'meta_keywords': ' '.join(
            ["resume", "education", "experience", "skills", "coursework", "papers", "awards"] + get_generic_keywords()),
        'page_title': 'R&eacute;sum&eacute; &#183; Jon Tedesco',
        'word_cloud_name': 'resume',
        'server_root': get_server_root()
    }))

    return HttpResponse(html)
コード例 #15
0
ファイル: views.py プロジェクト: jtedesco/ProfessionalWebsite
def blog(request):
    """

    """

    # Get all posts, from most recent to least recent
    posts = list(Post.objects.extra(order_by=['-timestamp']))

    chunkedPosts = chunks(posts, 2)

    # Split posts into numbered pages
    pages = []
    num = 1
    for postChunk in chunkedPosts:
        pages.append({
            'posts_list': postChunk,
            'number': num
        })
        num += 1

    # The HTML template
    template = get_template('pages/blog.html')

    # HTML Data for this page
    html = template.render(Context({
        'meta_description': 'Jon Tedesco\'s blog &#183; Jon Tedesco\'s collection of thoughts and experiences of his geeky endeavors.'
        ,
        'meta_keywords': ' '.join(
            ["blog", "discussion", "geek", "projects", "software", "projects"] + get_generic_keywords()),
        'page_title': 'Blog &#183; Jon Tedesco',
        'word_cloud_name': 'blog',
        'server_root': get_server_root(),
        'pages': pages,
        'number_of_pages': len(list(pages))
    }))

    return HttpResponse(html)
コード例 #16
0
ファイル: views.py プロジェクト: okute/ProfessionalWebsite
def project(request, name):
    """
      Builds a page containing information about a given project

        @param  name    The name of the project
    """

    project = Project.objects.get(name=name)

    # The HTML template
    template = get_template('pages/project.html')

    # HTML Data for this page
    html = template.render(
        Context({
            'meta_description':
            'Jon Tedesco\'s "%s" project &#183; Description, demos, and source code of Jon Tedesco\'s geeky projects'
            % project.title,
            'meta_keywords':
            ' '.join([
                "projects", "experience", "technology", "current", "past",
                "github", "sockit", "skills"
            ] + get_generic_keywords()),
            'page_title':
            'Projects &#183; Jon Tedesco &#183;' + project.title,
            'word_cloud_name':
            'projects',
            'server_root':
            get_server_root(),
            'static':
            True,
            'project':
            project
        }))

    return HttpResponse(html)
コード例 #17
0
ファイル: search.py プロジェクト: okute/ProfessionalWebsite
def insert_document(index_writer, title, url, name):
    """
        Insert a given document into the index.

            @param  index_writer    A writer to access the text index
            @param  title           The title of this document
            @param  url             The url of this page
            @param  name
    """

    # Grab the content of the file
    subprocess.call(["wget", url])
    content = subprocess.check_output(["cat", name])
    subprocess.call(["rm", name])

    # Remove all HTML tags from content (clean to plain text)
    parsed_content = content.replace("<br/>", "\n")
    closing_tag_re = re.compile("</.*?>")
    tag_re = re.compile("<.*?>")
    white_space_re = re.compile("\s+")
    parsed_content = closing_tag_re.sub("\n", parsed_content)
    parsed_content = tag_re.sub(" ", parsed_content)
    parsed_content = white_space_re.sub(" ", parsed_content)
    parsed_content = unicode(parsed_content, 'utf-8')

    # Parse out the title
    try:
        title = unicode(title.replace(".html", ""), 'utf-8')
    except Exception:
        pass

    # Put this content into index
    actualUrl = url.replace(get_server_root(), 'http://jontedesco.net/')
    index_writer.add_document(content=parsed_content,
                              title=title.title(),
                              url=unicode(actualUrl))
コード例 #18
0
def search(request, query):
    """
      Search the page using Whoosh

        @param  query   The query to search
    """

    # Prepare defaults
    title = "Jon Tedesco &#183; Search"

    # Run query
    if query is not None and len(query.strip()) > 0:
        # Convert the query to unicode
        try:
            query = unicode(query, 'utf-8')
        except Exception:
            # Skip if already unicode
            pass

        # Run the query & get the stats
        start_time = datetime.now()
        search_results, search_terms, spelling_suggestions, number_of_results = run_query(query, index)
        end_time = datetime.now()
        time = "%1.3f" % (float((end_time - start_time).microseconds) / 1000000.0)

        # Parse out the most likely spelling suggestion
        try:
            spelling_suggestion = spelling_suggestions[0][0]
        except Exception:
            spelling_suggestion = None

        # Update the title
        title += " &#183; '%s'" % query

    else:
        # Gracefully fail if someone gets to this page without a query
        spelling_suggestion = None
        time = None
        number_of_results = None
        search_results = None

    # Fill in the search template
    template = get_template('pages/search.html')

    # HTML Data for this page
    html = template.render(Context({
        'meta_description': 'Homepage of Jon Tedesco, a dedicated student and avid software developer at University' +
                            'of Illinois at Urbana-Champaign',
        'meta_keywords': ' '.join(get_generic_keywords()),
        'page_title': title,
        'word_cloud_name': 'about_me',
        'server_root': get_server_root(),
        'query': query,
        'time': time,
        'search_results': search_results,
        'number_of_results': number_of_results,
        'spelling_suggestion': spelling_suggestion

    }))

    response = HttpResponse(html)
    return response
コード例 #19
0
def view_source(request, path):
    """
        View the source code of the given file, in the standard <code>view_source</code> template.

            @param  path    The path of the file to display (relative to the root of the site)
    """

    languages = {
        "py": "python",
        "rb": "ruby",
        "js": "javascript",
        "html": "html",
        "htm": "html",
        "cpp": "cpp",
        "c": "c",
        "cc": "cpp",
        "php": "php",
        "java": "java",
        "xml": "xml"
    }

    # Read the source code file
    try:
        source_file = open(get_root_directory() + "/code/" + path, 'r')
        source_code = source_file.read()
        source_file.close()

        # Data structure to hold information for this page
        data = {
            'meta_description':
            'Homepage of Jon Tedesco, a dedicated student and avid software developer at University'
            + 'of Illinois at Urbana-Champaign',
            'meta_keywords':
            ' '.join(get_generic_keywords()),
            'page_title':
            'View Source &#183; %s (%s)',
            'word_cloud_name':
            'about_me',
            'server_root':
            get_server_root(),
            'static':
            True,
            'path':
            None,
            'language':
            None,
            'content':
            None
        }

        # Check if this is a binary file
        binary_file_extensions = ['jpg', 'png', 'bmp', 'jpeg']
        file_extension = path[path.rfind('.') + 1:]
        if file_extension not in binary_file_extensions:
            # Update data
            data['content'] = source_code
            if file_extension in languages:
                data['language'] = languages[file_extension]
            else:
                data['language'] = 'plain'
            data['path'] = path
            data['page_title'] = data['page_title'] % (
                path, data['language'].title())

        else:
            data['path'] = path
            data['page_title'] = 'View Source &#183; ' + path
            data['image'] = True

        # Fill HTML template
        template = get_template('pages/view_source.html')
        html = template.render(Context(data))
        return HttpResponse(html)

    except IOError:

        # Throw a 404 if the file can't be read
        raise Http404
コード例 #20
0
ファイル: search.py プロジェクト: okute/ProfessionalWebsite
def search(request, query):
    """
      Search the page using Whoosh

        @param  query   The query to search
    """

    # Prepare defaults
    title = "Jon Tedesco &#183; Search"

    # Run query
    if query is not None and len(query.strip()) > 0:
        # Convert the query to unicode
        try:
            query = unicode(query, 'utf-8')
        except Exception:
            # Skip if already unicode
            pass

        # Run the query & get the stats
        start_time = datetime.now()
        search_results, search_terms, spelling_suggestions, number_of_results = run_query(
            query, index)
        end_time = datetime.now()
        time = "%1.3f" % (float(
            (end_time - start_time).microseconds) / 1000000.0)

        # Parse out the most likely spelling suggestion
        try:
            spelling_suggestion = spelling_suggestions[0][0]
        except Exception:
            spelling_suggestion = None

        # Update the title
        title += " &#183; '%s'" % query

    else:
        # Gracefully fail if someone gets to this page without a query
        spelling_suggestion = None
        time = None
        number_of_results = None
        search_results = None

    # Fill in the search template
    template = get_template('pages/search.html')

    # HTML Data for this page
    html = template.render(
        Context({
            'meta_description':
            'Homepage of Jon Tedesco, a dedicated student and avid software developer at University'
            + 'of Illinois at Urbana-Champaign',
            'meta_keywords':
            ' '.join(get_generic_keywords()),
            'page_title':
            title,
            'word_cloud_name':
            'about_me',
            'server_root':
            get_server_root(),
            'query':
            query,
            'time':
            time,
            'search_results':
            search_results,
            'number_of_results':
            number_of_results,
            'spelling_suggestion':
            spelling_suggestion
        }))

    response = HttpResponse(html)
    return response
コード例 #21
0
def navigate_source(request, path, project):
    """
        View the contents of a directory, and provide a simple interface with which to navigate the directory
        structure, and view the source of files in the hierarchy.

            @param  path    The path, relative to the root of the site, to display
            @param  project The name of the source project we're viewing
    """

    # Setup data structures
    root = get_root_directory() + '/code/'
    files = []
    directories = []

    # Collect the files & directories separately
    for file in os.listdir(root + path):
        # Add directories and files to separate lists
        if os.path.isfile(root + path + "/" + file):
            files.append((path + "/" + file, file))
        elif os.path.isdir(root + path):
            directories.append((path + "/" + file, file))

    try:
        # Try to read the 'exclude' file
        if os.path.exists(root + path + '/' + '.exclude'):
            exclude_file = open(root + path + '/' + '.exclude', 'r')

            # Remove the files or directories from the list gathered
            for exclude_file_name in exclude_file:
                exclude_file_name = exclude_file_name.strip()
                exclude_path = path + '/' + exclude_file_name
                if os.path.exists(root + exclude_path):
                    if os.path.isdir(root + exclude_path):
                        directories.remove(exclude_path)
                    else:
                        files.remove(exclude_path)
                else:
                    print "Error parsing exclude file, could not open path '%s'" % exclude_path

    except Exception:
        print "Error parsing 'exclude' file: '%s'" % str(sys.exc_info()[1])

    # Fill HTML template
    template = get_template('pages/navigate_source.html')
    html = template.render(
        Context({
            'meta_description':
            'Homepage of Jon Tedesco, a dedicated student and avid software developer at University'
            + 'of Illinois at Urbana-Champaign',
            'meta_keywords':
            ' '.join(get_generic_keywords()),
            'page_title':
            'Navigate Source &#183; ' + project,
            'word_cloud_name':
            'about_me',
            'server_root':
            get_server_root(),
            'path':
            path,
            'project':
            project,
            'files':
            files,
            'static':
            True,
            'directories':
            directories
        }))
    return HttpResponse(html)
コード例 #22
0
def view_source(request, path):
    """
        View the source code of the given file, in the standard <code>view_source</code> template.

            @param  path    The path of the file to display (relative to the root of the site)
    """

    languages = {
        "py": "python",
        "rb": "ruby",
        "js": "javascript",
        "html": "html",
        "htm": "html",
        "cpp": "cpp",
        "c": "c",
        "cc": "cpp",
        "php": "php",
        "java": "java",
        "xml": "xml"
    }

    # Read the source code file
    try:
        source_file = open(get_root_directory() + "/code/" + path, 'r')
        source_code = source_file.read()
        source_file.close()

        # Data structure to hold information for this page
        data = {
            'meta_description': 'Homepage of Jon Tedesco, a dedicated student and avid software developer at University' +
                                'of Illinois at Urbana-Champaign',
            'meta_keywords': ' '.join(get_generic_keywords()),
            'page_title': 'View Source &#183; %s (%s)',
            'word_cloud_name': 'about_me',
            'server_root': get_server_root(),
            'static': True,
            'path': None,
            'language': None,
            'content': None
        }

        # Check if this is a binary file
        binary_file_extensions = ['jpg', 'png', 'bmp', 'jpeg']
        file_extension = path[path.rfind('.') + 1:]
        if file_extension not in binary_file_extensions:
            # Update data
            data['content'] = source_code
            if file_extension in languages:
                data['language'] = languages[file_extension]
            else:
                data['language'] = 'plain'
            data['path'] = path
            data['page_title'] = data['page_title'] % (path, data['language'].title())

        else:
            data['path'] = path
            data['page_title'] = 'View Source &#183; ' + path
            data['image'] = True

        # Fill HTML template
        template = get_template('pages/view_source.html')
        html = template.render(Context(data))
        return HttpResponse(html)

    except IOError:

        # Throw a 404 if the file can't be read
        raise Http404