Permalink
Browse files

enable scrolling in editors

fix encoding of non-ascii characters when compiling Python
  • Loading branch information...
yuguang committed May 3, 2012
1 parent cea9389 commit 60130dd88201dfac9a64858f724a93b1d5add815
Showing with 43 additions and 74 deletions.
  1. +1 −1 python/views.py
  2. +4 −0 static/css/python.css
  3. +0 −1 static/css/style.css
  4. +27 −67 static/files/csspreviewer.html
  5. +8 −2 static/js/fiddle-engine.coffee
  6. +3 −3 utility/views.py
View
@@ -18,7 +18,7 @@ def compile(request):
try:
g = Grammar.parse(code)
except ParseError, error:
- response_dict.update({'error': str(error).replace('Parse error ', '')})
+ response_dict.update({'error': error.message})
else:
success = True
response_dict.update({'code': Translator.parse(g)})
View
@@ -107,6 +107,10 @@ div.toolbar, .title {
padding: 0;
}
+.CodeMirror {
+ padding: .4em;
+}
+
/*
#revisionsMenu input + label {
View
@@ -157,7 +157,6 @@ form textarea {
font-size: 9pt;
line-height: 1.1em;
margin: 0;
- padding: .4em;
}
.CodeMirror-scroll {
@@ -4,92 +4,61 @@
<meta charset="utf-8" />
-<style id="previewer_css"></style>
+<style id="previewer_css">
+ body {
+ display: none;
+ }
+</style>
</head>
<body>
<header>
-
- <a id="currentuser" target="_blank" class="user button">Log in</a>
-
- <div class="with-dropdown">
- <button class="with-symbol" title="Settings">⚙</button>
- <form id="settings" class="dropdown">
- <fieldset id="view">
- <legend>View mode</legend>
-
- <div class="segmented-control">
- <input type="radio" name="view" value="split" id="view-split" checked data-scope="file" />
- <label for="view-split" class="button" title="Horizontal split">Horizontal</label>
-
- <input type="radio" name="view" value="split-vertical" id="view-split-vertical" data-scope="file" />
- <label for="view-split-vertical" class="button" title="Vertical split">Vertical</label>
-
- <input type="radio" name="view" value="separate" id="view-separate" data-scope="file" />
- <label for="view-separate" class="button" title="Separate">Separate</label>
- </div>
-
- <label class="checkbox">
- <input type="checkbox" name="seethrough" value="1" data-scope="file" />
- See-through code
- </label>
- </fieldset>
-
- <fieldset>
- <legend>Libraries</legend>
- <label class="checkbox">
- <input type="checkbox" name="prefixfree" value="1" data-scope="file" checked />
- Use -prefix-free
- </label>
- </fieldset>
- </form>
- </div>
-
+
<div class="with-dropdown">
- <button id="save-button" class="with-symbol" title="Save"></button>
+ <button id="save-button" class="with-symbol" title="Save"></button>
<menu class="dropdown">
- <a href="/" onclick="Dabblet.wipe()" class="command" data-keyboard="⌘N">New dabblet</a>
-
+ <a href="/" onclick="Dabblet.wipe()" class="command" data-keyboard="⌘N"></a>
+
<hr />
-
- <a id="save-cmd" tabindex="0" class="command" data-keyboard="⌘S" data-disabled>Save</a>
- <a onclick="gist.save({forceNew: true})" id="save-new-cmd" class="command" tabindex="0" data-disabled>Save as new</a>
- <a onclick="gist.save({anon: true})" class="command" tabindex="0">Save anonymously</a>
-
+
+ <a id="save-cmd" tabindex="0" class="command" data-keyboard="⌘S" data-disabled></a>
+ <a onclick="gist.save({forceNew: true})" id="save-new-cmd" class="command" tabindex="0" data-disabled></a>
+ <a onclick="gist.save({anon: true})" class="command" tabindex="0"></a>
+
<hr />
-
- <a data-href="https://gist.github.com/{gist-id}/{gist-rev}" target="_blank" class="command" data-disabled>View gist</a>
- <a data-href="/result/gist/{gist-id}/{gist-rev}" class="command" target="_blank" aria-hidden="true">View full page result</a>
+
+ <a data-href="https://gist.github.com/{gist-id}/{gist-rev}" target="_blank" class="command" data-disabled></a>
+ <a data-href="/result/gist/{gist-id}/{gist-rev}" class="command" target="_blank" aria-hidden="true"></a>
<a class="user command" target="_blank" aria-hidden="true" id="gist-user"></a>
</menu>
</div>
-
+
<div class="controls-group">
<a href="/help/" class="button" title="Help &amp; credits" target="_blank">?</a>
<div class="tabs">
<input type="radio" name="page" value="css" id="page-css" checked data-scope="file" />
<label for="page-css" title="⌘1">
- <span class="title">CSS
- <span class="if-not-separate"><i class="amp">&amp;</i> Result</span>
+ <span class="title">
+ <span class="if-not-separate"><i class="amp">&amp;</i></span>
</span>
</label>
-
+
<input type="radio" name="page" value="html" id="page-html" data-scope="file" />
<label for="page-html" title="⌘2">
- <span class="title">HTML
- <span class="if-not-separate"><i class="amp">&amp;</i> Result</span>
+ <span class="title">
+ <span class="if-not-separate"><i class="amp">&amp;</i></span>
</span>
</label>
-
+
<input type="radio" name="page" value="all" id="page-all" checked data-scope="file" />
<label for="page-all" title="⌘3">
- <span class="title">All</span>
+ <span class="title"></span>
</label>
-
+
<input type="radio" name="page" value="result" id="page-result" data-scope="file" />
<label for="page-result" title="⌘4">
- <span class="title">Result</span>
+ <span class="title"></span>
</label>
</div>
</div>
@@ -1667,9 +1636,6 @@
var login = user.login;
- currentuser.innerHTML = gist.getUserHTML(user);
- currentuser.href = gist.getUserURL(user);
-
window['save-button'].onclick = window['save-cmd'].onclick = gist.save;
window['save-cmd'].removeAttribute('data-disabled');
window['save-new-cmd'].removeAttribute('data-disabled');
@@ -2105,12 +2071,6 @@
window.ACCESS_TOKEN = localStorage['access_token'];
-currentuser.onclick = function(){
- if(!this.hasAttribute('href')) {
- gist.oauth[0]();
- }
-}
-
window.onbeforeunload = function(){
if(!gist.saved) {
html.onkeyup();
@@ -428,7 +428,7 @@ serverCompiler =
line and column numbers are given and notifies the user about the error.
###
$.post(
- ['http://fiddlesalad.com/', @mode.name, '/compile/'].join('')
+ ['/', @mode.name, '/compile/'].join('')
code: @get_code()
(response) =>
if response.success
@@ -518,6 +518,8 @@ PythonEditor = ProgramEditor.$extend(
preview: (javascript) ->
codeRunner.execute javascript
+ displayError: (message) ->
+ @$super(message.replace('Parse error ', ''))
)
Viewer = Class.$extend(
__init__: (id) ->
@@ -802,7 +804,7 @@ FiddleEditor = Class.$extend(
previewFrame = Frame 'source', 'Source'
tabs = TabInterface 'source-tab'
preview = IframeComponent @id.css
- preview.set_source if debug then base_url + '/files/csspreviewer.html' else 'http://fiddlesalad.com/home/files/csspreviewer.html?v=2012041516'
+ preview.set_source if debug then base_url + '/files/csspreviewer.html' else 'http://fiddlesalad.com/home/files/csspreviewer.html?v=2012050220'
index = tabs.add 'css', preview.to_html_string()
@styleEditor.set_focus_listener PreviewListener('source', index)
@@ -1131,6 +1133,10 @@ FiddleFactory = Class.$extend(
unless bowser.webkit
$('.ui-dialog-title').css(position: 'static', height: '1em')
+ for type in ['program', 'document', 'style']
+ $("##{ type }container").find('.CodeMirror-scroll').css(overflow: 'auto', height: "#{ $("##{ type }container").parent().height() }px")
+ $("##{ type }container").parent().css('overflow', 'hidden')
+
get_view_model: ->
document.getElementById('progress')?.value = 90
FiddleViewModel()
View
@@ -1,12 +1,12 @@
-from django.shortcuts import render
+from django.http import HttpResponseForbidden
from cloud_ide.fiddle.jsonresponse import JsonResponse
import urllib2, base64, urlparse
from bs4 import BeautifulSoup as BS
def scrape(request):
url = request.GET['url']
- if not urlparse.urlparse(url).scheme[0:4] is 'http':
- return
+ if not urlparse.urlparse(url).scheme[0:4] == 'http':
+ return HttpResponseForbidden()
response = urllib2.urlopen(url)
html = response.read(200000) #200 kiloBytes

0 comments on commit 60130dd

Please sign in to comment.