From 74449c6bd278ae72451808bda6611130ff4415d0 Mon Sep 17 00:00:00 2001 From: wrmswindmill Date: Wed, 18 Jul 2018 23:27:40 +0800 Subject: [PATCH] add new code color using highlight.js but indentation has error --- apps/operations/views.py | 4 +-- static/css/code_show.css | 4 ++- static/js/source.js | 32 +++++++++++-------- templates/projects/.source.html.swp | Bin 16384 -> 0 bytes templates/projects/filesub/code-reading.html | 14 ++++---- templates/projects/source.html | 7 +--- 6 files changed, 31 insertions(+), 30 deletions(-) delete mode 100644 templates/projects/.source.html.swp diff --git a/apps/operations/views.py b/apps/operations/views.py index eff461d..cea89b9 100644 --- a/apps/operations/views.py +++ b/apps/operations/views.py @@ -587,7 +587,7 @@ class AddVoteView(View): exist_records = Vote.objects.filter(user=request.user, vote_type_id=object_id, vote_type=vote_type) if exist_records: vote_before = exist_records[0].value - object.vote -= vote_before + object.voteup -= vote_before object.save() exist_records.delete() return HttpResponse(json.dumps({"status": "success", "info": "cancel", "value": -(vote_before), "msg": "取消成功"}), @@ -600,7 +600,7 @@ class AddVoteView(View): vote.vote_type_id = object_id vote.value = vote_value vote.save() - object.vote += int(vote_value) + object.voteup += int(vote_value) object.save() return HttpResponse(json.dumps({"status": "success", "msg": "点赞成功", "value": int(vote_value)}), content_type='application/json') else: diff --git a/static/css/code_show.css b/static/css/code_show.css index ab9b3b1..71509c9 100644 --- a/static/css/code_show.css +++ b/static/css/code_show.css @@ -568,7 +568,8 @@ a:hover { padding: 15px 0px; max-height: 600px; overflow-y: auto; - z-index:3; + z-index:3; + color:black; } .loadCommentpanel-back, .loadQuestionpanel-back { @@ -628,6 +629,7 @@ a:hover { border-radius: 4px; right: 32px; z-index: 3; + color:black; } .ques-title { diff --git a/static/js/source.js b/static/js/source.js index 5171254..2644c37 100644 --- a/static/js/source.js +++ b/static/js/source.js @@ -18,7 +18,7 @@ function getCookie(name) { var csrftoken = getCookie('csrftoken'); function show_annotation(file_id, line_num) { - ev = window.event + ev = window.event; var mousePos = mouseCoords(ev) $.ajax({ @@ -53,7 +53,7 @@ function show_annotation(file_id, line_num) { function close_modify_anno(){ $(".modify_anno_div").remove(); - ev = window.event + ev = window.event; ev.stopPropagation(); } @@ -66,7 +66,7 @@ function inject_modifyAnno_html(item,file_id,linenum) { '取消'+ ''; $(item).after(html_str) - ev = window.event + ev = window.event; ev.stopPropagation(); } @@ -104,7 +104,7 @@ function modify_anno(file_id,line_num){ // FIXME function show_issue_question(file_id, line_num, issue_ids) { issueid_str=issue_ids.toString() - ev = window.event + ev = window.event; var mousePos = mouseCoords(ev) //发送问题id,返回问题内容 $.ajax({ @@ -223,7 +223,7 @@ function add_comment_action(item, id, type) { } } }); - ev = window.event + ev = window.event; ev.stopPropagation(); } @@ -373,7 +373,7 @@ function submint_question(file_id, line_num, content) { function search_symbol(args) { - ev = event || window.event + ev = window.event var mousePos = mouseCoords(ev) $.ajax({ @@ -567,14 +567,14 @@ $(function () { function addcomments(item) { $(item).siblings(".comment-write").removeClass("none"); $(item).addClass("none"); - ev = window.event + ev = window.event; ev.stopPropagation(); } function cancelcom(item) { $(item).parents(".comment-write").siblings("#addcom").removeClass("none"); $(item).parents(".comment-write").addClass("none"); - ev = window.event + ev = window.event; ev.stopPropagation(); } @@ -713,14 +713,18 @@ function add_tab(project_id,path,filename) { if (data.status === 'success') { // 获取code-reading的内容,并填充到对应的code-reading的Element var content = data.html_str - // console.log(content); + div_codereading.innerHTML = content; + if(data.is_dir=="0"){ + hljs.configure({useBR: false}); + hljs.highlightBlock(div_codereading) + // .each(function(i, block) { + // hljs.highlightBlock(block); + // }); + } - hljs.configure({useBR: false}); + - $('.code_Area').each(function(i, block) { - hljs.highlightBlock(block); - }); } else { div_codereading.innerHTML = ""; @@ -807,7 +811,7 @@ function inject_addnoPanel_html(item,file_id,linenum) { ''+ ''; $(item).after(html_str) - ev = window.event + ev = window.event; ev.stopPropagation(); } diff --git a/templates/projects/.source.html.swp b/templates/projects/.source.html.swp deleted file mode 100644 index a65bf3bb7a5c793bd0e4d95f60e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&K1_KE0`%}?97ei;PZc4jb9ER~ zo*7(K^t~dDB?y)K;^q$TOs)gQVyrj}&ZO^dv1PCG#sSUwqXo9?xrO4nE7S%nbcA^= z0_@leC+=za2qprB`Yd-^Kg-D9_8H?G@4s;V-AmuQdgaM#i=YVEdq4ZZ)z_YR_lM`N zUOD&vvL#r$q5cxgr(%%b*Y&5?FKA z)2~Vv&L266SX7xBkAz<(P`#C5`DR&$7+8iqZ^SlPl?mo%RN$4>xX`(g@}kDRo3Y@u zJ5qD-AQP6F8Y*M-3ryVF zni-R8HILM|AMmINGWX06iWK2brgZ)Y-M(jj?$Ah?hlsf&Xsh`F96N0y?c1vkM_OlU z#q)wN1=JvxML39Aj+V;AVdwVE;+?WIoR3mF3(1|sv8N{j0O?Q71yi12Ty&; zIS!xltH6&l_Pyis;1}1waO#l5`o((C{L diff --git a/templates/projects/filesub/code-reading.html b/templates/projects/filesub/code-reading.html index a1b6b55..2637f65 100644 --- a/templates/projects/filesub/code-reading.html +++ b/templates/projects/filesub/code-reading.html @@ -1,12 +1,12 @@ {% load base_filter %} - +
{% formatText2Line project.name file.path as lines %} {% for linenum,line in lines.items %} -
+
{{ linenum }}
- {{ line }} + {{ line | safe }}
@@ -19,11 +19,11 @@ {% if linenum in issues_count %} - + {# {{ question_count | keyValue:linenum }} #} {% elif linenum in questions_count %} - + {% endif %} @@ -32,6 +32,6 @@
-
-{% endfor %} \ No newline at end of file +{% endfor %} +
\ No newline at end of file diff --git a/templates/projects/source.html b/templates/projects/source.html index dbc95de..e0f782f 100644 --- a/templates/projects/source.html +++ b/templates/projects/source.html @@ -22,12 +22,7 @@ - - - - + {{ project.name }}-{{ project.desc }}