Example #1
0
    def publish(self):
        identity = request.environ.get("repoze.who.identity")
        if identity:
            #Get list of vocabularies created by userid
            c.userid = identity['repoze.who.userid']
            c.user_det = get_mediator_details(c.userid)
            vocabs = get_mediator_vocabs(c.userid)
            #Get status of vocab - is rdf, ready to convert to html, new rdf check, convert to html, html check
            c.vocab_list = {}

            for k, v in vocabs.iteritems():
                files = get_vocab_files(k)
                description = {}
                for f, vals in files.iteritems():
                    if vals['format'] == 'application/rdf+xml':
                        description = get_vocab_description(vals['path'], k)
                msgs = get_vocab_editorial_note(k)
                c.vocab_list[k] = description
                c.vocab_list[k]['files'] = files
                c.vocab_list[k]['uri'] = v[0]
                c.vocab_list[k]['svn'] = v[1]
                c.vocab_list[k]['note'] = msgs
            return render('/publish.html')
        else:
            session[
                'login_flash'] = "Please login to view vocabularies published and managed by you and to upload new vocabularies"
            session.save()
            destination = "/login?came_from=publish"
            return redirect(destination, code=303)
Example #2
0
    def publish(self):
        identity = request.environ.get("repoze.who.identity")
        if identity:
            #Get list of vocabularies created by userid
            c.userid = identity['repoze.who.userid']
            c.user_det = get_mediator_details(c.userid)
            vocabs = get_mediator_vocabs(c.userid)
            #Get status of vocab - is rdf, ready to convert to html, new rdf check, convert to html, html check
            c.vocab_list = {}

            for k, v in vocabs.iteritems():
                files = get_vocab_files(k)
                description = {}
                for f, vals in files.iteritems():
                    if vals['format'] == 'application/rdf+xml':
                        description = get_vocab_description(vals['path'], k)
                msgs = get_vocab_editorial_note(k)
                c.vocab_list[k] = description
                c.vocab_list[k]['files'] = files
                c.vocab_list[k]['uri'] = v[0]
                c.vocab_list[k]['svn'] = v[1]
                c.vocab_list[k]['note'] = msgs
            return render('/publish.html')
        else:
            session['login_flash'] = "Please login to view vocabularies published and managed by you and to upload new vocabularies"
            session.save()
            destination = "/login?came_from=publish"
            return redirect(destination, code=303)
Example #3
0
 def index(self):
     """Generates the list of vocabs in the browse page."""
     vocabs = os.listdir(ag.vocabulariesdir)
     c.ox_vocab_list = {}
     c.ref_vocab_list = {}
     mediators_dir_name = ag.mediatorsdir.strip('/').split('/')[-1]
     reference_vocabs = get_ref_vocabs().keys()
     for v in vocabs:
         vocab_dict = {}
         if v.startswith(
                 '.') or v == mediators_dir_name or v == os.path.split(
                     ag.vocabulariesref)[1]:
             continue
         #Get the list of files
         files = get_vocab_files(v)
         if not files:
             continue
         description = {}
         for f, vals in files.iteritems():
             if vals['format'] == 'application/rdf+xml':
                 description = get_vocab_description(vals['path'], v)
         vocab_dict = description
         vocab_dict['files'] = files
         vocab_dict['mediators'] = get_vocab_mediator(v)
         properties = get_vocab_properties(v)
         vocab_dict['uri'] = properties['uri']
         vocab_dict['pref_uri'] = properties['preferredNamespaceUri']
         vocab_dict['pref_prefix'] = properties['preferredNamespacePrefix']
         if str(properties['uri']) in reference_vocabs:
             c.ref_vocab_list[v] = vocab_dict
         else:
             c.ox_vocab_list[v] = vocab_dict
     return render('/browse.html')
Example #4
0
 def index(self):
     """Generates the list of vocabs in the browse page."""
     vocabs =  os.listdir(ag.vocabulariesdir)
     c.ox_vocab_list = {}
     c.ref_vocab_list = {}
     mediators_dir_name = ag.mediatorsdir.strip('/').split('/')[-1]
     reference_vocabs = get_ref_vocabs().keys()
     for v in vocabs:
         vocab_dict = {}
         if v.startswith('.') or v == mediators_dir_name or v == os.path.split(ag.vocabulariesref)[1]:
             continue
         #Get the list of files
         files = get_vocab_files(v)
         if not files:
             continue
         description = {}
         for f, vals in files.iteritems():
             if vals['format'] == 'application/rdf+xml':
                 description = get_vocab_description(vals['path'], v)
         vocab_dict = description
         vocab_dict['files'] = files
         vocab_dict['mediators'] = get_vocab_mediator(v)
         properties = get_vocab_properties(v)
         vocab_dict['uri'] = properties['uri']
         vocab_dict['pref_uri'] = properties['preferredNamespaceUri']
         vocab_dict['pref_prefix'] = properties['preferredNamespacePrefix']
         if str(properties['uri']) in reference_vocabs:
             c.ref_vocab_list[v] = vocab_dict
         else:
             c.ox_vocab_list[v] = vocab_dict
     return render('/browse.html')
Example #5
0
 def render_vocab_file(self, vocab, filename):
     """Render the file for vocab"""
     files = get_vocab_files(vocab)
     if not files:
         abort(404)
     for f, v in files.iteritems():
         if v['name'] == filename or f == 'http://vocab.ox.ac.uk/%s/%s'%(vocab, filename):
             if v['format'].lower() == 'text/html':
                 c.format = v['format']
                 c.vocabfile = v['path'].replace('/opt', '')
                 return render('/vocab.html')
             elif v['format'].lower() in ['application/rdf+xml', 'text/xml', "text/rdf+n3", "application/x-turtle", \
                                          "text/rdf+ntriples", "text/rdf+nt", "text/plain"]:
                 response.content_type = '%s; charset="UTF-8"'%str(v['format'])
                 response.status_int = 200
                 response.status = "200 OK"
                 f = codecs.open(v['path'], 'r', 'utf-8')
                 return_str = f.read()
                 f.close()
                 return return_str
             else:
                 response.content_type = '%s; charset="utf-8"'%str(v['format'])
                 response.status_int = 200
                 response.status = "200 OK"
                 if os.path.isfile(v['path']):
                     fileserve_app = FileApp(v['path'])
                     return fileserve_app(request.environ, self.start_response)
                 else:
                     session['browse_flash'] = "Could not find the file %s for %s"%(filename, vocab)
                     session.save()
                     return redirect(url(controller='vocabs', action='index'), code=303)
     session['browse_flash'] = "Could not find the file %s for %s"%(filename, vocab)
     session.save()
     return redirect(url(controller='vocabs', action='index'), code=303)
Example #6
0
 def owner(self, owner_uuid):
     c.user_det = get_mediator_details(owner_uuid)
     c.vocab_list = {}
     if 'userid' in c.user_det and c.user_det['userid']:
         c.userid = c.user_det['userid']
         vocabs = get_mediator_vocabs(c.userid)
         #Get status of vocab - is rdf, ready to convert to html, new rdf check, convert to html, html check
         for k, v in vocabs.iteritems():
             files = get_vocab_files(k)
             description = {}
             for f, vals in files.iteritems():
                 if vals['format'] == 'application/rdf+xml':
                     description = get_vocab_description(vals['path'], k)
             c.vocab_list[k] = description
             c.vocab_list[k]['files'] = files
     return render('/owner.html')
Example #7
0
 def owner(self, owner_uuid):
     c.user_det = get_mediator_details(owner_uuid)
     c.vocab_list = {}
     if 'userid' in c.user_det and c.user_det['userid']:
         c.userid = c.user_det['userid']
         vocabs = get_mediator_vocabs(c.userid)
         #Get status of vocab - is rdf, ready to convert to html, new rdf check, convert to html, html check
         for k, v in vocabs.iteritems():
             files = get_vocab_files(k)
             description = {}
             for f, vals in files.iteritems():
                 if vals['format'] == 'application/rdf+xml':
                     description = get_vocab_description(vals['path'], k)
             c.vocab_list[k] = description
             c.vocab_list[k]['files'] = files
     return render ('/owner.html')
