This will have a fairly limited audience, but bbcodes for embedding rides from garmin, mapmyride etc...
Currently done: Garmin, MapmyRide and Endomondo, working on Strava and others.
Be aware this uses iframe embedding so I dont know if there could be any security risk as far as html goes..
in subs.php
find
);
// Let mods add new BBC without hassle.
Add before
array(
'tag' => 'garmin',
'before' => '<iframe width="465" height="548" frameborder="0" src="http://connect.garmin.com:80/activity/embed/',
'after' => '"></iframe>',
),
array(
'tag' => 'mapmyride',
'before' => '<iframe id="mapmyfitness_route" src="http://snippets.mapmycdn.com/routes/view/embedded/',
'after' => '?width=560&height=400&elevation=true&info=true&line_color=E6a67031&rgbhex=3170a6&distance_markers=0&unit_type=imperial&map_mode=TERRAIN&last_updated=2007-09-09T21:27:27+01:00" height="590px" width="100%" frameborder="0"></iframe>',
),
array(
'tag' => 'endomondo',
'before' => '<iframe src=http://www.endomondo.com/embed/workouts?w=',
'after' => '&width=580&height=600" width="580" height="600" frameborder="0" scrolling="no" ></iframe>',
),
in subs.editor.php (at the relevant point where you want the icons to appear
array(
'image' => 'garmin',
'code' => 'garmin',
'before' => '[garmin]',
'after' => '[/garmin]',
'description' => $txt['bbc_garmin']
),
array(
'image' => 'mapmyride',
'code' => 'mapmyride',
'before' => '[mapmyride]',
'after' => '[/mapmyride]',
'description' => $txt['bbc_mapmyride']
),
array(
'image' => 'endomondo',
'code' => 'endomondo',
'before' => '[endomondo]',
'after' => '[/endomondo]',
'description' => $txt['bbc_endomondo']
),
in modifications.english.php
$txt['bbc_garmin'] = 'Insert a Garmin activity ID';
$txt['bbc_mapmyride'] = 'Insert a Map my Ride activity ID';
$txt['bbc_endomondo'] = 'Insert an Endomondo rider and activity id for example 184353320/9925838';
in the bbc directory of theme/images the attached icons..
Useage..
Garmin - simply enter the workout id (numeric) in the bbcode
Map my ride - enter the workout id (numeric) in the bbcode
Endomondo - enter the user/activity code ie 184353320/9925838
Obviously limited useage, but useful to those sports forums that want users to be able to share their rides by embedding.
screens
Awesome! ;)
Bikemap and Ridewithgps
in subs.php
array(
'tag' => 'ridewithgps',
'before' => '<iframe src="http://ridewithgps.com/routes/',
'after' => '/embed" height="500px" width="100%" frameborder="0"></iframe>',
),
array(
'tag' => 'bikemap',
'before' => '<div style="background-color:#fff;"><iframe src="http://bikemap.net/en/route/',
'after' => '/widget/?width=425&extended=1&height=350&unit=metric" width="425" height="663" border="0" frameborder="0" marginheight="0" marginwidth="0" scrolling="no"> </iframe></div>',
),
in subs-editor.php
array(
'image' => 'bikemap',
'code' => 'bikemap',
'before' => '[bikemap]',
'after' => '[/bikemap]',
'description' => $txt['bbc_bikemap']
),
array(
'image' => 'ridewithgps',
'code' => 'ridewithgps',
'before' => '[ridewithgps]',
'after' => '[/ridewithgps]',
'description' => $txt['bbc_ridewithgps']
),
In modifications.eng/utf8
$txt['bbc_bikemap'] = 'Insert a Bikemap route in the format 1493880-putevima-cvijeca';
$txt['bbc_ridewithgps'] = 'Insert a Ride with GPS activity ID';
images
(Why cant you attach things in this section)
Is this limited to the US?
Reason being where I live we have what we call redways which basically are red paths which are not near roads.
These were intended for use by pedestrians and cycles.
http://en.wikipedia.org/wiki/Milton_Keynes_redway_system
all the mapping sites i have added so far, are global sites with a multitude of routes.. So depends if anyone has mapped the MK Routes.
Looking at the site, it appears that much like MK itself, the red routes are a spaghetti assortment sprawling across the entire city (got very lost trying to get into MK once ):D Will have a dig around and see if anyone has mapped them yet..
Milton Keynes Redway may be a good search term.
;)
Anyways Dr Who and my stomach are waiting.
Just had a look.. A user has created a bunch of MK routes on bikemap.
Heritage Trail A - citywide (http://bikemap.net/en/route/711048-mk-heritage-trail-a-city-wide/)
Heritage Trail B - North East (http://bikemap.net/en/route/710901-mk-heritage-trail-b-mk-north-east/)
Heritage Trail B - Olney Spur (http://bikemap.net/en/route/710922-mk-heritage-trail-b-olney-spur/)
Heritage Trail C - Ouzal Valley (http://bikemap.net/en/route/709493-mk-heritage-trail-c-ouzal-valley/)
Heritage Trail D - Southwest loop (http://bikemap.net/en/route/711093-mk-heritage-trail-d-mk-west-southern-loop-79m/)
Heritage Trail D - Northwest Loop (http://bikemap.net/en/route/710210-mk-heritage-trail-d-mk-west-northern-loop/)
all those can be embedded using the full embed code if you have html access, or the bb code without using the format
710210-mk-heritage-trail-d-mk-west-northern-loop
@dim, you should package this :P
Quote from: Mick. on May 12, 2013, 02:17:15 PM
@dim, you should package this :P
That would involve learning how to package mods.. :D Im far too lazy for all that. Maybe when ive finished bugfixing my smf installation :D
Quote from: dimspace on May 12, 2013, 02:33:43 PM
Quote from: Mick. on May 12, 2013, 02:17:15 PM
@dim, you should package this :P
That would involve learning how to package mods.
Best left to the experts I say.
:D
Eh, packaging mods isn't hard. The hard part really is writing the code in the first place.
I think the audience for those who want to embed running or cycling routes in their posts is probably fairly limited..
Packing is the easy bit, it would be interesting to learn how to package a mod, the difficult bit is then having the patience to offer support, update it, answer silly questions like "it says 2.0.3 will it work on 2.0.4" and the like. In no time at all I would have turned into a grumpy old man.
QuoteIn no time at all I would have turned into a grumpy old man.
OMG someone gets me.
Hmm, think i may have packaged it.. seems to work.. :D
http://velorooms.com/files/runridebbc.zip
I had a go on my test forum.
The package installed with no errors.
However there wer no bbc images.
(Default theme was used).
Quote from: Old Fossil on May 21, 2013, 01:57:47 PM
I had a go on my test forum.
The package installed with no errors.
However there wer no bbc images.
(Default theme was used).
hmm.. maybe i set it up to extract wrong.. there should be a bunch of images go to the bbc directory.. well im half way there. :D
ive got
<modification>install.xml</modification>
<require-dir name="bbc" destination="$themedir/images/" />
Maybe that should read
<modification>install.xml</modification>
<require-dir name="/bbc" destination="$themedir/images/" />
hmmm... hang on.. they are all .png, maybe they need to be gif for bbc?
Ya gonna have to ask one of the coder types lol.
No, you were right the first time with what you had. The thing is that it doesn't always install to other themes because of a combination between the inadequacies of the package manager and the way the bbc editor works.
Mind you, I have absolutely no idea why your editor edits are supposed to drop iframes directly into the posting area because unless you did something else, they will be processed out and never displayed (which is why you use bbcode instead anyway)
Quote from: Arantor on May 21, 2013, 06:11:29 PM
No, you were right the first time with what you had. The thing is that it doesn't always install to other themes because of a combination between the inadequacies of the package manager and the way the bbc editor works.
Does png v gif make a difference, it occured to me afterwards that not everyones smf has png bb icons, or is it smart enough to find them?
Quote from: Arantor on May 21, 2013, 06:11:29 PM
Mind you, I have absolutely no idea why your editor edits are supposed to drop iframes directly into the posting area because unless you did something else, they will be processed out and never displayed (which is why you use bbcode instead anyway)
Youve lost me? I dont know quite what you mean. The purpose of it is to allow members to put for instance [garmin]486135[/garmin] and it embed the iframe of that route as supplied by garmin without them using embed or html codes (but i think you get that), so i dont quite get what you mean.
Im new at this :D
code now something like
Package info
<?xml version="1.0"?>
<!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info">
<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
<name>Run/Ride BBC</name>
<id>dimspace:RunRideBBC</id>
<version>1.0</version>
<type>modification</type>
<install for="2.0 - 2.0.99">
<modification>install.xml</modification>
<require-file name="bbc/garmin.gif" destination="$imagesdir/bbc" />
<require-file name="bbc/mapmyride.gif" destination="$imagesdir/bbc" />
<require-file name="bbc/bikemap.gif" destination="$imagesdir/bbc" />
<require-file name="bbc/endomondo.gif" destination="$imagesdir/bbc" />
<require-file name="bbc/ridewithgps.gif" destination="$imagesdir/bbc" />
<require-file name="bbc/tracks4bikers.gif" destination="$imagesdir/bbc" />
<require-file name="bbc/garmin.png" destination="$imagesdir/bbc" />
<require-file name="bbc/mapmyride.png" destination="$imagesdir/bbc" />
<require-file name="bbc/bikemap.png" destination="$imagesdir/bbc" />
<require-file name="bbc/endomondo.png" destination="$imagesdir/bbc" />
<require-file name="bbc/ridewithgps.png" destination="$imagesdir/bbc" />
<require-file name="bbc/tracks4bikers.png" destination="$imagesdir/bbc" />
</install>
<uninstall for="2.0 - 2.0.99">
<modification reverse="true">install.xml</modification>
<require-file name="bbc/garmin.gif" destination="$imagesdir/bbc" />
<require-file name="bbc/mapmyride.gif" destination="$imagesdir/bbc" />
<require-file name="bbc/bikemap.gif" destination="$imagesdir/bbc" />
<require-file name="bbc/endomondo.gif" destination="$imagesdir/bbc" />
<require-file name="bbc/ridewithgps.gif" destination="$imagesdir/bbc" />
<require-file name="bbc/tracks4bikers.gif" destination="$imagesdir/bbc" />
<require-file name="bbc/garmin.png" destination="$imagesdir/bbc" />
<require-file name="bbc/mapmyride.png" destination="$imagesdir/bbc" />
<require-file name="bbc/bikemap.png" destination="$imagesdir/bbc" />
<require-file name="bbc/endomondo.png" destination="$imagesdir/bbc" />
<require-file name="bbc/ridewithgps.png" destination="$imagesdir/bbc" />
<require-file name="bbc/tracks4bikers.png" destination="$imagesdir/bbc" />
</uninstall>
</package-info>
install
<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
<id>nikan:EUCookie</id>
<version>1.0</version>
<file name="$sourcedir/Subs.php">
<operation>
<search position="before"><![CDATA[
array(
'tag' => 'i',
'before' => '<em>',
'after' => '</em>',
),
]]></search>
<add><![CDATA[
array(
'tag' => 'garmin',
'before' => '<iframe width="465" height="548" frameborder="0" src="http://connect.garmin.com:80/activity/embed/',
'after' => '"></iframe>',
),
array(
'tag' => 'mapmyride',
'before' => '<iframe id="mapmyfitness_route" src="http://snippets.mapmycdn.com/routes/view/embedded/',
'after' => '?width=560&height=400&elevation=true&info=true&line_color=E6a67031&rgbhex=3170a6&distance_markers=0&unit_type=imperial&map_mode=TERRAIN&last_updated=2007-09-09T21:27:27+01:00" height="590px" width="100%" frameborder="0"></iframe>',
),
array(
'tag' => 'endomondo',
'before' => '<iframe src=http://www.endomondo.com/embed/workouts?w=',
'after' => '&width=580&height="600" width="580" height="600" frameborder="0" scrolling="no" ></iframe>',
),
array(
'tag' => 'ridewithgps',
'before' => '<iframe src="http://ridewithgps.com/routes/',
'after' => '/embed" height="500px" width="100%" frameborder="0"></iframe>',
),
array(
'tag' => 'tracks4bikers',
'before' => '<iframe width="600" height="740" src="http://tracks4bikers.com/tracks/show_iframe/',
'after' => '"></iframe>',
),
array(
'tag' => 'bikemap',
'before' => '<div style="background-color:#fff;"><iframe src="http://bikemap.net/en/route/',
'after' => '/widget/?width=425&extended=1&height=350&unit=metric" width="425" height="663" border="0" frameborder="0" marginheight="0" marginwidth="0" scrolling="no"> </iframe></div>',
),
]]></add>
</operation>
</file>
<file name="$sourcedir/Subs-Editor.php">
<operation>
<search position="before"><![CDATA[
array(
'image' => 'quote',
'code' => 'quote',
'before' => '[quote]',
'after' => '[/quote]',
'description' => $txt['bbc_quote']
),
]]></search>
<add><![CDATA[
array(),
array(
'tag' => 'garmin',
'before' => '<iframe width="465" height="548" frameborder="0" src="http://connect.garmin.com:80/activity/embed/',
'after' => '"></iframe>',
),
array(
'tag' => 'mapmyride',
'before' => '<iframe id="mapmyfitness_route" src="http://snippets.mapmycdn.com/routes/view/embedded/',
'after' => '?width=560&height=400&elevation=true&info=true&line_color=E6a67031&rgbhex=3170a6&distance_markers=0&unit_type=imperial&map_mode=TERRAIN&last_updated=2007-09-09T21:27:27+01:00" height="590px" width="100%" frameborder="0"></iframe>',
),
array(
'tag' => 'endomondo',
'before' => '<iframe src=http://www.endomondo.com/embed/workouts?w=',
'after' => '&width=580&height="600" width="580" height="600" frameborder="0" scrolling="no" ></iframe>',
),
array(
'tag' => 'ridewithgps',
'before' => '<iframe src="http://ridewithgps.com/routes/',
'after' => '/embed" height="500px" width="100%" frameborder="0"></iframe>',
),
array(
'tag' => 'tracks4bikers',
'before' => '<iframe width="600" height="740" src="http://tracks4bikers.com/tracks/show_iframe/',
'after' => '"></iframe>',
),
array(
'tag' => 'bikemap',
'before' => '<div style="background-color:#fff;"><iframe src="http://bikemap.net/en/route/',
'after' => '/widget/?width=425&extended=1&height=350&unit=metric" width="425" height="663" border="0" frameborder="0" marginheight="0" marginwidth="0" scrolling="no"> </iframe></div>',
),
array(),
]]></add>
</operation>
</file>
<file name="$languagedir/Modifications.english.php">
<operation>
<search position="end" />
<add><![CDATA[
$txt['bbc_ridewithgps'] = 'Insert a Ride with GPS route ID';
$txt['bbc_tracks4bikers'] = 'Insert a Tracks 4 Bikers route ID';
$txt['bbc_garmin'] = 'Insert a Garmin activity ID';
$txt['bbc_bikemap'] = 'Insert a Bikemap route in the format 1493880-putevima-cvijeca';
$txt['bbc_mapmyride'] = 'Insert a Map my Ride activity ID';
$txt['bbc_endomondo'] = 'Insert an Endomondo rider and activity id for example 184353320/9925838';
]]></add>
</operation>
</file>
<file name="$languagedir/Modifications.english-utf8.php" error="skip">
<operation>
<search position="end" />
<add><![CDATA[
$txt['bbc_ridewithgps'] = 'Insert a Ride with GPS route ID';
$txt['bbc_tracks4bikers'] = 'Insert a Tracks 4 Bikers route ID';
$txt['bbc_garmin'] = 'Insert a Garmin activity ID';
$txt['bbc_bikemap'] = 'Insert a Bikemap route in the format 1493880-putevima-cvijeca';
$txt['bbc_mapmyride'] = 'Insert a Map my Ride activity ID';
$txt['bbc_endomondo'] = 'Insert an Endomondo rider and activity id for example 184353320/9925838';
]]></add>
</operation>
</file>
<require-dir name="bbc" destination="$sourcedir/images/" />
</modification>
And then bbc folder with all images as png and gif????
QuoteDoes png v gif make a difference, it occured to me afterwards that not everyones smf has png bb icons, or is it smart enough to find them?
It is not smart enough to find them. They have to be gifs unless you've modified the template. And there is a decent chance it won't install to other theme folders even if you tell it to.
Quoteso i dont quite get what you mean.
The code in Subs-Editor.php is for the things users click on to be inserted into the post content. Except iframes shouldn't work if you do that (regardless of whether you're in WYSIWYG mode or not), because they should be processed at save time to forcibly break the HTML tags for security reasons.
If regular users can just post iframes that are accepted as-is for posting, there is a truly huge security hole in your site (because it can't be done on regular SMF). Consider someone putting in an iframe to load a cookie stealing script when loaded. That's why iframes shouldn't be accepted normally.
The code in Subs-Editor.php is not supposed to be raw HTML under any circumstances because it shouldn't work. If it does work, there is a security hole and one that *needs* patching.
now i see what arantor meant.. (well no i dont, i see something different)
im a spanner.. ive got the editor code going in subs.php in error :bangsheadondesk:
But i had totally messed up the edits for subs.editor.. should have been
<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
<id>nikan:EUCookie</id>
<version>1.0</version>
<file name="$sourcedir/Subs.php">
<operation>
<search position="before"><![CDATA[
array(
'tag' => 'i',
'before' => '<em>',
'after' => '</em>',
),
]]></search>
<add><![CDATA[
array(
'tag' => 'garmin',
'before' => '<iframe width="465" height="548" frameborder="0" src="http://connect.garmin.com:80/activity/embed/',
'after' => '"></iframe>',
),
array(
'tag' => 'mapmyride',
'before' => '<iframe id="mapmyfitness_route" src="http://snippets.mapmycdn.com/routes/view/embedded/',
'after' => '?width=560&height=400&elevation=true&info=true&line_color=E6a67031&rgbhex=3170a6&distance_markers=0&unit_type=imperial&map_mode=TERRAIN&last_updated=2007-09-09T21:27:27+01:00" height="590px" width="100%" frameborder="0"></iframe>',
),
array(
'tag' => 'endomondo',
'before' => '<iframe src=http://www.endomondo.com/embed/workouts?w=',
'after' => '&width=580&height="600" width="580" height="600" frameborder="0" scrolling="no" ></iframe>',
),
array(
'tag' => 'ridewithgps',
'before' => '<iframe src="http://ridewithgps.com/routes/',
'after' => '/embed" height="500px" width="100%" frameborder="0"></iframe>',
),
array(
'tag' => 'tracks4bikers',
'before' => '<iframe width="600" height="740" src="http://tracks4bikers.com/tracks/show_iframe/',
'after' => '"></iframe>',
),
array(
'tag' => 'bikemap',
'before' => '<div style="background-color:#fff;"><iframe src="http://bikemap.net/en/route/',
'after' => '/widget/?width=425&extended=1&height=350&unit=metric" width="425" height="663" border="0" frameborder="0" marginheight="0" marginwidth="0" scrolling="no"> </iframe></div>',
),
]]></add>
</operation>
</file>
<file name="$sourcedir/Subs-Editor.php">
<operation>
<search position="before"><![CDATA[
array(
'image' => 'quote',
'code' => 'quote',
'before' => '[quote]',
'after' => '[/quote]',
'description' => $txt['bbc_quote']
),
]]></search>
<add><![CDATA[
array(
'image' => 'garmin',
'code' => 'garmin',
'before' => '[garmin]',
'after' => '[/garmin]',
'description' => $txt['bbc_garmin']
),
array(
'image' => 'mapmyride',
'code' => 'mapmyride',
'before' => '[mapmyride]',
'after' => '[/mapmyride]',
'description' => $txt['bbc_mapmyride']
),
array(
'image' => 'endomondo',
'code' => 'endomondo',
'before' => '[endomondo]',
'after' => '[/endomondo]',
'description' => $txt['bbc_endomondo']
),
array(
'image' => 'bikemap',
'code' => 'bikemap',
'before' => '[bikemap]',
'after' => '[/bikemap]',
'description' => $txt['bbc_bikemap']
),
array(
'image' => 'ridewithgps',
'code' => 'ridewithgps',
'before' => '[ridewithgps]',
'after' => '[/ridewithgps]',
'description' => $txt['bbc_ridewithgps']
),
array(
'image' => 'tracks4bikers',
'code' => 'tracks4bikers',
'before' => '[tracks4bikers]',
'after' => '[/tracks4bikers]',
'description' => $txt['bbc_tracks4bikers']
),
]]></add>
</operation>
</file>
<file name="$languagedir/Modifications.english.php">
<operation>
<search position="end" />
<add><![CDATA[
$txt['bbc_ridewithgps'] = 'Insert a Ride with GPS route ID';
$txt['bbc_tracks4bikers'] = 'Insert a Tracks 4 Bikers route ID';
$txt['bbc_garmin'] = 'Insert a Garmin activity ID';
$txt['bbc_bikemap'] = 'Insert a Bikemap route in the format 1493880-putevima-cvijeca';
$txt['bbc_mapmyride'] = 'Insert a Map my Ride activity ID';
$txt['bbc_endomondo'] = 'Insert an Endomondo rider and activity id for example 184353320/9925838';
]]></add>
</operation>
</file>
<file name="$languagedir/Modifications.english-utf8.php" error="skip">
<operation>
<search position="end" />
<add><![CDATA[
$txt['bbc_ridewithgps'] = 'Insert a Ride with GPS route ID';
$txt['bbc_tracks4bikers'] = 'Insert a Tracks 4 Bikers route ID';
$txt['bbc_garmin'] = 'Insert a Garmin activity ID';
$txt['bbc_bikemap'] = 'Insert a Bikemap route in the format 1493880-putevima-cvijeca';
$txt['bbc_mapmyride'] = 'Insert a Map my Ride activity ID';
$txt['bbc_endomondo'] = 'Insert an Endomondo rider and activity id for example 184353320/9925838';
]]></add>
</operation>
</file>
<require-dir name="bbc" destination="$sourcedir/images/" />
</modification>
subs defines the iframes, subs editor defines the arrays for the bbc and images *facepalm*
which means http://velorooms.com/files/runridebbc.zip does actually now work..
Basically like a dummy I had put the code that was for subs.php in both subs.php and subs-editor.php
Quote from: Arantor on May 21, 2013, 06:41:37 PM
QuoteDoes png v gif make a difference, it occured to me afterwards that not everyones smf has png bb icons, or is it smart enough to find them?
It is not smart enough to find them. They have to be gifs unless you've modified the template. And there is a decent chance it won't install to other theme folders even if you tell it to.
Quoteso i dont quite get what you mean.
The code in Subs-Editor.php is for the things users click on to be inserted into the post content. Except iframes shouldn't work if you do that (regardless of whether you're in WYSIWYG mode or not), because they should be processed at save time to forcibly break the HTML tags for security reasons.
If regular users can just post iframes that are accepted as-is for posting, there is a truly huge security hole in your site (because it can't be done on regular SMF). Consider someone putting in an iframe to load a cookie stealing script when loaded. That's why iframes shouldn't be accepted normally.
The code in Subs-Editor.php is not supposed to be raw HTML under any circumstances because it shouldn't work. If it does work, there is a security hole and one that *needs* patching.
Yeh, get you now. That was a mess up on my part. Had the subs code in editor in error.. Which is why that didnt work. Told you Im new to this.
On the general security aspect. This is using iframes to display the items, but im assuming because the bulk of the iframe is specified with the user only required to enter a numeric code that the risks are fairly minimal?
thanks for your patience by the way.. purely packaging this as a learning process, as a mod it has fairly limited appeal.
The risk is about what the user is allowed to enter. If they're not allowed to enter very much and what is allowed to be entered is sanitised, there's no risk.
In your case, that is still a valid risk because there isn't any kind of checking on what is entered, and incidentally the tag doesn't do anything to prevent other tags inside it.
Start with declaring 'type' => 'unparsed_content' for both all the tags. As far as validation goes, I really can't remember exactly how to roll out a validate function in the bbcode (because I changed how I did it in Wedge years ago and the mechanics there are slightly different in consequence)
Might be worth having a look around some of the bbcode mods to see what they do. IIRC using unparsed_content will require a validate function that you can validate its content as safe (like the img tag does)
cheers. will do..