Initial commit

This commit is contained in:
Carlos Santa Cruz
2011-08-23 09:34:28 -05:00
commit d11aeda3dc
12 changed files with 1139 additions and 0 deletions
View File
+276
View File
@@ -0,0 +1,276 @@
span.icon{ float: left; background-image: url('../images/fugue-sprite.png'); background-repeat: no-repeat; width: 16px; height: 16px; margin: 0px 3px 0px 0px; }span.abacus{ background-position: -0px -0px; }
span.alarm-clock-select{ background-position: -0px -16px; }
span.anchor{ background-position: -0px -32px; }
span.application-monitor{ background-position: -0px -48px; }
span.application-wave{ background-position: -0px -64px; }
span.arrow-branch-000-left{ background-position: -0px -80px; }
span.arrow-branch-090{ background-position: -0px -96px; }
span.asterisk{ background-position: -0px -112px; }
span.balloon-white-left{ background-position: -0px -128px; }
span.bandaid{ background-position: -0px -144px; }
span.brain{ background-position: -0px -160px; }
span.bread{ background-position: -0px -176px; }
span.burn{ background-position: -0px -192px; }
span.cake-plain{ background-position: -0px -208px; }
span.cake{ background-position: -0px -224px; }
span.calculator{ background-position: -16px -0px; }
span.calendar-list{ background-position: -16px -16px; }
span.calendar-month{ background-position: -16px -32px; }
span.camera-black{ background-position: -16px -48px; }
span.camera-lens{ background-position: -16px -64px; }
span.camera{ background-position: -16px -80px; }
span.car-red{ background-position: -16px -96px; }
span.car{ background-position: -16px -112px; }
span.card-address{ background-position: -16px -128px; }
span.cards-bind-address{ background-position: -16px -144px; }
span.cassette{ background-position: -16px -160px; }
span.certificate{ background-position: -16px -176px; }
span.chain{ background-position: -16px -192px; }
span.chart-up-color{ background-position: -16px -208px; }
span.chart-up{ background-position: -16px -224px; }
span.clock-frame{ background-position: -32px -0px; }
span.clock-select{ background-position: -32px -16px; }
span.clock{ background-position: -32px -32px; }
span.co2{ background-position: -32px -48px; }
span.compass{ background-position: -32px -64px; }
span.cookie-bite{ background-position: -32px -80px; }
span.cookie-chocolate{ background-position: -32px -96px; }
span.cookie{ background-position: -32px -112px; }
span.counter-count-up{ background-position: -32px -128px; }
span.counter-count{ background-position: -32px -144px; }
span.counter-reset{ background-position: -32px -160px; }
span.counter-stop{ background-position: -32px -176px; }
span.counter{ background-position: -32px -192px; }
span.credit-card{ background-position: -32px -208px; }
span.crown{ background-position: -32px -224px; }
span.cup-empty{ background-position: -48px -0px; }
span.cup-tea{ background-position: -48px -16px; }
span.cup{ background-position: -48px -32px; }
span.cutleries{ background-position: -48px -48px; }
span.cutlery{ background-position: -48px -64px; }
span.dashboard-network{ background-position: -48px -80px; }
span.dashboard{ background-position: -48px -96px; }
span.database{ background-position: -48px -112px; }
span.diamond{ background-position: -48px -128px; }
span.direction{ background-position: -48px -144px; }
span.disc-blue{ background-position: -48px -160px; }
span.disc-label{ background-position: -48px -176px; }
span.disc{ background-position: -48px -192px; }
span.door{ background-position: -48px -208px; }
span.drawer{ background-position: -48px -224px; }
span.drill{ background-position: -64px -0px; }
span.envelope{ background-position: -64px -16px; }
span.equalizer{ background-position: -64px -32px; }
span.eraser{ background-position: -64px -48px; }
span.eye{ background-position: -64px -64px; }
span.fingerprint-recognition{ background-position: -64px -80px; }
span.fingerprint{ background-position: -64px -96px; }
span.fire-big{ background-position: -64px -112px; }
span.fire{ background-position: -64px -128px; }
span.flag-black{ background-position: -64px -144px; }
span.flag-blue{ background-position: -64px -160px; }
span.flag-gray{ background-position: -64px -176px; }
span.flag-green{ background-position: -64px -192px; }
span.flag-pink{ background-position: -64px -208px; }
span.flag-purple{ background-position: -64px -224px; }
span.flag-white{ background-position: -80px -0px; }
span.flag-yellow{ background-position: -80px -16px; }
span.flag{ background-position: -80px -32px; }
span.flashlight{ background-position: -80px -48px; }
span.fruit-lime{ background-position: -80px -64px; }
span.fruit-orange{ background-position: -80px -80px; }
span.fruit{ background-position: -80px -96px; }
span.gear{ background-position: -80px -112px; }
span.gender-female{ background-position: -80px -128px; }
span.gender{ background-position: -80px -144px; }
span.glass-empty{ background-position: -80px -160px; }
span.glass{ background-position: -80px -176px; }
span.globe-green{ background-position: -80px -192px; }
span.globe-model{ background-position: -80px -208px; }
span.globe-place{ background-position: -80px -224px; }
span.globe{ background-position: -96px -0px; }
span.hamburger{ background-position: -96px -16px; }
span.hand-point{ background-position: -96px -32px; }
span.hand{ background-position: -96px -48px; }
span.hard-hat-military{ background-position: -96px -64px; }
span.hard-hat-mine{ background-position: -96px -80px; }
span.hard-hat{ background-position: -96px -96px; }
span.headphone{ background-position: -96px -112px; }
span.heart-empty{ background-position: -96px -128px; }
span.heart{ background-position: -96px -144px; }
span.home{ background-position: -96px -160px; }
span.hourglass-select-remain{ background-position: -96px -176px; }
span.hourglass-select{ background-position: -96px -192px; }
span.hourglass{ background-position: -96px -208px; }
span.ice{ background-position: -96px -224px; }
span.image-empty{ background-position: -112px -0px; }
span.jar-empty{ background-position: -112px -16px; }
span.jar-label{ background-position: -112px -32px; }
span.jar{ background-position: -112px -48px; }
span.key{ background-position: -112px -64px; }
span.keyboard{ background-position: -112px -80px; }
span.layer-shape-curve{ background-position: -112px -96px; }
span.leaf-plant{ background-position: -112px -112px; }
span.leaf-red{ background-position: -112px -128px; }
span.leaf-wormhole{ background-position: -112px -144px; }
span.leaf-yellow{ background-position: -112px -160px; }
span.leaf{ background-position: -112px -176px; }
span.license-key{ background-position: -112px -192px; }
span.lifebuoy{ background-position: -112px -208px; }
span.light-bulb-off{ background-position: -112px -224px; }
span.light-bulb{ background-position: -128px -0px; }
span.lightning{ background-position: -128px -16px; }
span.lock{ background-position: -128px -32px; }
span.lollipop{ background-position: -128px -48px; }
span.luggage{ background-position: -128px -64px; }
span.magnet{ background-position: -128px -80px; }
span.magnifier{ background-position: -128px -96px; }
span.mail{ background-position: -128px -112px; }
span.map{ background-position: -128px -128px; }
span.marker{ background-position: -128px -144px; }
span.medal-bronze-red{ background-position: -128px -160px; }
span.medal-bronze{ background-position: -128px -176px; }
span.medal-red{ background-position: -128px -192px; }
span.medal-silver-red{ background-position: -128px -208px; }
span.medal-silver{ background-position: -128px -224px; }
span.medal{ background-position: -144px -0px; }
span.megaphone{ background-position: -144px -16px; }
span.money-coin{ background-position: -144px -32px; }
span.money{ background-position: -144px -48px; }
span.monitor{ background-position: -144px -64px; }
span.monkey-sulky{ background-position: -144px -80px; }
span.monkey{ background-position: -144px -96px; }
span.new-text{ background-position: -144px -112px; }
span.paper-bag{ background-position: -144px -128px; }
span.paper-plane{ background-position: -144px -144px; }
span.pearl{ background-position: -144px -160px; }
span.picture{ background-position: -144px -176px; }
span.piggy-bank{ background-position: -144px -192px; }
span.pill{ background-position: -144px -208px; }
span.pin{ background-position: -144px -224px; }
span.plate-cutlery{ background-position: -160px -0px; }
span.plate{ background-position: -160px -16px; }
span.plug{ background-position: -160px -32px; }
span.point-bronze{ background-position: -160px -48px; }
span.point-silver{ background-position: -160px -64px; }
span.point{ background-position: -160px -80px; }
span.postage-stamp{ background-position: -160px -96px; }
span.present{ background-position: -160px -112px; }
span.price-tag-label{ background-position: -160px -128px; }
span.price-tag{ background-position: -160px -144px; }
span.puzzle{ background-position: -160px -160px; }
span.quill{ background-position: -160px -176px; }
span.radar{ background-position: -160px -192px; }
span.radioactivity{ background-position: -160px -208px; }
span.rainbow{ background-position: -160px -224px; }
span.receipt{ background-position: -176px -0px; }
span.robot{ background-position: -176px -16px; }
span.rocket-fly{ background-position: -176px -32px; }
span.rocket{ background-position: -176px -48px; }
span.ruby{ background-position: -176px -64px; }
span.ruler-crop{ background-position: -176px -80px; }
span.ruler-triangle{ background-position: -176px -96px; }
span.ruler{ background-position: -176px -112px; }
span.safe{ background-position: -176px -128px; }
span.screwdriver{ background-position: -176px -144px; }
span.service-bell{ background-position: -176px -160px; }
span.shield{ background-position: -176px -176px; }
span.shopping-basket{ background-position: -176px -192px; }
span.shovel{ background-position: -176px -208px; }
span.slash{ background-position: -176px -224px; }
span.soap{ background-position: -192px -0px; }
span.socket{ background-position: -192px -16px; }
span.sofa{ background-position: -192px -32px; }
span.solar-panel{ background-position: -192px -48px; }
span.speaker-volume{ background-position: -192px -64px; }
span.speaker{ background-position: -192px -80px; }
span.spectacle-sunglass{ background-position: -192px -96px; }
span.spectacle{ background-position: -192px -112px; }
span.spray{ background-position: -192px -128px; }
span.stamp{ background-position: -192px -144px; }
span.star-empty{ background-position: -192px -160px; }
span.star-half{ background-position: -192px -176px; }
span.star{ background-position: -192px -192px; }
span.sticky-note-text{ background-position: -192px -208px; }
span.sticky-note{ background-position: -192px -224px; }
span.switch{ background-position: -208px -0px; }
span.system-monitor{ background-position: -208px -16px; }
span.t-shirt-gray{ background-position: -208px -32px; }
span.t-shirt-print-gray{ background-position: -208px -48px; }
span.t-shirt-print{ background-position: -208px -64px; }
span.t-shirt{ background-position: -208px -80px; }
span.table{ background-position: -208px -96px; }
span.tag{ background-position: -208px -112px; }
span.target{ background-position: -208px -128px; }
span.telephone{ background-position: -208px -144px; }
span.television-off{ background-position: -208px -160px; }
span.television-test{ background-position: -208px -176px; }
span.television{ background-position: -208px -192px; }
span.thermometer-high{ background-position: -208px -208px; }
span.thermometer-low{ background-position: -208px -224px; }
span.thermometer{ background-position: -224px -0px; }
span.thumb-up{ background-position: -224px -16px; }
span.thumb{ background-position: -224px -32px; }
span.tick{ background-position: -224px -48px; }
span.ticket{ background-position: -224px -64px; }
span.tie{ background-position: -224px -80px; }
span.toolbox{ background-position: -224px -96px; }
span.traffic-cone{ background-position: -224px -112px; }
span.traffic-light{ background-position: -224px -128px; }
span.trophy-bronze{ background-position: -224px -144px; }
span.trophy-silver{ background-position: -224px -160px; }
span.trophy{ background-position: -224px -176px; }
span.truck{ background-position: -224px -192px; }
span.ui-button-navigation{ background-position: -224px -208px; }
span.umbrella{ background-position: -224px -224px; }
span.usb-flash-drive-logo{ background-position: -240px -0px; }
span.usb-flash-drive{ background-position: -240px -16px; }
span.user-black-female{ background-position: -240px -32px; }
span.user-black{ background-position: -240px -48px; }
span.user-business-boss{ background-position: -240px -64px; }
span.user-business-gray-boss{ background-position: -240px -80px; }
span.user-business-gray{ background-position: -240px -96px; }
span.user-business{ background-position: -240px -112px; }
span.user-detective-gray{ background-position: -240px -128px; }
span.user-detective{ background-position: -240px -144px; }
span.user-female{ background-position: -240px -160px; }
span.user-gray-female{ background-position: -240px -176px; }
span.user-gray{ background-position: -240px -192px; }
span.user-medical-female{ background-position: -240px -208px; }
span.user-medical{ background-position: -240px -224px; }
span.user-thief-baldie{ background-position: -256px -0px; }
span.user-thief-female{ background-position: -256px -16px; }
span.user-thief{ background-position: -256px -32px; }
span.user-white-female{ background-position: -256px -48px; }
span.user-white{ background-position: -256px -64px; }
span.user-worker-boss{ background-position: -256px -80px; }
span.user-worker{ background-position: -256px -96px; }
span.user-yellow-female{ background-position: -256px -112px; }
span.user-yellow{ background-position: -256px -128px; }
span.user{ background-position: -256px -144px; }
span.vise{ background-position: -256px -160px; }
span.wall-break{ background-position: -256px -176px; }
span.wall-brick{ background-position: -256px -192px; }
span.wall{ background-position: -256px -208px; }
span.wallet{ background-position: -256px -224px; }
span.wand-hat{ background-position: -272px -0px; }
span.water{ background-position: -272px -16px; }
span.weather-cloud{ background-position: -272px -32px; }
span.weather-clouds{ background-position: -272px -48px; }
span.weather-cloudy{ background-position: -272px -64px; }
span.weather-fog{ background-position: -272px -80px; }
span.weather-lightning{ background-position: -272px -96px; }
span.weather-moon-clouds{ background-position: -272px -112px; }
span.weather-moon-fog{ background-position: -272px -128px; }
span.weather-moon{ background-position: -272px -144px; }
span.weather-rain{ background-position: -272px -160px; }
span.weather-snow{ background-position: -272px -176px; }
span.weather-tornado{ background-position: -272px -192px; }
span.weather{ background-position: -272px -208px; }
span.webcam{ background-position: -272px -224px; }
span.weight{ background-position: -288px -0px; }
span.wheel{ background-position: -288px -16px; }
span.wooden-box-label{ background-position: -288px -32px; }
span.wooden-box{ background-position: -288px -48px; }
span.wrench-screwdriver{ background-position: -288px -64px; }
span.wrench{ background-position: -288px -80px; }
+36
View File
@@ -0,0 +1,36 @@
@CHARSET "UTF-8";
.ride-item:before {
content: "";
width: 16px;
height: 16px;
float: left;
background: url('../images/fugue-sprite.png') -48px -96px no-repeat;
margin: 0 6px 2px 0;
}
.table {
display: table;
margin: 0 auto;
}
#ride-details-table tr td {
padding: 5px;
}
#ride-details-table th {
padding: 5px;
text-align: center;
font-size: 0.8em;
}
#ride-details-table td {
text-align: center;
border: 1px solid #e7e7e7;
}
.ride-details-table-info {
font-size: 1.2em;
font-weight: bold;
text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.4);
}
.ride-details-table-units {
font-size: 0.8em;
}
.map img {
max-width: none;
}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