Example #8
0
 def render_vocab_file(self, vocab, filename):
     """Render the file for vocab"""
     files = get_vocab_files(vocab)
     if not files:
         abort(404)
     for f, v in files.iteritems():
         if v['name'] == filename or f == 'http://vocab.ox.ac.uk/%s/%s' % (
                 vocab, filename):
             if v['format'].lower() == 'text/html':
                 c.format = v['format']
                 c.vocabfile = v['path'].replace('/opt', '')
                 return render('/vocab.html')
             elif v['format'].lower() in ['application/rdf+xml', 'text/xml', "text/rdf+n3", "application/x-turtle", \
                                          "text/rdf+ntriples", "text/rdf+nt", "text/plain"]:
                 response.content_type = '%s; charset="UTF-8"' % str(
                     v['format'])
                 response.status_int = 200
                 response.status = "200 OK"
                 f = codecs.open(v['path'], 'r', 'utf-8')
                 return_str = f.read()
                 f.close()
                 return return_str
             else:
                 response.content_type = '%s; charset="utf-8"' % str(
                     v['format'])
                 response.status_int = 200
                 response.status = "200 OK"
                 if os.path.isfile(v['path']):
                     fileserve_app = FileApp(v['path'])
                     return fileserve_app(request.environ,
                                          self.start_response)
                 else:
                     session[
                         'browse_flash'] = "Could not find the file %s for %s" % (
                             filename, vocab)
                     session.save()
                     return redirect(url(controller='vocabs',
                                         action='index'),
                                     code=303)
     session['browse_flash'] = "Could not find the file %s for %s" % (
         filename, vocab)
     session.save()
     return redirect(url(controller='vocabs', action='index'), code=303)
Example #9
0
 def render_vocab(self, vocab):
     """Render the page for each vocab"""
     c.vocab = vocab
     files = get_vocab_files(vocab)
     if not files:
         session['browse_flash'] = "Could not find any file for %s" % vocab
         session.save()
         return redirect(url(controller='vocabs', action='index'), code=303)
     formats = []
     for f, v in files.iteritems():
         if not v['format'].lower() in formats:
             formats.append(v['format'].lower())
     # conneg return
     accept_list = None
     if 'HTTP_ACCEPT' in request.environ:
         try:
             accept_list = conneg_parse(request.environ['HTTP_ACCEPT'])
         except:
             accept_list = [MT("text", "html")]
     if not accept_list:
         accept_list = [MT("text", "html")]
     mimetype = accept_list.pop()
     while (mimetype):
         if str(mimetype).lower() in formats:
             if str(mimetype).lower() in ['text/html', "text/xhtml"]:
                 for f, v in files.iteritems():
                     if v['format'].lower() == 'text/html':
                         c.format = v['format']
                         c.vocabfile = v['path'].replace('/opt', '')
                         return render('/vocab.html')
             elif str(mimetype).lower() in ['application/rdf+xml', "text/xml", "text/rdf+n3", "application/x-turtle", \
             "text/rdf+ntriples", "text/rdf+nt", "text/plain"]:
                 for f, v in files.iteritems():
                     if v['format'].lower() in ['application/rdf+xml', 'text/xml', "text/rdf+n3", "application/x-turtle", \
                     "text/rdf+ntriples", "text/rdf+nt", "text/plain"]:
                         response.content_type = '%s; charset="UTF-8"' % str(
                             mimetype)
                         response.status_int = 200
                         response.status = "200 OK"
                         f = codecs.open(v['path'], 'r', 'utf-8')
                         return_str = f.read()
                         f.close()
                         return return_str
             else:
                 response.content_type = '%s; charset="UTF-8"' % str(
                     mimetype)
                 response.status_int = 200
                 response.status = "200 OK"
                 for f, v in files.iteritems():
                     if v['format'].lower() == str(mimetype).lower(
                     ) and os.path.isfile(v['path']):
                         fileserve_app = FileApp(v['path'])
                         return fileserve_app(request.environ,
                                              self.start_response)
         try:
             mimetype = accept_list.pop()
         except IndexError:
             mimetype = None
     #Whoops nothing satisfies - return one of the formats available - 1. text/html, 2. other
     if 'text/html' in formats:
         for f, v in files.iteritems():
             if v['format'].lower() == 'text/html':
                 c.format = v['format']
                 c.vocabfile = v['path'].replace('/opt', '')
                 return render('/vocab.html')
     elif 'application/rdf+xml' in formats or "text/xml" in formats or "text/rdf+n3" in formats or "text/plain" in formats or \
          "application/x-turtle" in formats or "text/rdf+ntriples" in formats or "text/rdf+nt" in formats:
         for f, v in files.iteritems():
             if v['format'].lower() in ['application/rdf+xml', "text/xml", "text/rdf+n3", "application/x-turtle", \
                                     "text/rdf+ntriples", "text/rdf+nt", "text/plain"]:
                 response.content_type = '%s; charset="UTF-8"' % str(
                     v['format'])
                 response.status_int = 200
                 response.status = "200 OK"
                 f = codecs.open(v['path'], 'r', 'utf-8')
                 return_str = f.read()
                 f.close()
                 return return_str
     else:
         for format in formats:
             response.content_type = '%s; charset="UTF-8"' % str(format)
             response.status_int = 200
             response.status = "200 OK"
             for f, v in files.iteritems():
                 if v['format'].lower() == format and os.path.isfile(
                         v['path']):
                     fileserve_app = FileApp(v['path'])
                     return fileserve_app(request.environ,
                                          self.start_response)
     session['browse_flash'] = "Could not find any file for %s" % vocab
     session.save()
     return redirect(url(controller='vocabs', action='index'), code=303)
Example #10
0
 def render_vocab(self, vocab):
     """Render the page for each vocab"""
     c.vocab = vocab
     files = get_vocab_files(vocab)
     if not files:
         session['browse_flash'] = "Could not find any file for %s"%vocab
         session.save()
         return redirect(url(controller='vocabs', action='index'), code=303)
     formats = []
     for f, v in files.iteritems():
         if not v['format'].lower() in formats:
             formats.append(v['format'].lower())
     # conneg return
     accept_list = None
     if 'HTTP_ACCEPT' in request.environ:
         try:
             accept_list = conneg_parse(request.environ['HTTP_ACCEPT'])
         except:
             accept_list= [MT("text", "html")]
     if not accept_list:
         accept_list= [MT("text", "html")]
     mimetype = accept_list.pop()
     while(mimetype):
         if str(mimetype).lower() in formats:
             if str(mimetype).lower() in ['text/html', "text/xhtml"]:
                 for f, v in files.iteritems():
                     if v['format'].lower() == 'text/html':
                         c.format = v['format']
                         c.vocabfile = v['path'].replace('/opt', '')
                         return render('/vocab.html')
             elif str(mimetype).lower() in ['application/rdf+xml', "text/xml", "text/rdf+n3", "application/x-turtle", \
             "text/rdf+ntriples", "text/rdf+nt", "text/plain"]:
                 for f, v in files.iteritems():
                     if v['format'].lower() in ['application/rdf+xml', 'text/xml', "text/rdf+n3", "application/x-turtle", \
                     "text/rdf+ntriples", "text/rdf+nt", "text/plain"]:
                         response.content_type = '%s; charset="UTF-8"'%str(mimetype)
                         response.status_int = 200
                         response.status = "200 OK"
                         f = codecs.open(v['path'], 'r', 'utf-8')
                         return_str = f.read()
                         f.close()
                         return return_str
             else:
                 response.content_type = '%s; charset="UTF-8"'%str(mimetype)
                 response.status_int = 200
                 response.status = "200 OK"
                 for f, v in files.iteritems():
                     if v['format'].lower() == str(mimetype).lower() and os.path.isfile(v['path']):
                         fileserve_app = FileApp(v['path'])
                         return fileserve_app(request.environ, self.start_response)
         try:
             mimetype = accept_list.pop()
         except IndexError:
             mimetype = None
     #Whoops nothing satisfies - return one of the formats available - 1. text/html, 2. other
     if 'text/html' in formats:
         for f, v in files.iteritems():
             if v['format'].lower() == 'text/html':
                 c.format = v['format']
                 c.vocabfile = v['path'].replace('/opt', '')
                 return render('/vocab.html')
     elif 'application/rdf+xml' in formats or "text/xml" in formats or "text/rdf+n3" in formats or "text/plain" in formats or \
          "application/x-turtle" in formats or "text/rdf+ntriples" in formats or "text/rdf+nt" in formats:
         for f, v in files.iteritems():
             if v['format'].lower() in ['application/rdf+xml', "text/xml", "text/rdf+n3", "application/x-turtle", \
                                     "text/rdf+ntriples", "text/rdf+nt", "text/plain"]:
                 response.content_type = '%s; charset="UTF-8"'%str(v['format'])
                 response.status_int = 200
                 response.status = "200 OK"
                 f = codecs.open(v['path'], 'r', 'utf-8')
                 return_str = f.read()
                 f.close()
                 return return_str
     else:
         for format in formats:
             response.content_type = '%s; charset="UTF-8"'%str(format)
             response.status_int = 200
             response.status = "200 OK"
             for f, v in files.iteritems():
                 if v['format'].lower() == format and os.path.isfile(v['path']):
                     fileserve_app = FileApp(v['path'])
                     return fileserve_app(request.environ, self.start_response)
     session['browse_flash'] = "Could not find any file for %s"%vocab
     session.save()
     return redirect(url(controller='vocabs', action='index'), code=303)
