Skip to content
Browse files

change required package name

remember previously selected languages on home page
fix import url validation
  • Loading branch information...
1 parent 642eb67 commit 68f5e9c964cb445a641e35c192cb3f260a0bcf5e @yuguang committed Apr 19, 2012
Showing with 19 additions and 22 deletions.
  1. +0 −1 README.md
  2. +1 −1 requirements.txt
  3. +1 −1 static/js/bindings.js
  4. +7 −1 static/js/codestorage.coffee
  5. +2 −13 static/js/fiddle-engine.coffee
  6. +5 −3 static/js/menu.coffee
  7. +3 −2 utility/views.py
View
1 README.md
@@ -78,7 +78,6 @@ Features ready to be implemented:
* CDN search, suggest, and add as resource (http://www.cdnjs.com/#/search/)
* Color picker
* Scroll source to current cursor position in editor
-* Remember previously selected languages on home page
* Better CoffeeCup documentation page with syntax highlighting
* Use CodeMirror's built-in run mode
* More Languages
View
2 requirements.txt
@@ -2,5 +2,5 @@ django >= 1.3.1
django-mediasync >= 2.2.0
django-social-auth >= 0.6.4
django-taggit >= 0.9.3
-chunks >= 0.1
+django-chunks >= 0.1
beautifulsoup4 >= 4.0.1
View
2 static/js/bindings.js
@@ -66,7 +66,7 @@ ko.extenders.url = function(target, overrideMessage) {
//define a function to do validation
function validate(newValue) {
var urlPattern = /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)*(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i;
- target.hasError(urlPattern.test(newValue));
+ target.hasError(urlPattern.test(newValue) ? false : true);
target.validationMessage(overrideMessage || 'Please enter a valid URL with the protocol.');
}
View
8 static/js/codestorage.coffee
@@ -1,7 +1,13 @@
root = global ? window
Language = Class.$extend(
- __init__: ->
+ __init__: (languages) ->
@settings = new Object
+ # for each language
+ for language in languages
+ # if the language is in category
+ if LANGUAGE_CATEGORY?[language]
+ # set language for the category
+ @set_language language, LANGUAGE_CATEGORY[language]
@settings[LANGUAGE_TYPE.RESOURCE] = LANGUAGE.RESOURCE
@settings[LANGUAGE_TYPE.COMPILED_PROGRAM] = LANGUAGE.JAVASCRIPT
@settings[LANGUAGE_TYPE.FRAMEWORK] = LANGUAGE.FRAMEWORK
View
15 static/js/fiddle-engine.coffee
@@ -1025,21 +1025,10 @@ FiddleFactory = Class.$extend(
for language, languageIndex in secondaryLanguages
if LANGUAGE_CATEGORY[language] is LANGUAGE_CATEGORY[primaryLanguage]
secondaryLanguages[languageIndex] = primaryLanguage
- @loadLanguageSettings secondaryLanguages
+ Language secondaryLanguages
loadLanguages: (storageJSON) ->
- @loadLanguageSettings _.keys(JSON.parse(storageJSON))
-
- loadLanguageSettings: (languages) ->
- # initialize language object
- settings = Language()
- # for each language
- for language in languages
- # if the language is in category
- if LANGUAGE_CATEGORY?[language]
- # set language for the category
- settings.set_language language, LANGUAGE_CATEGORY[language]
- settings
+ Language _.keys(JSON.parse(storageJSON))
layout: ->
$('#snippet, #progress').remove()
View
8 static/js/menu.coffee
@@ -633,9 +633,11 @@ editor = CodeMirror.fromTextArea(document.getElementById('code'),
$('.CodeMirror-placeholder').remove()
ViewModel = ->
- @documentLanguage = ko.observable('html')
- @styleLanguage = ko.observable('less')
- @programLanguage = ko.observable('javascript')
+ settings = Language(if store.get('languages')? then store.get('languages').split(',') else [LANGUAGE.HTML, LANGUAGE.LESS, LANGUAGE.JAVASCRIPT])
+
+ @documentLanguage = ko.observable(settings.get_language(LANGUAGE_TYPE.DOCUMENT))
+ @styleLanguage = ko.observable(settings.get_language(LANGUAGE_TYPE.STYLE))
+ @programLanguage = ko.observable(settings.get_language(LANGUAGE_TYPE.PROGRAM))
@selectBasic = =>
@documentLanguage 'html'
View
5 utility/views.py
@@ -1,11 +1,12 @@
from django.shortcuts import render
from cloud_ide.fiddle.jsonresponse import JsonResponse
-import urllib2
-import base64
+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
response = urllib2.urlopen(url)
html = response.read(200000) #200 kiloBytes

0 comments on commit 68f5e9c

Please sign in to comment.
Something went wrong with that request. Please try again.