[PATCH v2] codemirror: fix model when using proxy prefix issue #160

Mads Kiilerich mads at kiilerich.com
Sun Sep 20 19:42:23 UTC 2015


On 09/20/2015 09:38 PM, Christian Oyarzun wrote:
>
>
> On Fri, Sep 18, 2015 at 4:07 PM, Mads Kiilerich <mads at kiilerich.com 
> <mailto:mads at kiilerich.com>> wrote:
>
>     On 09/18/2015 08:12 PM, Christian Oyarzun wrote:
>>     # HG changeset patch
>>     # User Christian Oyarzun <oyarzun at gmail.com
>>     <mailto:oyarzun at gmail.com>>
>>     # Date 1442599888 14400
>>     #      Fri Sep 18 14:11:28 2015 -0400
>>     # Node ID 3033e182787ede6bda4a6ad87e9795dbd2e82a2f
>>     # Parent  889ff0f436c8b57f5962e204e699cbabc6d33aac
>>     codemirror: fix model when using proxy prefix issue #160
>>
>>     diff --git a/kallithea/config/routing.py
>>     b/kallithea/config/routing.py
>>     --- a/kallithea/config/routing.py
>>     +++ b/kallithea/config/routing.py
>>     @@ -99,6 +99,7 @@
>>      #==========================================================================
>>          #MAIN PAGE
>>     +    rmap.connect('static_files', '/', _static=True)
>
>     Why does _static mean here? Why is it needed for this but not for
>     others?
>
> I may be using _static incorrectly, but produces the correct url with 
> pyroutes.url. Similar to using
> h.url_for('/css/source.css') 
> http://pylonsbook.com/en/1.1/urls-routing-and-dispatch.html#internal-static-routes
>
> Using rmap.connect('static_files', '/', controller='home') also works. 
> Which is better / more correct?
>
>
>
>>          rmap.connect('home', '/', controller='home', action='index')
>>          rmap.connect('about', '/about', controller='home',
>>     action='about')
>>          rmap.connect('repo_switcher_data', '/_repos', controller='home',
>>     diff --git a/kallithea/public/js/base.js
>>     b/kallithea/public/js/base.js
>>     --- a/kallithea/public/js/base.js
>>     +++ b/kallithea/public/js/base.js
>>     @@ -903,7 +903,7 @@
>>                  indentUnit: 4,
>>                  autofocus: true
>>              });
>>     -    CodeMirror.modeURL = "/codemirror/mode/%N/%N.js";
>>     +    CodeMirror.modeURL = pyroutes.url('static_files') +
>>     "codemirror/mode/%N/%N.js";
>>          $('#reset').click(function(e){
>>                  window.location=resetUrl;
>>     diff --git a/kallithea/templates/admin/gists/edit.html
>>     b/kallithea/templates/admin/gists/edit.html
>>     --- a/kallithea/templates/admin/gists/edit.html
>>     +++ b/kallithea/templates/admin/gists/edit.html
>>     @@ -81,6 +81,7 @@
>>                      ## dynamic edit box.
>>                      <script type="text/javascript">
>>     +  pyroutes.register('static_files', "${h.url('static_files')}", []);
>
>     Why not put it in root.html with (most) other pyroutes registrations?
>
> This did not work on my initial test. That turned out to be because 
> initCodeMirror was called before the routes were registered. The 
> pyroutes registrations in root.html are in a 
> $(document).ready(function() block. Moving the calls to initCodeMirror 
> inside
> a $(document).ready(function() block fixes that.

Yes, I am hacking on it right now and realizing the same ...

/Mads
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sfconservancy.org/pipermail/kallithea-general/attachments/20150920/f3574f29/attachment.html>


More information about the kallithea-general mailing list