Skip to content
Snippets Groups Projects
Commit 74de999f authored by Bruno Nocera Zanette's avatar Bruno Nocera Zanette
Browse files

Add HREF attribute to entities


Added HREF attribute to every tag that directly reference a web page.
For example: User's profile page, Content's webpage

Signed-off-by: default avatarBruno Nocera Zanette <brunonzanette@gmail.com>
parent 9f3f553c
No related branches found
No related tags found
No related merge requests found
......@@ -88,7 +88,7 @@ qry_post_content_permission = \
# Argument: Post_ID
# Return: All comments, and its info, made on the post.
qry_post_comments = \
(" SELECT u.guid, u.name, m.string, a.time_created \
(" SELECT u.guid, u.name, u.username, m.string, a.time_created \
FROM elgg_annotations a, elgg_metastrings m, elgg_users_entity u \
WHERE a.value_id = m.id AND a.owner_guid = u.guid \
AND (a.access_id = 1 OR a.access_id = 2) \
......@@ -100,7 +100,7 @@ qry_post_comments = \
# Argument: Group_ID
# Return: All members' name from this group.
qry_group_members = \
(" SELECT u.guid, u.name \
(" SELECT u.guid, u.name, u.username \
FROM elgg_users_entity u, elgg_entity_relationships r \
WHERE u.guid = r.guid_one \
AND r.relationship = 'member' AND r.guid_two = %s; ")
......@@ -152,6 +152,13 @@ def qtystr(quantity):
return qty_string
#--------------------------------------------------------------------#
#--------------------------------------------------------------------#
def hrefstr(prefix, guid):
http_str="http://participatorio.juventude.gov.br/"
href_string=" href="+"\'"+http_str+prefix+guid+"\'"
return href_string
#--------------------------------------------------------------------#
#--------------------------------------------------------------------#
def datestr(time):
if time != '':
......@@ -229,11 +236,12 @@ def write_comments (db, xml, post_guid):
post_comments.execute(qry_post_comments, (post_guid,))
xml.write(l4+"<comentarios>\n")
for (user_id, user_name, string, time) in post_comments:
for (user_id, user_name, user_username, string, time) in post_comments:
xml.write(l5+"<comentario>\n")
write_tag(xml,l6,"usuario",user_name,uidstr(user_id))
attr=uidstr(user_id)+hrefstr('profile/',user_username)
write_tag(xml,l6,"usuario",user_name,attr)
write_tag(xml,l6,"data",datestr(time),'')
write_tag(xml,l6,"mensagem",cdata(string),'')
......@@ -252,8 +260,9 @@ def write_groupmembers_subsection (db, xml, group_guid):
write_tag(xml,l2,"quantidade_membros",str(group_members.rowcount),'')
xml.write(l2+"<membros>\n")
for (user_id, user_name) in group_members:
write_tag(xml,l3,"usuario",user_name,uidstr(user_id))
for (user_id, user_name, user_username) in group_members:
attr=uidstr(user_id)+hrefstr('profile/',user_username)
write_tag(xml,l3,"usuario",user_name,attr)
xml.write(l2+"</membros>\n")
group_members.close()
......@@ -277,7 +286,8 @@ def write_groupfiles_subsection (db, xml, group_guid):
link_prefix="http://participatorio.juventude.gov.br/file/download/"
file_link=str(link_prefix)+str(post_guid)
xml.write(l3+"<arquivo>\n")
attr=hrefstr('file/view/',str(post_guid))
xml.write(l3+"<arquivo"+attr+">\n")
write_tag(xml,l4,"autor",owner_name,uidstr(owner_id))
write_tag(xml,l4,"titulo",post_title,'')
......@@ -309,7 +319,8 @@ def write_groupforumtopics_subsection (db, xml, group_guid):
for (post_guid, post_title, post_desc, owner_id, owner_name, time)\
in group_forumtopics:
xml.write(l3+"<debate>\n")
attr=hrefstr('discussion/view/',str(post_guid))
xml.write(l3+"<debate"+attr+">\n")
write_tag(xml,l4,"autor",owner_name,uidstr(owner_id))
write_tag(xml,l4,"titulo",post_title,'')
......@@ -343,7 +354,8 @@ def write_groupbookmarks_subsection (db, xml, group_guid):
# 90 = select * from elgg_metastrings where string='address';
bookmark_link=post_content(db,post_guid,90)
xml.write(l3+"<favorito>\n")
attr=hrefstr('bookmarks/view/',str(post_guid))
xml.write(l3+"<favorito"+attr+">\n")
write_tag(xml,l4,"autor",owner_name,uidstr(owner_id))
write_tag(xml,l4,"titulo",post_title,'')
......@@ -375,7 +387,8 @@ def write_grouppages_subsection (db, xml, group_guid):
for (post_guid, post_title, post_desc, owner_id, owner_name, time)\
in group_pages:
xml.write(l3+"<pagina>\n")
attr=hrefstr('pages/view/',str(post_guid))
xml.write(l3+"<pagina"+attr+">\n")
write_tag(xml,l4,"autor",owner_name,uidstr(owner_id))
write_tag(xml,l4,"titulo",post_title,'')
......@@ -409,7 +422,8 @@ def write_groupvideos_subsection (db, xml, group_guid):
# 477 = select * from elgg_metastrings where string='video_url';
video_link=post_content(db,post_guid, 477)
xml.write(l3+"<video>\n")
attr=hrefstr('videos/view/',str(post_guid))
xml.write(l3+"<video"+attr+">\n")
write_tag(xml,l4,"autor",owner_name,uidstr(owner_id))
write_tag(xml,l4,"titulo",post_title,'')
......@@ -459,7 +473,8 @@ def write_groupevents_subsection (db, xml, group_guid):
# 30 = select * from elgg_metastrings where string='organizer';
organizer=post_content(db, post_guid, 30)
xml.write(l3+"<evento>\n")
attr=hrefstr('event_calendar/view/',str(post_guid))
xml.write(l3+"<evento"+attr+">\n")
write_tag(xml,l4,"autor",owner_name,uidstr(owner_id))
write_tag(xml,l4,"titulo",post_title,'')
......@@ -498,7 +513,8 @@ def write_groups_section(db, xml_file):
# 45 = select * from elgg_metastrings where string='briefdescription';
brief_desc=post_content(db,guid, 45)
xml.write(l1+"<comunidade"+cidstr(guid)+">\n")
attr=cidstr(guid)+hrefstr('groups/profile/',str(guid))
xml.write(l1+"<comunidade"+attr+">\n")
# Write all group's information
write_tag(xml,l2,"proprietario",owner_name,uidstr(owner_id))
......
......@@ -45,7 +45,7 @@ l7="\t\t\t\t\t\t\t"
# Argument: None
# Return: All member instances, and its info, from database.
qry_users_info = \
(" SELECT u.guid, u.name \
(" SELECT u.guid, u.name, u.username \
FROM elgg_entities e, elgg_users_entity u \
WHERE e.guid = u.guid \
AND (e.access_id = 1 OR e.access_id = 2); ")
......@@ -67,7 +67,7 @@ qry_user_posts = \
# Argument: Post_ID
# Return: All comments, and its info, made on the post.
qry_post_comments = \
(" SELECT u.guid, u.name, m.string, a.time_created \
(" SELECT u.guid, u.name, u.username, m.string, a.time_created \
FROM elgg_annotations a, elgg_metastrings m, elgg_users_entity u \
WHERE a.value_id = m.id AND a.owner_guid = u.guid \
AND (a.access_id = 1 OR a.access_id = 2) \
......@@ -79,7 +79,7 @@ qry_post_comments = \
# Argument: User_ID
# Return: All user friends' name
qry_user_friends = \
(" SELECT u.guid, u.name \
(" SELECT u.guid, u.name, u.username \
FROM elgg_users_entity u, elgg_entity_relationships r \
WHERE u.guid = r.guid_two \
AND r.guid_one = %s AND r.relationship = 'friend'; ")
......@@ -139,6 +139,13 @@ def cidstr(guid):
return uid_string
#--------------------------------------------------------------------#
#--------------------------------------------------------------------#
def hrefstr(prefix, guid):
http_str="http://participatorio.juventude.gov.br/"
href_string=" href="+"\'"+http_str+prefix+guid+"\'"
return href_string
#--------------------------------------------------------------------#
#--------------------------------------------------------------------#
def datestr(time):
if time != '':
......@@ -181,11 +188,12 @@ def write_comments (db, xml, post_guid):
post_comments.execute(qry_post_comments, (post_guid,))
xml.write(l4+"<comentarios>\n")
for (user_id, user_name, string, time) in post_comments:
for (user_id, user_name, user_username, string, time) in post_comments:
xml.write(l5+"<comentario>\n")
write_tag(xml,l6,"usuario",user_name,uidstr(user_id))
attr=uidstr(user_id)+hrefstr('profile/',user_username)
write_tag(xml,l6,"usuario",user_name,attr)
write_tag(xml,l6,"data",datestr(time),'')
write_tag(xml,l6,"mensagem",cdata(string),'')
......@@ -202,8 +210,9 @@ def write_userfriends_subsection (db, xml, user_guid):
friends_info.execute(qry_user_friends, (user_guid))
xml.write(l2+"<amigos>\n")
for (friend_id, friend_name) in friends_info:
write_tag(xml,l3,"usuario",friend_name,uidstr(friend_id))
for (friend_id, friend_name, friend_username) in friends_info:
attr=uidstr(friend_id)+hrefstr('profile/',friend_username)
write_tag(xml,l3,"usuario",friend_name,attr)
xml.write(l2+"</amigos>\n")
friends_info.close()
......@@ -216,7 +225,8 @@ def write_userowngroup_subsection (db, xml, user_guid):
xml.write(l3+"<dono>\n")
for (group_id, group_title) in user_owngroups:
write_tag(xml,l4,"comunidade",group_title,cidstr(group_id))
attr=cidstr(group_id)+hrefstr('groups/profile/',str(group_id))
write_tag(xml,l4,"comunidade",group_title,attr)
xml.write(l3+"</dono>\n")
user_owngroups.close()
......@@ -229,7 +239,8 @@ def write_usermembergroup_subsection (db, xml, user_guid):
xml.write(l3+"<membro>\n")
for (group_id, group_title) in user_membergroups:
write_tag(xml,l4,"comunidade",group_title,cidstr(group_id))
attr=cidstr(group_id)+hrefstr('groups/profile/',str(group_id))
write_tag(xml,l4,"comunidade",group_title,attr)
xml.write(l3+"</membro>\n")
user_membergroups.close()
......@@ -258,7 +269,8 @@ def write_userfiles_subsection (db, xml, user_guid):
link_prefix="http://participatorio.juventude.gov.br/file/download/"
file_link=str(link_prefix)+str(post_guid)
xml.write(l3+"<arquivo>\n")
attr=hrefstr('file/view/',str(post_guid))
xml.write(l3+"<arquivo"+attr+">\n")
write_tag(xml,l4,"titulo",post_title,'')
write_tag(xml,l4,"data",datestr(time),'')
......@@ -290,7 +302,8 @@ def write_userblogs_subsection (db, xml, user_guid):
# 64 = select * from elgg_metastrings where string='excerpt';
post_excerpt=post_content(db,post_guid,64)
xml.write(l3+"<blog>\n")
attr=hrefstr('blog/view/',str(post_guid))
xml.write(l3+"<blog"+attr+">\n")
write_tag(xml,l4,"titulo",post_title,'')
write_tag(xml,l4,"data",datestr(time),'')
......@@ -321,7 +334,8 @@ def write_userbookmarks_subsection (db, xml, user_guid):
# 90 = select * from elgg_metastrings where string='address';
bookmark_link=post_content(db,post_guid,90)
xml.write(l3+"<favorito>\n")
attr=hrefstr('bookmarks/view/',str(post_guid))
xml.write(l3+"<favorito"+attr+">\n")
write_tag(xml,l4,"titulo",post_title,'')
write_tag(xml,l4,"data",datestr(time),'')
......@@ -349,7 +363,8 @@ def write_userpages_subsection (db, xml, user_guid):
for (post_guid, post_title, post_desc, time)\
in user_pages:
xml.write(l3+"<pagina>\n")
attr=hrefstr('pages/view/',str(post_guid))
xml.write(l3+"<pagina"+attr+">\n")
write_tag(xml,l4,"titulo",post_title,'')
write_tag(xml,l4,"data",datestr(time),'')
......@@ -379,7 +394,8 @@ def write_uservideos_subsection (db, xml, user_guid):
# 477 = select * from elgg_metastrings where string='video_url';
video_link=post_content(db, post_guid, 477)
xml.write(l3+"<video>\n")
attr=hrefstr('videos/view/',str(post_guid))
xml.write(l3+"<video"+attr+">\n")
write_tag(xml,l4,"titulo",post_title,'')
write_tag(xml,l4,"data",datestr(time),'')
......@@ -402,6 +418,7 @@ def write_userevents_subsection (db, xml, user_guid):
# 6 = select * from elgg_entity_subtypes where subtype='calendar_event';
user_events.execute(qry_user_posts, (user_guid, user_guid, 6,))
xml.write(l2+"<eventos>\n")
for (post_guid, post_title, post_desc, time)\
......@@ -425,7 +442,8 @@ def write_userevents_subsection (db, xml, user_guid):
# 30 = select * from elgg_metastrings where string='organizer';
organizer=post_content(db, post_guid, 30)
xml.write(l3+"<evento>\n")
attr=hrefstr('event_calendar/view/',str(post_guid))
xml.write(l3+"<evento"+attr+">\n")
write_tag(xml,l4,"titulo",post_title,'')
write_tag(xml,l4,"data",datestr(time),'')
......@@ -458,9 +476,10 @@ def write_users_section (db, xml_file):
users_info = db.cursor()
users_info.execute(qry_users_info)
for (guid, name) in users_info:
for (guid, name, username) in users_info:
xml.write(l1+"<usuario"+uidstr(guid)+">\n")
attr=uidstr(guid)+hrefstr('profile/',username)
xml.write(l1+"<usuario"+attr+">\n")
# Write all user's information
write_tag(xml,l2,"nome",name,'')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment