-
Notifications
You must be signed in to change notification settings - Fork 0
/
post.txt
1 lines (1 loc) · 4.47 KB
/
post.txt
1
64|MULT LANGUAGE BOIII|{"cells": [{"lang": null, "type": 2, "content": "int main(void){\n for(int i = 0; i<12; i++){\n printf(\"this code literally cannot run because i havent imported stdio.h\");\n }\n return 0;\n}", "title": "c"}, {"lang": null, "type": 2, "content": "class NewPostView(TemplateView):\n template_name = 'timeline/new.html'\n def get_context_data(self, **kwargs):\n context = super(NewPostView, self).get_context_data(**kwargs)\n context['subtitle'] = '/new'\n context['title'] = 'new post | codeli.ne'\n c = RequestContext(self.request)\n print(context)\n print(c)\n return context\n def post(self, request, *args, **kwargs):\n newpost = Post()\n postdict = json.loads(str(request.body, 'utf-8'))\n try:\n newpost.author = User.objects.get(username=postdict['author'])\n newpost.title = postdict['title']\n newpost.date = datetime.datetime.now()\n except Exception as e:\n print('SOME VALIDATION ERROR')\n print(e)\n return JsonResponse(dict(error='true'))\n newpost.save()\n if not newpost.title:\n newpost.title = 'untitled '+str(newpost.id)\n tags = postdict['tagstring'].split()\n print(tags)\n for tag in tags:\n try:\n tag = ''.join([c for c in tag if c in 'abcdefghijklmnopqrstuvwxyz1234567890-_.'])\n tag_obj = Tag.objects.get(name=tag)\n except Tag.DoesNotExist:\n tag_obj = Tag()\n tag_obj.name = tag\n tag_obj.save()\n newpost.tags.add(tag_obj)\n print(tag)\n print(postdict['cells'])\n if (not postdict['cells']):\n newpost.delete()\n return JsonResponse(dict(success=False, error='empty post'))\n body = dict(cells=postdict['cells'])\n newpost.body = json.dumps(body)\n print(newpost)\n newpost.save()\n return JsonResponse(dict(success=True, link='http://'+request.get_host()+'/'+str(newpost.id)))\n", "title": "py"}, {"lang": null, "type": 1, "content": "## some markdown\n* just\n* for\n* bants", "title": "md"}, {"lang": null, "type": 2, "content": "function setup_inputs(i){\n //$('.newfield').prop('contenteditable',true);\n $($('.cellinputtype')[i]).click(function(){\n var i = $('.cellinputtype').index(this)\n if (this.innerHTML == 'Aa'){\n this.innerHTML = 'MD';\n $($('.cellinputlang')[i]).val(\"markdown\").attr(\"disabled\", true);\n } else if (this.innerHTML == 'MD'){\n this.innerHTML = '{}';\n this.style.paddingTop = 0;\n this.style.fontFamily = \"Consolas,monospace\";\n $($('.cellinputlang')[i]).val(\"language\").attr(\"disabled\", false).css('color', '#909090');\n\n } else {\n this.style.paddingTop = 2;\n this.innerHTML = 'Aa';\n $($('.cellinputlang')[i]).val(\"text\").css(\"color\", \"inherit\").attr(\"disabled\", true);\n //$('.cellinputcontent')[i].style.fontFamily = \"inherit\";\n this.style.fontFamily = \"inherit\";\n }\n $($('.cellinputlang')[i]).change();\n });\n\n $('textarea').each(function () { //from Obsidian on StackOverflow\n this.setAttribute('style', 'height:' + (this.scrollHeight) + 'px;overflow-y:hidden;');\n }).on('input', function () {\n this.style.height = 'auto';\n this.style.height = (this.scrollHeight) + 'px';\n });\n setup_placeholder($('.cellinputname')[i], CELL_NAME);\n setup_placeholder($('.cellinputlang')[i], LANG);\n $($('.cellinputlang')[i]).change(function(){\n mode = this.value.toLowerCase()\n if (mode == this.last_correct_mode) {\n this.style.borderColor = \"#409060\";\n return;\n }\n this.style.borderColor = \"#c06060\";\n console.log('cellinputlang change');\n var editor = ace.edit(\"ace_editor\" + i.toString());\n if (this.value == LANG || this.value == \"\"){\n this.style.borderColor = \"#d8d8d8\";\n return;\n }\n if (mode == \"c\" || mode == \"c++\" || mode == \"cpp\"){\n editor.getSession().setMode(\"ace/mode/c_cpp\");\n return;\n }\n console.log(\"asking for mode change\", editor);\n editor.getSession().setMode(\"ace/mode/\" + mode);\n }).val(\"text\").css(\"color\", \"inherit\").css(\"border-color\", \"#409060\").attr(\"disabled\", true);\n //setup_placeholder(\".cellinputcontent\", CELL_CONTENT);\n}\n", "title": "js"}]}|2016-12-21 12:32:44.024531|1|1