|
@@ -82,78 +82,88 @@ def wordpress_post_by_scopus(data, category = []):
|
|
|
|
|
|
# define post structure
|
|
|
post = WordPressPost()
|
|
|
- post.title = coredata['dc:title'].encode('utf-8')
|
|
|
+ post.title = coredata['dc:title']
|
|
|
post.date = ts
|
|
|
|
|
|
# set the name of the post different to the title
|
|
|
- post.slug = coredata['dc:identifier'].encode('utf-8')
|
|
|
+ post.slug = coredata['dc:identifier']
|
|
|
|
|
|
- post.excerpt = authors[0]['ce:indexed-name'].encode('utf-8')
|
|
|
+ post.excerpt = authors[0]['ce:indexed-name']
|
|
|
if len(authors) > 2:
|
|
|
- post.excerpt += " et al."
|
|
|
+ post.excerpt += u' et al.'
|
|
|
elif len(authors) == 2:
|
|
|
- post.excerpt += u', ' + authors[1]['ce:indexed-name'].encode('utf-8')
|
|
|
- post.excerpt += u', in <em>' + coredata['prism:publicationName'].encode('utf-8') + u'</em>'
|
|
|
+ post.excerpt += u', ' + authors[1]['ce:indexed-name']
|
|
|
+ post.excerpt += u', in <em>' + coredata['prism:publicationName'] + u'</em>'
|
|
|
if 'prism:volume' in coredata:
|
|
|
- post.excerpt += u', ' + coredata['prism:volume'].encode('utf-8')
|
|
|
+ post.excerpt += u', ' + coredata['prism:volume']
|
|
|
post.excerpt += u' (' + str(year).encode('utf-8') + u')'
|
|
|
if 'prism:pageRange' in coredata:
|
|
|
- post.excerpt += u' ' + coredata['prism:pageRange'].encode('utf-8')
|
|
|
+ post.excerpt += u' ' + coredata['prism:pageRange']
|
|
|
if 'article-number' in coredata:
|
|
|
- post.excerpt += u', ' + coredata['article-number'].encode('utf-8')
|
|
|
+ post.excerpt += u', ' + coredata['article-number']
|
|
|
post.excerpt += u'.'
|
|
|
|
|
|
- post.content = u'<p>' + authors[0]['ce:indexed-name'].encode('utf-8')
|
|
|
+ post.content = u'<p>' + authors[0]['ce:indexed-name']
|
|
|
authors.pop(0)
|
|
|
if len(authors) > 20:
|
|
|
- post.content += " et al."
|
|
|
+ post.content += u' et al.'
|
|
|
else:
|
|
|
for author in authors:
|
|
|
- post.content += u', ' + author['ce:indexed-name'].encode('utf-8')
|
|
|
+ post.content += u', ' + author['ce:indexed-name']
|
|
|
post.content += u'</p>'
|
|
|
- post.content += u'<p>in <em>' + coredata['prism:publicationName'].encode('utf-8') + u'</em>'
|
|
|
+ post.content += u'<p>in <em>' + coredata['prism:publicationName'] + u'</em>'
|
|
|
if 'prism:volume' in coredata:
|
|
|
- post.content += u', ' + coredata['prism:volume'].encode('utf-8')
|
|
|
+ post.content += u', ' + coredata['prism:volume']
|
|
|
post.content += u' (' + str(year).encode('utf-8') + u')'
|
|
|
if 'prism:pageRange' in coredata:
|
|
|
- post.content += u' ' + coredata['prism:pageRange'].encode('utf-8')
|
|
|
+ post.content += u' ' + coredata['prism:pageRange']
|
|
|
if 'article-number' in coredata:
|
|
|
- post.content += u', ' + coredata['article-number'].encode('utf-8')
|
|
|
+ post.content += u', ' + coredata['article-number']
|
|
|
post.content += u'.'
|
|
|
if 'prism:doi' in coredata:
|
|
|
- post.content += u' DOI:' + coredata['prism:doi'].encode('utf-8')
|
|
|
+ post.content += u' DOI:' + coredata['prism:doi']
|
|
|
post.content += u'</p>\n\n'
|
|
|
if 'dc:description' in coredata:
|
|
|
post.content += u'<div class="accordion-inner"><h4>Abstract</h4>' + coredata['dc:description']
|
|
|
if 'authkeywords' in coredata:
|
|
|
- post.content += u'\n<b>Keywords:</b> ' + coredata['authkeywords'].encode('utf-8')
|
|
|
+ post.content += u'\n<b>Keywords:</b> ' + coredata['authkeywords']
|
|
|
post.content += u'</div>'
|
|
|
if 'prism:doi' in coredata:
|
|
|
- link = u'http://dx.doi.org/' + coredata['prism:doi'].encode('utf-8')
|
|
|
+ link = u'http://dx.doi.org/' + coredata['prism:doi']
|
|
|
post.content += u'\n\n<div class="accordion-inner"><a class="btn btn-primary" href="' + link + u'"><i class="icon-download icon-white"></i> Get it</a></div>'
|
|
|
|
|
|
#print post.content
|
|
|
-
|
|
|
#post.id = wp.call(NewPost(post)) # Creates a new post and returns the id!
|
|
|
|
|
|
catlist = []
|
|
|
for slug in category:
|
|
|
- cat = wordpress_get_category(slug)
|
|
|
- catlist.append(cat)
|
|
|
+ try:
|
|
|
+ cat = wordpress_get_category(slug)
|
|
|
+ catlist.append(cat)
|
|
|
+ except:
|
|
|
+ print "Slug %s not found in Wordpress" % slug
|
|
|
+ exit
|
|
|
post.terms = catlist
|
|
|
+ print post.terms
|
|
|
|
|
|
+ taglist = []
|
|
|
try:
|
|
|
- taglist = []
|
|
|
for tag in data['abstracts-retrieval-response']['authkeywords']['author-keyword']:
|
|
|
- print "Keyword: ", tag
|
|
|
- taglist.append(tag['$'])
|
|
|
+ try:
|
|
|
+ print "Keyword: ", tag
|
|
|
+ taglist.append(tag['$'].decode('utf-8','ignore'))
|
|
|
+ except:
|
|
|
+ print "Keyword contains special characters - droped!"
|
|
|
+ pass
|
|
|
except:
|
|
|
- pass
|
|
|
+ # No keywords given
|
|
|
+ pass
|
|
|
|
|
|
post.terms_names = {
|
|
|
- 'category': ['Publications'],
|
|
|
- 'post_tag': taglist
|
|
|
- }
|
|
|
+ 'category': ['Publications'],
|
|
|
+ 'post_tag': taglist
|
|
|
+ }
|
|
|
+ print post.terms_names
|
|
|
|
|
|
# whoops, I forgot to publish it!
|
|
|
if len(authors) > sc_max_authors:
|
|
@@ -166,7 +176,7 @@ def wordpress_post_by_scopus(data, category = []):
|
|
|
# Todo: this can fail! Add proper error handling
|
|
|
post.id = wp.call(NewPost(post)) # Creates a new post and returns the id!
|
|
|
#wp.call(EditPost(post.id, post))# Update the before created post
|
|
|
-
|
|
|
+ print post.id
|
|
|
|
|
|
# need to update the database !!!
|
|
|
return post.id
|