+6
View File
@@ -0,0 +1,6 @@
#!/bin/bash
/usr/bin/xgettext --language=PHP --indent --keyword=__ --keyword=_e --keyword=__ngettext:1,2 -s -n --from-code=UTF8 \
../wp-strava.php \
../readme.txt
msgfmt -o es_ES.mo messages.es_ES.po
Executable
BIN
View File
Binary file not shown.
+89
View File
@@ -0,0 +1,89 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# Carlos Santa Cruz <cmanon@gmail.com>, 2011.
#
#, fuzzy
msgid ""
msgstr "Project-Id-Version: wp-strava-0.5\n"
"Report-Msgid-Bugs-To: Carlos Santa Cruz\n"
"POT-Creation-Date: 2011-06-30 08:42-0500\n"
"PO-Revision-Date: 2011-06-30 08:42-0500\n"
"Last-Translator: Carlos Santa Cruz <cmanon@gmail.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: ../wp-strava.php:221
msgid " climbing "
msgstr " escalando "
#: ../wp-strava.php:220
msgid " during "
msgstr " durante "
#: ../wp-strava.php:219
msgid " rode "
msgstr " rodo "
#: ../wp-strava.php:92
msgid "Athlete"
msgstr "Atleta"
#: ../wp-strava.php:93
msgid "Club"
msgstr "Club"
#: ../wp-strava.php:168
msgid "Could not get information from strava.com for the ride id: "
msgstr "No se pudo obtener informacion desde strava.com para la rodada numero: "
#: ../wp-strava.php:218
msgid "On "
msgstr "El dia "
#: ../wp-strava.php:207
msgid "Please configure the Strava search id on the widget options."
msgstr "Por favor configura la opcion buscar identificador Strava en las opciones del widget."
#: ../wp-strava.php:173
msgid "Please provide the rides array to be processed."
msgstr "Por favor proporciona el arreglo de rodadas para ser procesado."
#: ../wp-strava.php:126
msgid "Please specify your Strava athlete name."
msgstr "Por favor configura tu nombre de atleta/club."
#: ../wp-strava.php:101
msgid "Quantity:"
msgstr "Cantidad:"
#: ../wp-strava.php:49 ../wp-strava.php:79
msgid "Rides"
msgstr "Rodadas"
#: ../wp-strava.php:97
msgid "Search Id:"
msgstr "Id Busqueda"
#: ../wp-strava.php:90
msgid "Search Option:"
msgstr "Opcion Busqueda"
#: ../wp-strava.php:195
msgid "There was an error pulling data of strava.com."
msgstr "Hubo un error al obtener informacion de strava.com"
#: ../wp-strava.php:189
msgid "There's an error on the widget options combination."
msgstr "Existe un error en la combinacion de opciones del widget."
#: ../wp-strava.php:86
msgid "Title:"
msgstr "Titulo:"
#: ../wp-strava.php:39
msgid "Will publish your latest rides activity from strava.com."
msgstr "Publicara las ultimas rodadas registradas en el sitio strava.com."
+89
View File
@@ -0,0 +1,89 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# Carlos Santa Cruz <cmanon@gmail.com>, 2011.
#
#, fuzzy
msgid ""
msgstr "Project-Id-Version: wp-strava-0.5\n"
"Report-Msgid-Bugs-To: Carlos Santa Cruz\n"
"POT-Creation-Date: 2011-06-30 08:42-0500\n"
"PO-Revision-Date: 2011-06-30 08:42-0500\n"
"Last-Translator: Carlos Santa Cruz <cmanon@gmail.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: ../wp-strava.php:221
msgid " climbing "
msgstr " escalando "
#: ../wp-strava.php:220
msgid " during "
msgstr " durante "
#: ../wp-strava.php:219
msgid " rode "
msgstr " rodo "
#: ../wp-strava.php:92
msgid "Athlete"
msgstr "Atleta"
#: ../wp-strava.php:93
msgid "Club"
msgstr "Club"
#: ../wp-strava.php:168
msgid "Could not get information from strava.com for the ride id: "
msgstr "No se pudo obtener informacion desde strava.com para la rodada numero: "
#: ../wp-strava.php:218
msgid "On "
msgstr "El dia "
#: ../wp-strava.php:207
msgid "Please configure the Strava search id on the widget options."
msgstr "Por favor configura la opcion buscar identificador Strava en las opciones del widget."
#: ../wp-strava.php:173
msgid "Please provide the rides array to be processed."
msgstr "Por favor proporciona el arreglo de rodadas para ser procesado."
#: ../wp-strava.php:126
msgid "Please specify your Strava athlete name."
msgstr "Por favor configura tu nombre de atleta/club."
#: ../wp-strava.php:101
msgid "Quantity:"
msgstr "Cantidad:"
#: ../wp-strava.php:49 ../wp-strava.php:79
msgid "Rides"
msgstr "Rodadas"
#: ../wp-strava.php:97
msgid "Search Id:"
msgstr "Id Busqueda"
#: ../wp-strava.php:90
msgid "Search Option:"
msgstr "Opcion Busqueda"
#: ../wp-strava.php:195
msgid "There was an error pulling data of strava.com."
msgstr "Hubo un error al obtener informacion de strava.com"
#: ../wp-strava.php:189
msgid "There's an error on the widget options combination."
msgstr "Existe un error en la combinacion de opciones del widget."
#: ../wp-strava.php:86
msgid "Title:"
msgstr "Titulo:"
#: ../wp-strava.php:39
msgid "Will publish your latest rides activity from strava.com."
msgstr "Publicara las ultimas rodadas registradas en el sitio strava.com."
Executable
+63
View File
@@ -0,0 +1,63 @@
=== Plugin Name ===
Contributors: cmanon (@cmanon)
Donate link: http://cmanon.com/
Tags: bycicle, strava
Requires at least: 2.0
Tested up to: 3.1
Stable tag: 0.61
This plugin is inteneded to show your strava.com information in your wordpress blog.
== Description ==
This plugin uses the REST strava.com API to pull the data out and show the information in your wordpress blog.
== Installation ==
1. Upload `plugin-name.php` to the `/wp-content/plugins/` directory
1. Activate the plugin through the 'Plugins' menu in WordPress
1. Place `<?php do_action('plugin_name_hook'); ?>` in your templates
== Frequently Asked Questions ==
= A question that someone might have =
An answer to that question.
= What about foo bar? =
Answer to foo bar dilemma.
== Screenshots ==
1. This screen shot description corresponds to screenshot-1.(png|jpg|jpeg|gif). Note that the screenshot is taken from
the directory of the stable readme.txt, so in this case, `/tags/4.3/screenshot-1.png` (or jpg, jpeg, gif)
2. This is the second screen shot
== Changelog ==
= 0.61 =
Added option to select unit of measurements on the widget.
= 0.6 =
Initial version.
== Arbitrary section ==
You may provide arbitrary sections, in the same format as the ones above. This may be of use for extremely complicated
plugins where more information needs to be conveyed that doesn't fit into the categories of "description" or
"installation." Arbitrary sections will be shown below the built-in sections outlined above.
== A brief Markdown Example ==
Ordered list:
1. Some feature
1. Another feature
1. Something else about the plugin
Unordered list:
* something
* something else
* third thing
+147
View File
@@ -0,0 +1,147 @@
<?php
namespace WP\Strava;
/*
* WP\Strava\Rides is a class wrapper for the Strava REST API functions.
*/
class Rides {
private $rideUrl = "http://www.strava.com/api/v1/rides/:id";
private $ridesUrl = "http://www.strava.com/api/v1/rides";
private $authenticationUrl = "https://www.strava.com/api/v1/authentication/login";
private $rideMapDetailsUrl = "http://www.strava.com/api/v1/rides/:id/map_details";
private $rideMapDetailsUrlv2 = "http://www.strava.com/api/v2/rides/:id/map_details";
public $ridesLinkUrl = "http://app.strava.com/rides/";
public $stravaRides;
public $feedback;
public function __construct() {
// Empty constructor
} // __construct
public function getRideDetails($rideId, $systemOfMeasurement) {
$url = preg_replace('/:id/', $rideId, $this->rideUrl);
//$url = $this->ridesUrl . $rideId;
$json = file_get_contents($url);
if($json) {
$strava_ride = json_decode($json);
//Transform data to a ready to be displayed format
$startDate = date("F j, Y - H:i a", strtotime($strava_ride->ride->startDateLocal));
$elapsedTime = date("H:i:s", mktime(0, 0, $strava_ride->ride->elapsedTime));
$movingTime = date("H:i:s", mktime(0, 0, $strava_ride->ride->movingTime));
if ($systemOfMeasurement == "metric") {
//To km
$distance = number_format($strava_ride->ride->distance/1000, 2);
//To km/h
$averageSpeed = number_format($strava_ride->ride->averageSpeed * 3.6, 2);
//To km/h
$maximumSpeed = number_format($strava_ride->ride->maximumSpeed/1000, 2);
//It is already in meters
$elevationGain = number_format($strava_ride->ride->elevationGain, 2);
} elseif ($systemOfMeasurement == "english") {
//To miles
$distance = number_format($strava_ride->ride->distance/1609.34, 2);
//To miles/h
$averageSpeed = number_format($strava_ride->ride->averageSpeed * 2.2369, 2);
//To miles/h
$maximumSpeed = number_format($strava_ride->ride->maximumSpeed/1609.34, 2);
//To foot
$elevationGain = number_format($strava_ride->ride->elevationGain/0.3048, 2);
}
$ride_details = array(
'id' => $rideId,
'name' => $strava_ride->ride->name,
//'description' => $stravaRide->rides->description,
'startDate' => $startDate,
'elapsedTime' => $elapsedTime,
'movingTime' => $movingTime,
'distance' => $distance,
'averageSpeed' => $averageSpeed,
'maximumSpeed' => $maximumSpeed,
'elevationGain' => $elevationGain
);
return $ride_details;
} else {
$this->feedback .= _e("Could not get information from strava.com for the ride id: ") . $stravaRide->id;
return false;
}
} // getRideDetails
public function getRidesDetails($systemOfMeasurement) {
if($this->stravaRides) {
$rides_details = array();
foreach($this->stravaRides as $stravaRide) {
$rides_details[] = $this->getRideDetails($stravaRide->id, $systemOfMeasurement);
}
return $rides_details;
} else {
$this->feedback .= _e("Please provide the rides array to be processed.", "wp-strava");
return false;
}
} // getRidesDetails
public function getLatestRides($searchOption, $searchId, $quantity) {
$url = $this->ridesUrl;
//Get the json results using the constructor specified values.
if($searchOption == "athlete") {
if(is_numeric($searchId)) {
$json = file_get_contents($url . '?athleteId=' . urlencode($searchId));
} else {
$json = file_get_contents($url . '?athleteName=' . urlencode($searchId));
}
} elseif ($this->searchOption == "club" AND is_numeric($searchId)) {
$json = file_get_contents($url . '?clubId=' . urlencode($searchId));
} else {
$this->feedback .= _e("There's an error on the widget options combination.", "wp-strava");
}
if($json) {
$strava_rides = json_decode($json);
$this->stravaRides = array_slice($strava_rides->rides, 0, $quantity);
} else {
$this->feedback .= _e("There was an error pulling data of strava.com.", "wp-strava");
return false;
}
} // getLatestRides
public function getAuthenticationToken($email, $password) {
$util = new Util;
$data = array('email' => $email, 'password' => $password);
$json = $util->makePostRequest($this->authenticationUrl, $data);
if($json) {
$strava_login = json_decode($json);
if($strava_login->success == "true") {
$this->feedback .= __('Successfully authenticated.', 'wp-strava');
return $strava_login->token;
} else {
$this->feedback .= __('Authentication failed, please check your credentials.', 'wp-strava');
return false;
}
} else {
$this->feedback .= __('There was an error pulling data of strava.com.', 'wp-strava');
return false;
}
} // getAuthenticationToken
public function getRideMap($rideId, $token, $efforts, $threshold) {
if($rideId != 0 AND $token != "") {
$url = preg_replace('/:id/', $rideId, $this->rideMapDetailsUrlv2);
$json = file_get_contents($url . '?token=' . $token . '&threshold=' . $threshold);
if($json) {
//$map_details = json_decode($json);
//return $map_details;
return $json;
} else {
$this->feedback .= _e("There was an error pulling data of strava.com.", "wp-strava");
return false;
}
} else {
$this->feedback .= _e("You need to provide both parameters to complete the call.", "wp-strava");
return false;
}
} // getRideDetails
} // class Rides
?>
Executable
+58
View File
@@ -0,0 +1,58 @@
<?php
namespace WP\Strava;
/*
* WP\Strava\Util is a class with all the utility methods.
*/
class Util {
public function makePostRequest ($url, $data) {
$data = http_build_query($data);
$url = parse_url($url);
if ($url['scheme'] == "http") {
$port = 80;
$domain = "tcp://";
} elseif ($url['scheme'] == "https") {
$port = 443;
$domain = "ssl://";
} else {
$this->feedback .= __('This function only support http and https', 'wp-strava');
return false;
}
$host = $url['host'];
$path = $url['path'];
$protocol = $url['scheme'] . "://";
// Open a socket connection to the specified port - timeout 30 seconds
$fp = fsockopen($domain . $host, $port, $error_number, $error_string, 30);
if ($fp) {
// Build the request headers and data
$request = "POST " . $protocol . $host . $path . " HTTP/1.0\r\n";
$request .= "Host: " . $host . "\r\n";
$request .= "Content-Type: application/x-www-form-urlencoded\r\n";
$request .= "Content-Length: " . strlen($data) . "\r\n";
$request .= "Connection: close\r\n\r\n";
$request .= $data;
fputs($fp, $request);
$result = "";
while (!feof($fp)) {
$result .= fgets($fp, 128);
}
} else {
$this->feedback .= __('ERROR - ' . $error_string . '-' . $error_number, 'wp-strava');
return false;
}
fclose($fp);
// Split the result header from the content
$result = explode("\r\n\r\n", $result, 2);
$header = isset($result[0]) ? $result[0] : '';
$content = isset($result[1]) ? $result[1] : '';
return $content;
} // makePostRequest
} // class Util
Executable
+375
View File
@@ -0,0 +1,375 @@
<?php
namespace WP\Strava;
require_once 'rides.class.php';
require_once 'util.class.php';
/*
Plugin Name: WP Strava
Plugin URI: http://cmanon.com
Description: Plugin to show your strava.com information in your wordpress blog. Some Icons are Copyright © Yusuke Kamiyamane. All rights reserved. Licensed under a Creative Commons Attribution 3.0 license.
Version: 0.61
Author: Carlos Santa Cruz (cmanon)
Author URI: http://cmanon.com
License: GPL2
*/
?>
<?php
/* Copyright 2011 Carlos Santa Cruz (email : cmanon at gmail dot com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
?>
<?php
// Load the multilingual support.
if(file_exists(dirname(__FILE__) . '/lang/' . get_locale() . '.mo' ) ) {
load_textdomain('wp-strava', dirname(__FILE__) . '/lang/' . get_locale() . '.mo' );
}
// Creating the admin menu options
//add_action('admin_menu', '\WP\Strava\wp_strava_plugin_menu');
function wp_strava_plugin_menu() {
add_options_page('WP Strava Options', 'WP Strava', 'manage_options', '\WP\Strava\wp-strava-options', '\WP\Strava\wp_strava_plugin_options');
add_action('admin_init', '\WP\Strava\register_strava_settings');
}
function register_strava_settings() {
register_setting('wp-strava-settings-group','strava_email');
register_setting('wp-strava-settings-group','strava_token');
//register_setting('wp-strava-settings-group','strava_som');
}
function wp_strava_plugin_options() {
if (!current_user_can('administrator')) {
wp_die(__('You do not have sufficient permissions to access this page.'));
}
if(isset($_POST['strava_email'])) {
$email = is_email($_POST['strava_email']);
if(!$email OR $_POST['strava_password'] == "") {
update_option('strava_email', $_POST['strava_email']);
echo '<div class="error"><p><strong>' . __('Please include your strava email and password the password will not be stored.', 'wp-strava' ) . '</strong></p></div>';
} else {
$ride = new Rides();
$token = $ride->getAuthenticationToken($email, $_POST['strava_password']);
if($token) {
update_option('strava_token', $token);
echo '<div class="updated"><p><strong>' . $ride->feedback . __('Token saved.', 'wp-strava' ) . '</strong></p></div>';
} else {
echo '<div class="error"><p><strong>' . $ride->feedback . '</strong></p></div>';
}
}
}
?>
<div class="wrap">
<div id="icon-options-general" class="icon32"><br/></div>
<h2><?php _e('WP Strava Options','wp-strava'); ?></h2>
<p><?php _e('Please specify the options below in order to obtain an authentication token, this will work with the Strava shortcodes supported by this plugin, the widget options are independant.', 'wp-strava');?> </p>
<form method="post" action="">
<?php //settings_fields('wp-strava-settings-group'); ?>
<?php //do_settings_fields('wp-strava-settings-group'); ?>
<table class="form-table">
<tr valign="top">
<th scope="row">Email</th>
<td><input type="text" id="strava_email" name="strava_email" size=50 value="<?php echo get_option('strava_email'); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row">Password</th>
<td><input type="password" id="strava_password" name="strava_password" size=50 value="" /></td>
</tr>
<tr valign="top">
<th scope="row">Token</th>
<td><input type="text" id="strava_token" name="strava_token" size=50 value="<?php echo get_option('strava_token'); ?>" disabled /></td>
</tr>
</table>
<p class="submit">
<input type="submit" class="button-primary" value="<?php _e('Save Changes'); ?>" />
</p>
</form>
</div>
<?php } // Finished admin menu options
// Load required javascript libraries
wp_enqueue_script('jquery');
//wp_enqueue_script('google-maps', 'http://maps.google.com/maps/api/js?sensor=false');
// Register a personalized stylesheet
wp_register_style('wp-strava', plugins_url('css/wp-strava.css', __FILE__));
/**
* WP Strava Latest Rides Widget Class
*/
class LatestRidesWidget extends \WP_Widget {
function __construct() {
$widget_ops = array('classname' => 'LatestRidesWidget', 'description' => __( 'Will publish your latest rides activity from strava.com.') );
parent::__construct('wp-strava', $name = 'Strava Latest Rides', $widget_ops);
wp_enqueue_style('wp-strava');
}
/** @see WP_Widget::widget */
function widget($args, $instance) {
extract($args);
//$widget_id = $args['widget_id'];
$title = apply_filters('widget_title', empty($instance['title']) ? _e('Rides', 'wp-strava') : $instance['title']);
$strava_search_option = empty($instance['strava_search_option']) ? 'athlete' : $instance['strava_search_option'];
$strava_som_option = empty($instance['strava_som_option']) ? 'metric' : $instance['strava_som_option'];
$strava_search_id = empty($instance['strava_search_id']) ? '' : $instance['strava_search_id'];
$quantity = empty($instance['quantity']) ? '5' : $instance['quantity'];
?>
<?php echo $before_widget; ?>
<?php if ( $title ) echo $before_title . $title . $after_title; ?>
<?php echo strava_request_handler($strava_search_option, $strava_search_id, $strava_som_option, $quantity); ?>
<?php echo $after_widget; ?>
<?php
}
/** @see WP_Widget::update */
function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
if(in_array($new_instance['strava_search_option'], array('athlete', 'club'))) {
$instance['strava_search_option'] = $new_instance['strava_search_option'];
} else {
$instance['strava_search_option'] = 'athlete';
}
if(in_array($new_instance['strava_som_option'], array('metric', 'english'))) {
$instance['strava_som_option'] = $new_instance['strava_som_option'];
} else {
$instance['strava_som_option'] = 'metric';
}
$instance['strava_search_id'] = strip_tags($new_instance['strava_search_id']);
$instance['quantity'] = $new_instance['quantity'];
return $instance;
}
/** @see WP_Widget::form */
function form($instance) {
$title = isset($instance['title']) ? esc_attr($instance['title']) : _e('Rides', 'wp-strava');
$strava_search_option = isset($instance['strava_search_option']) ? esc_attr($instance['strava_search_option']) : "athlete";
$strava_som_option = isset($instance['strava_som_option']) ? esc_attr($instance['strava_som_option']) : "metric";
$strava_search_id = isset($instance['strava_search_id']) ? esc_attr($instance['strava_search_id']) : "";
$quantity = isset($instance['quantity']) ? absint($instance['quantity']) : 5;
?>
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id('strava_search_option'); ?>"><?php _e('Search Option:'); ?></label>
<select class="widefat" id="<?php echo $this->get_field_id('strava_search_option'); ?>" name="<?php echo $this->get_field_name('strava_search_option'); ?>">
<option value="athlete" <?php selected($strava_search_option, 'athlete'); ?>><?php _e("Athlete", "wp-strava")?></option>
<option value="club" <?php selected($strava_search_option, 'club'); ?>><?php _e("Club", "wp-strava")?></option>
</select>
</p>
<p>
<label for="<?php echo $this->get_field_id('strava_som_option'); ?>"><?php _e('System of Measurement:'); ?></label>
<select class="widefat" id="<?php echo $this->get_field_id('strava_som_option'); ?>" name="<?php echo $this->get_field_name('strava_som_option'); ?>">
<option value="metric" <?php selected($strava_som_option, 'metric'); ?>><?php _e("Metric", "wp-strava")?></option>
<option value="english" <?php selected($strava_som_option, 'english'); ?>><?php _e("English", "wp-strava")?></option>
</select>
</p>
<p>
<label for="<?php echo $this->get_field_id('strava_search_id'); ?>"><?php _e('Search Id:'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('strava_search_id'); ?>" name="<?php echo $this->get_field_name('strava_search_id'); ?>" type="text" value="<?php echo $strava_search_id; ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id('quantity'); ?>"><?php _e('Quantity:'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('quantity'); ?>" name="<?php echo $this->get_field_name('quantity'); ?>" type="text" value="<?php echo $quantity; ?>" />
</p>
<?php
}
} // class LatestRidesWidget
// Register StravaLatestRidesWidget widget
add_action('widgets_init', function() { return register_widget('WP\Strava\LatestRidesWidget'); });
// The handler to the ajax call, we will avoid this if Strava support jsonp request and we can do it
// the parsing directly on the jQuery ajax call, the returned text will be enclosed in the $response variable.
function strava_request_handler($strava_search_option, $strava_search_id, $strava_som_option, $quantity) {
$response = "";
//Check if the username is empty.
if (empty($strava_search_id)) {
$response .= __("Please configure the Strava search id on the widget options.", "wp-strava");
} else {
$strava_rides = new Rides();
$strava_rides->getLatestRides($strava_search_option, $strava_search_id, $quantity);
$rides_details = $strava_rides->getRidesDetails($strava_som_option);
if ($strava_som_option == "metric") {
$units = array(
'elapsedTime' => __('hours','wp-strava'),
'movingTime' => __('hours','wp-strava'),
'distance' => __('km','wp-strava'),
'averageSpeed' => __('km/h','wp-strava'),
'maximumSpeed' => __('km/h','wp-strava'),
'elevationGain' => __('meters','wp-strava')
);
} elseif ($strava_som_option == "english") {
$units = array(
'elapsedTime' => __('hours','wp-strava'),
'movingTime' => __('hours','wp-strava'),
'distance' => __('miles','wp-strava'),
'averageSpeed' => __('miles/h','wp-strava'),
'maximumSpeed' => __('miles/h','wp-strava'),
'elevationGain' => __('feet','wp-strava')
);
}
$response .= "<ul id='rides'>";
foreach($rides_details as $ride) {
$response .= "<li class='ride'>";
$response .= "<a href='" . $strava_rides->ridesLinkUrl . $ride['id'] . "' >" . $ride['name'] . "</a>";
$response .= "<div class='ride-item'>";
$response .= __("On ", "wp-strava") . $ride['startDate'];
$response .= __(" rode ", "wp-strava") . $ride['distance'] . " " . $units['distance'];
$response .= __(" during ", "wp-strava") . $ride['elapsedTime'] . " " . $units['elapsedTime'];
$response .= __(" climbing ", "wp-strava") . $ride['elevationGain'] . " " . $units['elevationGain'] . ".";
$response .= "</div>";
$response .= "</li>";
}
$response .= "</ul>";
}
return $response;
} // Function strava_request_handler
// Shortcode handler function
// [ride id=id efforts=false threshold=5 map-width="100%" map-height="400px"] tag
function strava_ride_shortcode_handler($atts) {
$token = get_option('strava_token');
$strava_som = get_option('strava_som');
if($token) {
$pairs = array(
'id' => 0,
'efforts' => false,
'threshold' => 0,
'map_width' => "100%",
'map_height' => "400px"
);
extract(shortcode_atts($pairs, $atts));
$ride = new Rides();
$rideDetails = $ride->getRideDetails($id, $strava_som_option);
$rideCoordinates = $ride->getRideMap($id, $token, $efforts, $threshold);
if ($strava_som == "metric") {
$units = array(
'elapsedTime' => __('hours','wp-strava'),
'movingTime' => __('hours','wp-strava'),
'distance' => __('km','wp-strava'),
'averageSpeed' => __('km/h','wp-strava'),
'maximumSpeed' => __('km/h','wp-strava'),
'elevationGain' => __('meters','wp-strava')
);
} elseif ($strava_som_option == "english") {
$units = array(
'elapsedTime' => __('hours','wp-strava'),
'movingTime' => __('hours','wp-strava'),
'distance' => __('miles','wp-strava'),
'averageSpeed' => __('miles/h','wp-strava'),
'maximumSpeed' => __('miles/h','wp-strava'),
'elevationGain' => __('feet','wp-strava')
);
}
if($rideCoordinates) {
return "
<div id='ride-header-{$id}' class='table'>
<table id='ride-details-table'>
<thead>
<tr>
<th>Elapsed Time</th>
<th>Moving Time</th>
<th>Distance</th>
<th>Average Speed</th>
<th>Max Speed</th>
<th>Elevation Gain</th>
</tr>
</thead>
<tbody>
<tr class='ride-details-table-info'>
<td>{$rideDetails['elapsedTime']}</td>
<td>{$rideDetails['movingTime']}</td>
<td>{$rideDetails['distance']}</td>
<td>{$rideDetails['averageSpeed']}</td>
<td>{$rideDetails['maximumSpeed']}</td>
<td>{$rideDetails['elevationGain']}</td>
</tr>
<tr class='ride-details-table-units'>
<td>{$units['elapsedTime']}</td>
<td>{$units['movingTime']}</td>
<td>{$units['distance']}</td>
<td>{$units['averageSpeed']}</td>
<td>{$units['maximumSpeed']}</td>
<td>{$units['elevationGain']}</td>
</tr>
</tbody>
</table>
</div>
<div id='ride-map-{$id}' class='map' style='width: {$map_width}; height: {$map_height}; border: 1px solid lightgrey;'></div>
<script type='text/javascript' src='http://maps.google.com/maps/api/js?sensor=false'></script>
<script type='text/javascript'>
jQuery(document).ready(function($){
var coordinates = eval({$rideCoordinates});
var rideCoordinates = coordinates.latlng;
var mapCenter = new google.maps.LatLng(23.091860, -102.839356);
var mapOptions = {
zoom: 5,
center: mapCenter,
//mapTypeControl: true,
//mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
zoomControl: true,
zoomControlOptions: {style: google.maps.MapTypeControlStyle.SMALL},
mapTypeId: google.maps.MapTypeId.TERRAIN
};
var mapObject = new google.maps.Map($('#ride-map-{$id}')[0], mapOptions);
var mapBounds = new google.maps.LatLngBounds();
var mapCoordinates = new google.maps.MVCArray();
var size = rideCoordinates.length;
for(i = 0; i < size; i++) {
point = new google.maps.LatLng(parseFloat(rideCoordinates[i][0]), parseFloat(rideCoordinates[i][1]));
mapBounds.extend(point);
mapCoordinates.push(point);
}
var polylineOptions = {
path: mapCoordinates,
strokeColor: '#e0642e',
strokeOpacity: 0.8,
strokeWeight: 3
};
var polyline = new google.maps.Polyline(polylineOptions);
polyline.setMap(mapObject);
mapObject.fitBounds(mapBounds);
//google.maps.event.trigger(mapObject, 'resize');
});
</script>
";
}
} else {
return _e('Please first get your strava token using the settings wp strava page.', 'wp-strava');
}
} // strava_ride_shortcode_handler
//add_shortcode('ride', 'WP\Strava\strava_ride_shortcode_handler');
?>