Permalink
Browse files

fix bug 759356 - update devmo_url for kuma

  • Loading branch information...
1 parent 8866a06 commit 0cccdf1b2a1c58ea4ab690a17e48e85af4eb60a2 @groovecoder groovecoder committed Jun 12, 2012
View
@@ -153,7 +153,7 @@
"summary": _("The HTML5 audio element lets you embed sound in webpages without requiring your users to rely on plug-ins."),
"description": _("The HTML5 audio element lets you embed sound in webpages without requiring your users to rely on plug-ins."),
"learn_more": [],
- "tab_copy": _("<p>The <a href=\"https://developer.mozilla.org/en/HTML/Element/audio\">HTML5 &lt;audio&gt;</a> element lets you embed sound in Web pages. More importantly, it lets you do so without requiring your users to rely on plug-ins. This means sound for everyone, everywhere, in the most open way possible. In particular, you can play sounds in games with <a href=\"http://robert.ocallahan.org/2011/11/latency-of-html5-sounds.html\">very low latency</a>, making for a responsive, immersive game experience.</p><p>What else can you do with the audio element? Show us by submitting to the Dev Derby today.</p>"),
+ "tab_copy": _("<p>The <a href=\"/en-US/docs//HTML/Element/audio\">HTML5 &lt;audio&gt;</a> element lets you embed sound in Web pages. More importantly, it lets you do so without requiring your users to rely on plug-ins. This means sound for everyone, everywhere, in the most open way possible. In particular, you can play sounds in games with <a href=\"http://robert.ocallahan.org/2011/11/latency-of-html5-sounds.html\">very low latency</a>, making for a responsive, immersive game experience.</p><p>What else can you do with the audio element? Show us by submitting to the Dev Derby today.</p>"),
},
{
"tag_name": "challenge:2012:may",
@@ -165,7 +165,7 @@
"summary": _("With the Websocket API and protocol, you can open a two-way channel between the browser and a server, for scalable and real-time data flow. No more server polling!"),
"description": _("With the Websocket API and protocol, you can open a two-way channel between the browser and a server, for scalable and real-time data flow. No more server polling!"),
"learn_more": [],
- "tab_copy": _("""<p>With the <a href="https://developer.mozilla.org/en/WebSockets">Websocket API and protocol</a>, you can open a two-way communication channel between the browser and a server. This lets you send messages to the server and receive event-driven responses in real time, all without server polling. Websockets are simple, scalable, and future-proof. <a href="http://www.websocket.org/">Websocket.org</a> even argues that Websockets are the "next evolutionary step in web communication."</p>
+ "tab_copy": _("""<p>With the <a href="/en-US/docs/WebSockets">Websocket API and protocol</a>, you can open a two-way communication channel between the browser and a server. This lets you send messages to the server and receive event-driven responses in real time, all without server polling. Websockets are simple, scalable, and future-proof. <a href="http://www.websocket.org/">Websocket.org</a> even argues that Websockets are the "next evolutionary step in web communication."</p>
<p>Not excited yet? This is about more than just sending messages&mdash;it's about highly interactive experiences. Last month, Little Workshop and Mozilla collaborated to create <a href="https://hacks.mozilla.org/2012/03/browserquest/">BrowserQuest</a>, a multiplayer online game that uses Websockets at its core. As if that weren't enough, Mozilla's very own Rob Hawkes created <a href="http://rawkets.com/">Rawkets</a>, a multiplayer space shooter that also uses Websockets.</p>
<p>Of course, you can't do much with Websockets unless you have a server to communicate with. Thankfully, there are many free Websockets servers available on the web, such as <a href="http://www.heroku.com/">Heroku</a> and <a href="http://nodejitsu.com/#/">Nodejitsu</a>. If you prefer, you could even use your own Websockets server.</p>
<p>Setting up a Websockets demo is more involved than setting up a static demo, but we know you can do it. As long as you keep these <a href="https://hacks.mozilla.org/2012/05/may-dev-derby-show-us-what-you-can-do-with-websockets/#may-derby-setup">three simple rules</a> in mind, everything should work flawlessly.</p>
@@ -182,7 +182,7 @@
"description": _("WebGL brings the power of OpenGL, for creating interactive 3D graphics, to the Web, with no plug-ins required."),
"learn_more": [],
"tab_copy": _("""<p>WebGL brings the power of OpenGL to the Web. Using WebGL, you can create interactive 3D graphics that work directly in modern browsers without plug-ins.
-<p>Using WebGL is easier if you already have experience with graphics programming, but don't let that hold you back. <a href="http://learningwebgl.com/blog/?page_id=1217">Learning WebGL</a> provides a great set of tutorials for newcomers and the MDN offers <a href="https://developer.mozilla.org/en/WebGL">WebGL articles</a> that make a great next step. While you're working, you might also appreciate <a href="http://webglplayground.net/">WebGL Playground</a>, a handy tool that lets you edit your creations and see the results in real time.</p>
+<p>Using WebGL is easier if you already have experience with graphics programming, but don't let that hold you back. <a href="http://learningwebgl.com/blog/?page_id=1217">Learning WebGL</a> provides a great set of tutorials for newcomers and the MDN offers <a href="/en-US/docs/WebGL">WebGL articles</a> that make a great next step. While you're working, you might also appreciate <a href="http://webglplayground.net/">WebGL Playground</a>, a handy tool that lets you edit your creations and see the results in real time.</p>
<p>Best of all, you have the power of the open-source community on your side. Be sure to consider the <a href="http://dev.opera.com/articles/view/an-introduction-to-webgl/#webgllib">many JavaScript libraries</a> that make writing WebGL animations even easier.</p>
<p>What can you do with WebGL? Show us this month in the June Dev Derby!</p>"""),
},
View
@@ -17,7 +17,8 @@
from soapbox.models import Message
import utils
-from sumo.urlresolvers import split_path
+from sumo.urlresolvers import split_path, reverse
+from wiki.models import Document
# Yanking filters from Django.
@@ -70,20 +71,39 @@ def jsonencode(data):
return jinja2.Markup(simplejson.dumps(data))
+# TODO: move this to wiki/helpers.py
@register.function
@jinja2.contextfunction
def devmo_url(context, path):
""" Create a URL pointing to devmo.
- Look for a wiki page in the current locale first,
- then default to given path
+ Look for a wiki page in the current locale, or default to given path
"""
if not settings.DEKIWIKI_ENDPOINT:
- # HACK: If MindTouch is unavailable, skip the rest of this and lean on
- # locale processing redirects to resolve things. Might be interesting
- # to resolve some of the redirects first, and come up with the ultimate
- # real URL. See bug 759356 for followup.
- path = path.replace('/en', '')
- return '/%s/docs%s' % (context['request'].locale, path)
+ locale = context['request'].locale
+ url = cache.get('devmo_url:%s_%s' % (locale, path))
+ if not url:
+ url = reverse('wiki.document',
+ locale=settings.WIKI_DEFAULT_LANGUAGE,
+ args=[path])
+ if locale != settings.WIKI_DEFAULT_LANGUAGE:
+ try:
+ parent = Document.objects.get(
+ locale=settings.WIKI_DEFAULT_LANGUAGE, slug=path)
+ """ # TODO: redirect_document is coupled to doc view
+ follow redirects vs. update devmo_url calls
+
+ target = parent.redirect_document()
+ if target:
+ parent = target
+ """
+ child = Document.objects.get(locale=locale,
+ parent=parent)
+ url = reverse('wiki.document', locale=locale,
+ args=[child.slug])
+ except Document.DoesNotExist:
+ pass
+ cache.set('devmo_url:%s_%s' % (locale, path), url)
+ return url
# HACK: If DEKIWIKI_MOCK is True, just skip hitting the API. This can speed
# up a lot of tests without adding decorators, and should never be true in
@@ -95,10 +95,12 @@ def test_stage_bug607996(self):
class TestDevMoHelpers(test_utils.TestCase):
+ fixtures = ['wiki/documents.json']
+
def test_devmo_url(self):
# Skipping this test for now, because it hits unreliable prod resources
- raise SkipTest()
+ raise SkipTest()
en_only_page = '/en/HTML/HTML5'
localized_page = '/en/HTML'
@@ -113,32 +115,30 @@ def test_devmo_url(self):
eq_(devmo_url(context, localized_page), '/zh_tw/HTML')
- @attr('current')
- @mock.patch('devmo.helpers.check_devmo_local_page')
- def test_devmo_url_mindtouch_disabled(self, mock_check_devmo_local_page):
+ def test_devmo_url_mindtouch_disabled(self):
_old = settings.DEKIWIKI_ENDPOINT
settings.DEKIWIKI_ENDPOINT = False
- # HACK: mock has an assert_called_with, but I want something like
- # never_called or call_count. Instead, I have this:
- trap = {'was_called': False}
- def my_check_devmo_local_page(username, password, force=False):
- trap['was_called'] = True
- return None
- mock_check_devmo_local_page.side_effect = my_check_devmo_local_page
-
- en_only_page = '/en/HTML/HTML5'
- localized_page = '/en/HTML'
+ localized_page = 'article-title'
req = test_utils.RequestFactory().get('/')
context = {'request': req}
- req.locale = 'de'
- eq_(devmo_url(context, localized_page), '/de/docs/HTML')
+ req.locale = 'fr'
+ eq_(devmo_url(context, localized_page), '/fr/docs/le-title')
- ok_(not trap['was_called'])
settings.DEKIWIKI_ENDPOINT = _old
+ def test_devmo_url_mindtouch_disabled_redirect(self):
+ # Skipping this test for now, redirect model logic is coupled to view
+ raise SkipTest()
+ _old = settings.DEKIWIKI_ENDPOINT
+ settings.DEKIWIKI_ENDPOINT = False
+
+ # TODO: add redirect localized pages to fixture and test
+
+ settings.DEKIWIKI_ENDPOINT = _old
+
class TestDevMoUrlResolvers(test_utils.TestCase):
def test_prefixer_get_language(self):
@@ -30,27 +30,27 @@
</header>
<ul id="doc-topics">
<li>
- <h3><a href="{{ devmo_url(_('/en/HTML')) }}">{{ _('HTML') }}</a></h3>
+ <h3><a href="{{ devmo_url('HTML') }}">{{ _('HTML') }}</a></h3>
<p>{{ _('HyperText Markup Language, the core language of the web.') }}</p>
</li>
<li>
- <h3><a href="{{ devmo_url(_('/en/HTML/HTML5')) }}">{{ _('HTML5') }}</a></h3>
+ <h3><a href="{{ devmo_url('HTML/HTML5') }}">{{ _('HTML5') }}</a></h3>
<p>{{ _('The next generation of HTML, HTML5 adds powerful new capabilities for web sites and web applications.') }}</p>
</li>
<li>
- <h3><a href="{{ devmo_url(_('/en/JavaScript')) }}">{{ _('JavaScript') }}</a></h3>
+ <h3><a href="{{ devmo_url('JavaScript') }}">{{ _('JavaScript') }}</a></h3>
<p>{{ _('The scripting language that powers modern web applications.') }}</p>
</li>
<li>
- <h3><a href="{{ devmo_url(_('/en/CSS')) }}">{{ _('CSS') }}</a></h3>
+ <h3><a href="{{ devmo_url('CSS') }}">{{ _('CSS') }}</a></h3>
<p>{{ _('Cascading Style Sheets provide advanced layout and formatting of web content.') }}</p>
</li>
<li>
- <h3><a href="{{ devmo_url(_('/en/DOM')) }}">{{ _('DOM') }}</a></h3>
+ <h3><a href="{{ devmo_url('DOM') }}">{{ _('DOM') }}</a></h3>
<p>{{ _('The Document Object Model describes the structure and content of web pages.') }}</p>
</li>
<li>
- <h3><a href="{{ devmo_url(_('/en/AJAX')) }}">{{ _('AJAX') }}</a></h3>
+ <h3><a href="{{ devmo_url('AJAX') }}">{{ _('AJAX') }}</a></h3>
<p>{{ _('"Asynchronous JavaScript and XML" is a term that describes the use of all these technologies together to create powerful web applications.') }}</p>
</li>
</ul>
@@ -94,29 +94,29 @@
<div class="section">
<h4><a href="{{ url('mobile') }}" class="mobile">{{ _('Mobile') }}</a></h4>
<ul>
- <li><a href="{{ devmo_url(_('/en/Mobile')) }}">{{ _('Firefox Mobile for developers') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/Detecting_device_orientation')) }}">{{ _('Detecting device orientation') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/Using_geolocation')) }}">{{ _('Using geolocation') }}</a></li>
+ <li><a href="{{ devmo_url('Mobile') }}">{{ _('Firefox Mobile for developers') }}</a></li>
+ <li><a href="{{ devmo_url('Detecting_device_orientation') }}">{{ _('Detecting device orientation') }}</a></li>
+ <li><a href="{{ devmo_url('Using_geolocation') }}">{{ _('Using geolocation') }}</a></li>
</ul>
</div>
<div class="section">
<h4><a href="{{ url('addons') }}" class="addons">{{ _('Add-ons') }}</a></h4>
<ul>
<li><a href="https://addons.mozilla.org/en-US/developers/">{{ _('AMO Developer Hub') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/Extensions')) }}">{{ _('Extensions') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/Plugins')) }}">{{ _('Plugins') }}</a></li>
+ <li><a href="{{ devmo_url('Extensions') }}">{{ _('Extensions') }}</a></li>
+ <li><a href="{{ devmo_url('Plugins') }}">{{ _('Plugins') }}</a></li>
<li><a href="https://builder.mozillalabs.com/">{{ _('Add-ons Builder') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/Themes')) }}">{{ _('Themes') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/Creating_OpenSearch_plugins_for_Firefox')) }}">{{ _('Search engine plugins') }}</a></li>
+ <li><a href="{{ devmo_url('Themes') }}">{{ _('Themes') }}</a></li>
+ <li><a href="{{ devmo_url('Creating_OpenSearch_plugins_for_Firefox') }}">{{ _('Search engine plugins') }}</a></li>
</ul>
</div>
<div class="section">
<h4><a href="{{ url('mozilla') }}" class="mozilla">{{ _('Mozilla') }}</a></h4>
<ul>
- <li><a href="{{ devmo_url(_('/en/Participating_in_the_Mozilla_project')) }}">{{ _('Participating in the Mozilla project') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/Using_Mozilla_code_in_other_projects')) }}">{{ _('Using Mozilla code in other projects') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/Localization')) }}">{{ _('Localization') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/QA')) }}">{{ _('Quality Assurance') }}</a></li>
+ <li><a href="{{ devmo_url('Participating_in_the_Mozilla_project') }}">{{ _('Participating in the Mozilla project') }}</a></li>
+ <li><a href="{{ devmo_url('Using_Mozilla_code_in_other_projects') }}">{{ _('Using Mozilla code in other projects') }}</a></li>
+ <li><a href="{{ devmo_url('Localization') }}">{{ _('Localization') }}</a></li>
+ <li><a href="{{ devmo_url('QA') }}">{{ _('Quality Assurance') }}</a></li>
</ul>
</div>
</div>
@@ -1,26 +1,26 @@
<ul id="glossary">
<li>
<ul class="cols-4">
- <li><a href="{{ devmo_url(_('/en/HTML')) }}">{{ _('HTML') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/CSS')) }}">{{ _('CSS') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/JavaScript')) }}">{{ _('JavaScript') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/HTML/HTML5')) }}">{{ _('HTML5') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/DOM')) }}">{{ _('DOM') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/SVG')) }}">{{ _('SVG') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/HTML/Element/canvas')) }}">{{ _('Canvas') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/AJAX')) }}">{{ _('AJAX') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/CSS/Media_queries')) }}">{{ _('Media Queries') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/WebGL')) }}">{{ _('WebGL') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/DOM/Storage')) }}">{{ _('Web Storage') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/Using_audio_and_video_in_Firefox')) }}">{{ _('Audio') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/Using_audio_and_video_in_Firefox')) }}">{{ _('Video') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/Using_web_workers')) }}">{{ _('Web Workers') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/Using_files_from_web_applications')) }}">{{ _('Files') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/DragDrop/Drag_and_Drop')) }}">{{ _('Drag and Drop') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/CSS/Using_CSS_transforms')) }}">{{ _('CSS Transforms') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/Using_gradients')) }}">{{ _('CSS Gradients') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/Security')) }}">{{ _('Security') }}</a></li>
- <li><a href="{{ devmo_url(_('/en/IndexedDB')) }}">{{ _('IndexedDB') }}</a></li>
+ <li><a href="{{ devmo_url('HTML') }}">{{ _('HTML') }}</a></li>
+ <li><a href="{{ devmo_url('CSS') }}">{{ _('CSS') }}</a></li>
+ <li><a href="{{ devmo_url('JavaScript') }}">{{ _('JavaScript') }}</a></li>
+ <li><a href="{{ devmo_url('HTML/HTML5') }}">{{ _('HTML5') }}</a></li>
+ <li><a href="{{ devmo_url('DOM') }}">{{ _('DOM') }}</a></li>
+ <li><a href="{{ devmo_url('SVG') }}">{{ _('SVG') }}</a></li>
+ <li><a href="{{ devmo_url('HTML/Element/canvas') }}">{{ _('Canvas') }}</a></li>
+ <li><a href="{{ devmo_url('AJAX') }}">{{ _('AJAX') }}</a></li>
+ <li><a href="{{ devmo_url('CSS/Media_queries') }}">{{ _('Media Queries') }}</a></li>
+ <li><a href="{{ devmo_url('WebGL') }}">{{ _('WebGL') }}</a></li>
+ <li><a href="{{ devmo_url('DOM/Storage') }}">{{ _('Web Storage') }}</a></li>
+ <li><a href="{{ devmo_url('Using_audio_and_video_in_Firefox') }}">{{ _('Audio') }}</a></li>
+ <li><a href="{{ devmo_url('Using_audio_and_video_in_Firefox') }}">{{ _('Video') }}</a></li>
+ <li><a href="{{ devmo_url('Using_web_workers') }}">{{ _('Web Workers') }}</a></li>
+ <li><a href="{{ devmo_url('Using_files_from_web_applications') }}">{{ _('Files') }}</a></li>
+ <li><a href="{{ devmo_url('DragDrop/Drag_and_Drop') }}">{{ _('Drag and Drop') }}</a></li>
+ <li><a href="{{ devmo_url('CSS/Using_CSS_transforms') }}">{{ _('CSS Transforms') }}</a></li>
+ <li><a href="{{ devmo_url('Using_gradients') }}">{{ _('CSS Gradients') }}</a></li>
+ <li><a href="{{ devmo_url('Security') }}">{{ _('Security') }}</a></li>
+ <li><a href="{{ devmo_url('IndexedDB') }}">{{ _('IndexedDB') }}</a></li>
</ul>
</li>
</ul>
@@ -59,7 +59,7 @@ <h4 class="entry-title"><a href="https://addons.mozilla.org/en-US/developers/doc
<p class="entry-summary">{{ _('The official documentation on APIs and languages. What you need, when you need it, to create your masterpiece.') }}</p>
</li>
<li class="hentry">
- <h4 class="entry-title"><a href="{{ devmo_url(_('/en/Extensions')) }}" rel="bookmark">{{ _('Extensions') }}</a></h4>
+ <h4 class="entry-title"><a href="{{ devmo_url('Extensions') }}" rel="bookmark">{{ _('Extensions') }}</a></h4>
<p class="entry-summary">{{ _('Complete documentation for developing extensions for Mozilla applications.') }}</p>
</li>
<li class="hentry">
Oops, something went wrong.

0 comments on commit 0cccdf1

Please sign in to comment.