Example #11
0
    def generate(self, prefix):
        came_from = "/publish"
        identity = request.environ.get("repoze.who.identity")
        if not identity:
            session['login_flash'] = "Please login to convert vocabularies published and managed by you"
            session.save()
            destination = "/login?came_from=%s"%came_from
            return redirect(destination, code=303)
            
        #Check if userid has permissions for this vocab
        userid = identity['repoze.who.userid']
        vocablist = get_mediator_vocabs(userid)
        if vocablist and not prefix in vocablist.keys():
            session['welcome_flash'] = "You are not authorized to make any changes to %s"%prefix
            session.save()
            return redirect(url(controller='vocabs', action='publish'), code=303)

        params = request.params
        if not 'file' in params or not params['file']:
            session['welcome_flash'] = """No file was selected to modify"""
            session.save()
            return redirect(url(controller='vocabs', action='publish'), code=303)

        c.vocabprefix = prefix
        c.filename = params.get('file')

        #Get vocab properties
        vocab_properties = get_vocab_properties(c.vocabprefix)

        #Get vocab rdf file properties
        files = get_vocab_files(c.vocabprefix)
        rdf_vocab_properties = None
        for f, val in files.iteritems():
            if val['name'] == c.filename and val['format'] == 'application/rdf+xml':
                rdf_vocab_properties = val
                rdf_vocab_properties['uri'] = f    
                break
        #Check file exists
        if not rdf_vocab_properties or not os.path.isfile(rdf_vocab_properties['path']):
            session['welcome_flash'] = """Could not locate the file %s for %s"""%(c.filename, c.vocabprefix)
            session.save()
            return redirect(url(controller='vocabs', action='publish'), code=303)

        #Get editorial notes
        notes = get_vocab_editorial_note(c.vocabprefix)
        vocab_msgs = []
        for (msg, recepient) in notes:
            if (not recepient) or recepient == c.filename:
                vocab_msgs.append(msg)
                #vocab_file_msgs.append(msg)

        if vocab_editorial_descriptions[5] in vocab_msgs:
            #TODO: Get the URI for the html file
            session['welcome_flash'] = "HTML file exists for %s"%c.vocabprefix
            session.save()
            return redirect(url(controller='vocabs', action='publish'), code=303)

        if not vocab_editorial_descriptions[3] in vocab_msgs:
            if vocab_editorial_descriptions[1] in vocab_msgs:
                session['welcome_flash'] = "%s in %s"%(vocab_editorial_descriptions[1], c.vocabprefix)
                session.save()
                return redirect(url(controller='vocabs', action='publish'), code=303)
            if vocab_editorial_descriptions[2] in vocab_msgs:
                session['welcome_flash'] = "%s in %s"%(vocab_editorial_descriptions[2], c.filename)
                session.save()
                return redirect(url(controller='vocabs', action='publish'), code=303)
            if vocab_editorial_descriptions[4] in vocab_msgs:
                session['welcome_flash'] = "%s in %s"%(vocab_editorial_descriptions[4], c.filename)
                session.save()
                return redirect(url(controller='vocabs', action='publish'), code=303)

        del_status(c.vocabprefix, rdf_vocab_properties['uri'], 'skos:editorialNote', vocab_editorial_descriptions[3])

        #Check if file is rdf
        if not check_rdf(rdf_vocab_properties['path']):
            add_status(c.vocabprefix, rdf_vocab_properties['uri'], 'skos:editorialNote', vocab_editorial_descriptions[2])
            session['welcome_flash'] = "Could not parse %s as an rdf file"%c.filename
            session.save()
            return redirect(url(controller='vocabs', action='publish'), code=303)

        html_vocab_properties = {}
        html_vocab_properties['format'] = 'text/html'
        html_vocab_properties['name'] = "%s.html"%os.path.splitext(rdf_vocab_properties['name'])[0]
        (head, tail) = os.path.split(rdf_vocab_properties['path'])
        html_vocab_properties['path'] = os.path.join(head, html_vocab_properties['name'])
        uri_parts = rdf_vocab_properties['uri'].split('/')
        for i in range(len(uri_parts)-1, -1, -1):
            if uri_parts[i] == rdf_vocab_properties['name']:
                uri_parts[i] = html_vocab_properties['name']
                break
        html_vocab_properties['uri'] = '/'.join(uri_parts)

        loc = rdf_vocab_properties['path']
        dest = html_vocab_properties['path']
        #try:
        #    s = SpecGen(loc, c.vocabprefix, vocab_properties['preferredNamespaceUri'], ag.conversion_template, dest)
        #    s.create_file()
        #except Exception, e:
        #    add_status(c.vocabprefix, rdf_vocab_properties['uri'], 'skos:editorialNote', vocab_editorial_descriptions[4])
        #    add_status(c.vocabprefix, rdf_vocab_properties['uri'], 'skos:note', str(e))
        #    session['welcome_flash'] = """%s <br>%s"""%(vocab_editorial_descriptions[4], str(e))
        #    session.save()
        #    return redirect(url(controller='vocabs', action='publish'), code=303)        
        s = SpecGen(loc, c.vocabprefix, vocab_properties['preferredNamespaceUri'], ag.conversion_template, dest)
        s.create_file()

        add_file_to_vocab_status(c.vocabprefix, html_vocab_properties)
        add_status(c.vocabprefix, rdf_vocab_properties['uri'], 'skos:editorialNote', vocab_editorial_descriptions[5])
        add_status(c.vocabprefix, html_vocab_properties['uri'], 'dcterms:isFormatOf', rdf_vocab_properties['uri'])

        message = ["""Generated the html file %s"""%html_vocab_properties['uri']]   
        #Commit svn changes
        (status1, msg1) = svn_add(dest, "Created HTML file")
        if not status1:
            message.append("""Error committing to SVN: %s"""%msg1)
       
        (status2, msg2) = svn_commit([dest], "Generated HTML file. Committing changes")
        if not status2:
            message.append("""Error committing to SVN: %s"""%msg2)
        
        session['welcome_flash'] = '<br>'.join(message)
        session.save()
        return redirect(url(controller='vocabs', action='publish'), code=303)
