From: <jli...@us...> - 2009-04-04 07:28:17
|
Revision: 315 http://pytrainer.svn.sourceforge.net/pytrainer/?rev=315&view=rev Author: jliljenfeldt Date: 2009-04-04 07:28:12 +0000 (Sat, 04 Apr 2009) Log Message: ----------- Wordpress export support working again. Added some more fields and translated blog output to English. Modified Paths: -------------- pytrainer/trunk/extensions/wordpress/googlemaps.py pytrainer/trunk/extensions/wordpress/main.py pytrainer/trunk/pytrainer/lib/soapUtils.py Modified: pytrainer/trunk/extensions/wordpress/googlemaps.py =================================================================== --- pytrainer/trunk/extensions/wordpress/googlemaps.py 2009-04-04 07:15:00 UTC (rev 314) +++ pytrainer/trunk/extensions/wordpress/googlemaps.py 2009-04-04 07:28:12 UTC (rev 315) @@ -18,17 +18,30 @@ import os import re - -from pytrainer.lib.gpx import Gpx -import pytrainer.lib.points as Points -from pytrainer.lib.fileUtils import fileUtils - +import sys +sys.path.insert(0,os.path.join(sys.path[0],'../../pytrainer/lib')) +from gpx import Gpx +import points as Points +from fileUtils import fileUtils +import fileinput def drawMap(gpxfile,key,htmlpath): cachefile = "/tmp/gpx.txt" trackdistance = 100 os.system("gpsbabel -t -i gpx -f %s -x position,distance=%sm -o gpx -F %s" %(gpxfile,trackdistance,cachefile)) + # Test if file already contains gpxdata attribute + found = False + for line in fileinput.FileInput(cachefile,inplace=1): + if "xmlns:gpxdata" in line: + found = True + print line.rstrip('\n'); + # If file don't has gpxdata attribute: add namespace + if not found: + for line in fileinput.FileInput(cachefile,inplace=1): + if "xmlns:xsi" in line: + line=line.replace('xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"','xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gpxdata="http://www.cluetrust.com/XML/GPXDATA/1/0"') + print line.rstrip('\n'); gpx = Gpx("",cachefile) list_values = gpx.getTrackList() pointlist = [] @@ -72,7 +85,7 @@ content += " </script>\n" content += " </head>\n" content += " <body onload=\"load()\" onunload=\"GUnload()\">\n" - content += " <div id=\"map\" style=\"width: 520px; height: 480px\"></div>\n" + content += " <div id=\"map\" style=\"width: 460px; height: 460px\"></div>\n" content += " </body>\n" content += "</html>\n" file = fileUtils(htmlpath,content) Modified: pytrainer/trunk/extensions/wordpress/main.py =================================================================== --- pytrainer/trunk/extensions/wordpress/main.py 2009-04-04 07:15:00 UTC (rev 314) +++ pytrainer/trunk/extensions/wordpress/main.py 2009-04-04 07:28:12 UTC (rev 315) @@ -4,9 +4,10 @@ from optparse import OptionParser import os import googlemaps +import sys +sys.path.insert(0,os.path.join(sys.path[0],'../../pytrainer/lib')) +from date import Date -from pytrainer.lib.date import Date - import SOAPpy class Main: @@ -40,9 +41,9 @@ hfile = self.wp.newMediaObject(htmlpath) kfile = self.wp.newMediaObject(kmlpath) - description_route = '''<strong>Route: <strong> <br/> - <iframe width='540' height='500' src='%s'> Need frame support </iframe><br/> - <a href='%s'>Gpx file</a> <a href='%s'>Kml file (GoogleEarth)</a><br/><br/>''' %(hfile,gfile,kfile) + description_route = '''<strong>Map: <strong> <br/> + <iframe width='480' height='480' src='%s'> Need frame support </iframe><br/> + <a href='%s'>Gpx-format</a> <a href='%s'>Kml-format (GoogleEarth)</a><br/><br/>''' %(hfile,gfile,kfile) return description_route def loadRecordInfo(self): @@ -59,9 +60,14 @@ self.title = record["title"] self.upositive = record["upositive"] self.unegative = record["unegative"] + self.unegative = record["unegative"] + self.maxspeed = record["maxspeed"] + self.maxpace = record["maxpace"] + self.pace = record["pace"] + self.maxbeats = record["maxbeats"] def createBody(self): - return '''<b> Descripcion: <b/><br/> + return '''<b> Description: </b><br/> %s<br/>''' %self.comments def createTable(self): @@ -69,47 +75,59 @@ <br/> <table border=0> <tr> - <td><strong>Deporte:</strong></td> + <td><strong>Activity:</strong></td> <td>%s</td> - <td><strong>Fecha:</strong></td> + <td><strong>Date:</strong></td> <td>%s</td> </tr> <tr> - <td><strong>Distancia:</strong></td> + <td><strong>Distance:</strong></td> <td>%s</td> - <td><strong>Tiempo:</strong></td> + <td><strong>Time (hh, mm, ss):</strong></td> <td>%s</td> </tr> <tr> - <td><strong>Calorias:</strong></td> + <td><strong>Max speed:</strong></td> <td>%s</td> - <td><strong>Media:</strong></td> + <td><strong>Avg speed (km/h):</strong></td> <td>%s</td> </tr> <tr> - <td><strong>Desnivel Positivo:</strong></td> + <td><strong>Max pace (min/km):</strong></td> <td>%s</td> - <td><strong>Desnivel Negativo:</strong></td> + <td><strong>Avg pace (min/km):</strong></td> <td>%s</td> </tr> + <tr> + <td><strong>Max pulse:</strong></td> + <td>%s</td> + <td><strong>Avg pulse:</strong></td> + <td>%s</td> + </tr> + <tr> + <td><strong>Acc elevation +:</strong></td> + <td>%s</td> + <td><strong>Acc elevation -:</strong></td> + <td>%s</td> + </tr> </table> - ''' %(self.sport,self.date,self.distance,self.time,self.calories,self.average,self.upositive,self.unegative) + ''' %(self.sport,self.date,self.distance,self.time,self.maxspeed,self.average,self.maxpace,self.pace,self.maxbeats,self.beats,self.upositive,self.unegative) return description_table def createFigures(self): - hr_fig_path = "/tmp/hr.png" - stage_fig_path = "/tmp/stage.png" - blog_figures = '' - # If there are no graphs, return empty string. + hr_fig_path = "/tmp/hr.png" + stage_fig_path = "/tmp/stage.png" + blog_figures = '' + # If there are no graphs, return empty string. if os.path.isfile(hr_fig_path) and os.path.isfile(stage_fig_path): - #the graph files are created because the graph tabs are automatically visited (which invokes graph generation) + #the graph files are created because the graph tabs are automatically visited (which invokes graph generation) hrfile = self.wp.newMediaObject(hr_fig_path) - stagefile = self.wp.newMediaObject(stage_fig_path) - blog_figures = '''<br/> <img src='%s' /> <img src='%s' /> <br/>''' %(hrfile, stagefile) - return blog_figures + stagefile = self.wp.newMediaObject(stage_fig_path) + blog_figures = '''<br/> <img src='%s' /> <img src='%s' /> <br/>''' %(hrfile, stagefile) + return blog_figures def createFoot(self): - return ''' <center>Powered by <a href='http://pytrainer.e-oss.net'>Pytrainer</a></center>''' + return ''' <center>Powered by <a href='http://sourceforge.net/projects/pytrainer/'>Pytrainer</a></center>''' def createTitle(self): if self.title==None: @@ -141,7 +159,7 @@ post.title = blog_title post.description = blog_body+blog_table+blog_route+blog_figures+blog_foot post.categories = blog_category - idNewPost = self.wp.newPost(post, False) + idNewPost = self.wp.newPost(post, True) return "The post has been submited" else: Modified: pytrainer/trunk/pytrainer/lib/soapUtils.py =================================================================== --- pytrainer/trunk/pytrainer/lib/soapUtils.py 2009-04-04 07:15:00 UTC (rev 314) +++ pytrainer/trunk/pytrainer/lib/soapUtils.py 2009-04-04 07:28:12 UTC (rev 315) @@ -47,7 +47,7 @@ ddbb = DDBB(configuration) ddbb.connect() recordinfo = ddbb.select("records,sports", - "sports.name,date,distance,time,beats,comments,average,calories,id_record,title,upositive,unegative", + "sports.name,date,distance,time,beats,comments,average,calories,id_record,title,upositive,unegative,maxspeed,maxpace,pace,maxbeats", "id_record=\"%s\" and records.sport=sports.id_sports" %id_record) record = recordinfo[0] info = {} @@ -62,6 +62,10 @@ info["title"] = record[9] info["upositive"] = record[10] info["unegative"] = record[11] + info["maxspeed"] = record[12] + info["maxpace"] = record[13] + info["pace"] = record[14] + info["maxbeats"] = record[15] return info def newRecord(self,title=None,distance=None,time=None,upositive=None, unegative=None, bpm=None,calories=None, date=None, comment=None): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |