Example #1
0
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ésumé (resume) · My education, experience,skills, coursework, papers, and awards",
            'meta_keywords':
            ' '.join([
                "resume", "education", "experience", "skills", "coursework",
                "papers", "awards"
            ] + get_generic_keywords()),
            'page_title':
            'Résumé · Jon Tedesco',
            'word_cloud_name':
            'resume',
            'server_root':
            get_server_root()
        }))

    return HttpResponse(html)
Example #2
0
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)
Example #3
0
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)
Example #4
0
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)
Example #5
0
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)
Example #6
0
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)
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 · ' + project,
        'word_cloud_name': 'about_me',
        'server_root': get_server_root(),
        'path': path,
        'project': project,
        'files': files,
        'static': True,
        'directories': directories
    }))
    return HttpResponse(html)
Example #8
0
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 · 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 · Jon Tedesco',
            'word_cloud_name':
            'projects',
            'server_root':
            get_server_root(),
            'pages':
            pages,
            'number_of_pages':
            len(list(pages))
        }))

    return HttpResponse(html)
Example #9
0
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)
Example #10
0
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 · 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',
            'word_cloud_name':
            'blog',
            'server_root':
            get_server_root(),
            'pages':
            pages,
            'number_of_pages':
            len(list(pages))
        }))

    return HttpResponse(html)
Example #11
0
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 · 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 · Jon Tedesco',
        'word_cloud_name': 'projects',
        'server_root': get_server_root(),
        'pages': pages,
        'number_of_pages': len(list(pages))
    }))

    return HttpResponse(html)
Example #12
0
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)
Example #13
0
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 · 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',
        'word_cloud_name': 'blog',
        'server_root': get_server_root(),
        'pages': pages,
        'number_of_pages': len(list(pages))
    }))

    return HttpResponse(html)
Example #14
0
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)
Example #15
0
def search(request, query):
    """
      Search the page using Whoosh

        @param  query   The query to search
    """

    # Prepare defaults
    title = "Jon Tedesco · 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 += " · '%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
Example #16
0
def search(request, query):
    """
      Search the page using Whoosh

        @param  query   The query to search
    """

    # Prepare defaults
    title = "Jon Tedesco · 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 += " · '%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
Example #17
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
Example #18
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)
Example #19
0
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)
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