Example #12
0
    def generate(self, prefix):
        came_from = "/publish"
        identity = request.environ.get("repoze.who.identity")
        if not identity:
            session[
                'login_flash'] = "Please login to convert vocabularies published and managed by you"
            session.save()
            destination = "/login?came_from=%s" % came_from
            return redirect(destination, code=303)

        #Check if userid has permissions for this vocab
        userid = identity['repoze.who.userid']
        vocablist = get_mediator_vocabs(userid)
        if vocablist and not prefix in vocablist.keys():
            session[
                'welcome_flash'] = "You are not authorized to make any changes to %s" % prefix
            session.save()
            return redirect(url(controller='vocabs', action='publish'),
                            code=303)

        params = request.params
        if not 'file' in params or not params['file']:
            session['welcome_flash'] = """No file was selected to modify"""
            session.save()
            return redirect(url(controller='vocabs', action='publish'),
                            code=303)

        c.vocabprefix = prefix
        c.filename = params.get('file')

        #Get vocab properties
        vocab_properties = get_vocab_properties(c.vocabprefix)

        #Get vocab rdf file properties
        files = get_vocab_files(c.vocabprefix)
        rdf_vocab_properties = None
        for f, val in files.iteritems():
            if val['name'] == c.filename and val[
                    'format'] == 'application/rdf+xml':
                rdf_vocab_properties = val
                rdf_vocab_properties['uri'] = f
                break
        #Check file exists
        if not rdf_vocab_properties or not os.path.isfile(
                rdf_vocab_properties['path']):
            session[
                'welcome_flash'] = """Could not locate the file %s for %s""" % (
                    c.filename, c.vocabprefix)
            session.save()
            return redirect(url(controller='vocabs', action='publish'),
                            code=303)

        #Get editorial notes
        notes = get_vocab_editorial_note(c.vocabprefix)
        vocab_msgs = []
        for (msg, recepient) in notes:
            if (not recepient) or recepient == c.filename:
                vocab_msgs.append(msg)
                #vocab_file_msgs.append(msg)

        if vocab_editorial_descriptions[5] in vocab_msgs:
            #TODO: Get the URI for the html file
            session[
                'welcome_flash'] = "HTML file exists for %s" % c.vocabprefix
            session.save()
            return redirect(url(controller='vocabs', action='publish'),
                            code=303)

        if not vocab_editorial_descriptions[3] in vocab_msgs:
            if vocab_editorial_descriptions[1] in vocab_msgs:
                session['welcome_flash'] = "%s in %s" % (
                    vocab_editorial_descriptions[1], c.vocabprefix)
                session.save()
                return redirect(url(controller='vocabs', action='publish'),
                                code=303)
            if vocab_editorial_descriptions[2] in vocab_msgs:
                session['welcome_flash'] = "%s in %s" % (
                    vocab_editorial_descriptions[2], c.filename)
                session.save()
                return redirect(url(controller='vocabs', action='publish'),
                                code=303)
            if vocab_editorial_descriptions[4] in vocab_msgs:
                session['welcome_flash'] = "%s in %s" % (
                    vocab_editorial_descriptions[4], c.filename)
                session.save()
                return redirect(url(controller='vocabs', action='publish'),
                                code=303)

        del_status(c.vocabprefix, rdf_vocab_properties['uri'],
                   'skos:editorialNote', vocab_editorial_descriptions[3])

        #Check if file is rdf
        if not check_rdf(rdf_vocab_properties['path']):
            add_status(c.vocabprefix, rdf_vocab_properties['uri'],
                       'skos:editorialNote', vocab_editorial_descriptions[2])
            session[
                'welcome_flash'] = "Could not parse %s as an rdf file" % c.filename
            session.save()
            return redirect(url(controller='vocabs', action='publish'),
                            code=303)

        html_vocab_properties = {}
        html_vocab_properties['format'] = 'text/html'
        html_vocab_properties['name'] = "%s.html" % os.path.splitext(
            rdf_vocab_properties['name'])[0]
        (head, tail) = os.path.split(rdf_vocab_properties['path'])
        html_vocab_properties['path'] = os.path.join(
            head, html_vocab_properties['name'])
        uri_parts = rdf_vocab_properties['uri'].split('/')
        for i in range(len(uri_parts) - 1, -1, -1):
            if uri_parts[i] == rdf_vocab_properties['name']:
                uri_parts[i] = html_vocab_properties['name']
                break
        html_vocab_properties['uri'] = '/'.join(uri_parts)

        loc = rdf_vocab_properties['path']
        dest = html_vocab_properties['path']
        #try:
        #    s = SpecGen(loc, c.vocabprefix, vocab_properties['preferredNamespaceUri'], ag.conversion_template, dest)
        #    s.create_file()
        #except Exception, e:
        #    add_status(c.vocabprefix, rdf_vocab_properties['uri'], 'skos:editorialNote', vocab_editorial_descriptions[4])
        #    add_status(c.vocabprefix, rdf_vocab_properties['uri'], 'skos:note', str(e))
        #    session['welcome_flash'] = """%s <br>%s"""%(vocab_editorial_descriptions[4], str(e))
        #    session.save()
        #    return redirect(url(controller='vocabs', action='publish'), code=303)
        s = SpecGen(loc, c.vocabprefix,
                    vocab_properties['preferredNamespaceUri'],
                    ag.conversion_template, dest)
        s.create_file()

        add_file_to_vocab_status(c.vocabprefix, html_vocab_properties)
        add_status(c.vocabprefix, rdf_vocab_properties['uri'],
                   'skos:editorialNote', vocab_editorial_descriptions[5])
        add_status(c.vocabprefix, html_vocab_properties['uri'],
                   'dcterms:isFormatOf', rdf_vocab_properties['uri'])

        message = [
            """Generated the html file %s""" % html_vocab_properties['uri']
        ]
        #Commit svn changes
        (status1, msg1) = svn_add(dest, "Created HTML file")
        if not status1:
            message.append("""Error committing to SVN: %s""" % msg1)

        (status2, msg2) = svn_commit([dest],
                                     "Generated HTML file. Committing changes")
        if not status2:
            message.append("""Error committing to SVN: %s""" % msg2)

        session['welcome_flash'] = '<br>'.join(message)
        session.save()
        return redirect(url(controller='vocabs', action='publish'), code=303)