Commits

reorx committed 37a38b6

do Expand & Shrink

  • Participants
  • Parent commits 329f7ab

Comments (0)

Files changed (12)

File default/knowledge/query/set.py

     knowledge.title=d.title
     knowledge.brief=d.brief
     knowledge.content=d.content
-    if d.parent or d.brother:
+    knowledge.parents.clear()
+    if d.parent!='':
+        print 'p cl ed'
+        print d.parent
         p = Knowledge.objects.filter(title=d.parent)
+        if p:
+            knowledge.parents.add(p.get())
+    if d.brother!='':
+        knowledge.brothers.clear()
         b = Knowledge.objects.filter(title=d.brother)
-        if p:
-            knowledge.parents.clear()
-            knowledge.parents.add(p.get())
         if b:
-            knowledge.brothers.clear()
             knowledge.brothers.add(b.get())
     knowledge.save()
     return knowledge.id
 
+def delete(k_id):
+    k = Knowledge.objects.get(id=int(k_id))
+    if k.itsChildren.all():
+        status = ''
+    else:
+        status = k.title
+        k.delete()
+    return status
+
 def add_parent(d):
     knowledge = create_basic(d,1)
     # brother & parent #

File default/knowledge/query/set.pyc

Binary file modified.

File default/knowledge/urls.py

     #editor
     (r'^editor_contentpart/', editor_contentpart),
     (r'^editor_extendpart/', editor_extendpart),
-    #create, change
+    #create, change, delete
     (r'^create/', create_or_change),
     (r'^change/', create_or_change),
+    (r'^delete/', delete),
     #ajax
     (r'^ajax_parent/', ajax_parent),
     #tip

File default/knowledge/urls.pyc

Binary file modified.

File default/knowledge/views.py

 from my_PIGS.default.models import TimeInfo,Category,Knowledge,Tip,Quickwrite
 
 # query #
-from query import get as knowledge_get
-from query import set as knowledge_set
+from query import get as get_k
+from query import set as set_k
 
 # function #
 def ajax_response(t,c):
     return HttpResponse(t.render(c))
 
 def knowledgeFull(k_id):
-    k = knowledge_get.knowledge(k_id)
+    k = get_k.knowledge(k_id)
     k.category_reset = k.category.name
     k.tips_reset = k.tips.all()
     if k.parents.all():
     else:
         k.brother_reset = ''
     return k
+
+# knowledge #
+def create_or_change(request):
+    print 'in cc'
+    class d: pass
+    d.id =request.POST.get('id')
+    d.category = request.POST.get('category')
+    d.title = request.POST.get('title')
+    d.brief = request.POST.get('brief')
+    d.content = request.POST.get('content')
+    d.parent = request.POST.get('parent')
+    d.brother = request.POST.get('brother')
+    case = (d.category!='' and d.title!='' and d.brief!='' and d.content!='')
+    ####
+    certify = get_k.certify(d)
+    ####
+    if d.id!='': #change
+        print 'change'
+        print d.parent
+        k_id = set_k.change(d)
+    else: #create
+        if case:
+            print 'create'
+            k_id = set_k.create_basic(d)
+        else:
+            k_id = 'crash'
+    return HttpResponse(k_id)
+
+def delete(request):
+    k_id = request.GET.get('knowledge_id')
+    return HttpResponse(set_k.delete(k_id))
 # main #
 def index(request):
-    category_list = knowledge_get.category_all()
+    category_list = get_k.category_all()
     return render_to_response('knowledge/base.html',{
         'category_list': category_list,
         },
     c_id= int(request.GET.get('category'))
     t = 'knowledge/infoarea_knowledgelist.html'
     c = {
-        'html':knowledge_get.knowledge_category_tree(c_id)
+        'html':get_k.knowledge_category_tree(c_id)
     }
     return (ajax_response(t,c))
 
 def infoarea_category(request):
     c_id= int(request.GET.get('category'))
-    category = knowledge_get.category(id=c_id)
+    category = get_k.category(id=c_id)
     t = 'knowledge/infoarea_category.html'
     c = {
         'category' : category,
 
 def content_knowledge(request):
     k_id = int(request.GET.get('knowledge'))
-    knowledge = knowledge_get.knowledge(k_id)
-    knowledge.tips_reset = knowledge_get.tips(k_id)
+    knowledge = get_k.knowledge(k_id)
+    knowledge.tips_reset = get_k.tips(k_id)
     t = 'knowledge/content_knowledge.html'
     c = {
         'knowledge' : knowledge,
         })
     return HttpResponse(t.render(c))
 
-def create_or_change(request):
-    print 'in cc'
-    class d: pass
-    d.id =request.POST.get('id')
-    d.category = request.POST.get('category')
-    d.title = request.POST.get('title')
-    d.brief = request.POST.get('brief')
-    d.content = request.POST.get('content')
-    d.parent = request.POST.get('parent')
-    d.brother = request.POST.get('brother')
-    case = (d.category!='' and d.title!='' and d.brief!='' and d.content!='')
-    ####
-    certify = knowledge_get.certify(d)
-    ####
-    if d.id!='': #change
-        print 'change'
-        print d.parent
-        k_id = knowledge_set.change(d)
-    else: #create
-        if case:
-            print 'create'
-            k_id = knowledge_set.create_basic(d)
-        else:
-            k_id = 'crash'
-    return HttpResponse(k_id)
-
 def ajax_parent(request):
     c_id = request.GET.get('category')
     t = request.GET.get('title')
     k_id  = request.GET.get('knowledge_id')
     html = ''
     if k_id == '':
-        ks = knowledge_get.knowledge_title_search(c_id,t)
+        ks = get_k.knowledge_title_search(c_id,t)
     else:
-        ks = knowledge_get.knowledge_title_search_nochild(c_id,t,k_id)
+        ks = get_k.knowledge_title_search_nochild(c_id,t,k_id)
     for k in ks:
         html += ('<div class="search_result">'+k.title+'</div>')
     return  HttpResponse(html)
 def add_tip(request):
     k_id = request.GET.get('knowledge_id')
     c = request.GET.get('content')
-    t_id = knowledge_set.add_tip(k_id,c)
+    t_id = set_k.add_tip(k_id,c)
     return HttpResponse(t_id)
 
 def change_tip(request):    # include remove
     c = request.GET.get('content')
     t_id = request.GET.get('tip_id')
     if c!='':
-        knowledge_set.change_tip(t_id,c)
+        set_k.change_tip(t_id,c)
         status = 'tip changed'
     else:
-        knowledge_set.remove_tip(t_id)
+        set_k.remove_tip(t_id)
         status = 'tip was removed'
     return HttpResponse(status)
 
 def get_parent_title(request):
     k_id = request.GET.get('knowledge_id')
-    title = knowledge_get.get_parent_title(k_id)
+    title = get_k.get_parent_title(k_id)
     return HttpResponse(title)
 
 def get_self_title(request):
     k_id = request.GET.get('knowledge_id')
-    title = knowledge_get.get_self_title(k_id)
+    title = get_k.get_self_title(k_id)
     return HttpResponse(title)

File default/knowledge/views.pyc

Binary file modified.

File static/knowledge/css/base.css

 /* main */
-#KnowledgeArea a,#KnowledgeArea a:visited,
+#Navs a,#Navs a:visited,
 #AppsArea a,#AppsArea a:visited {
     color: #111;
 }
-/* layout */
+/* invisibles */
 #loading {
     width: 300px;height: 20px;
     background: red;
     display: none;
     z-index: 9999;
 }
+#knowledgeMenu {
+    position: absolute;
+    width: 25px;height: 83px;
+    border: 1px solid #000;
+    z-index: 100;
+}
+/* #Header */
 #Header {
     position: relative;
     height: 50px;
     background: #fff;
     border-bottom: 1px solid #000;
 }
-    #Home {
-        position: absolute;
-        left: 0px;top: 0px;
-        width: 49px;height: 50px;
-        border-right: 1px solid #000;
-    }
-    #KnowledgeArea {
-        position: absolute;
-        left: 50px;right: 0px;top: 0px;
-        height: 50px;
-    }
-        #KnowledgeButton {
-            display: block;
-            position: absolute;
-            left: 0px;top: 0px;bottom: 0px;
-            width: 49px;
-            font-size: 30px;line-height: 50px;text-align: center;
-            border-right: 1px solid #000;
-            z-index: 9;
-        }
-        #CategoryNav {
-            position: absolute;
-            left: 50px;top: 9px;bottom: 9px;
-            border-top: 1px solid #000;
-            border-bottom: 1px solid #000;
-            z-index: 1;
-        }
-
+/* #God */
+#God {
+    position: absolute;
+    left: 0px;top: 0px;
+    width: 49px;height: 50px;
+    border-right: 1px solid #000;
+    background: #fff;
+    z-index: 999;
+}
+#G0, #G1, #G2 { position: absolute;left:0px;top:0px;background: #fff; }
+#G0, #G1 { border-right: 1px solid #000;border-bottom: 1px solid #000; }
+#G0 { width: 29px;height: 29px;z-index: 999; }
+#G0:hover { background: #9a3; }
+#G1 { width: 39px;height: 39px;z-index: 99;}
+#G1:hover { background: #2e2; }
+#G2 { right:0px; bottom:0px; z-index:9;}
+#G2:hover { background: #3f1; }
+/* #Navs */
+#Navs {
+    position: absolute;
+    left: 50px;right: 0px;top: 0px;
+    height: 50px;
+}
+#KnowledgeButton {
+    display: block;
+    position: absolute;
+    left: 0px;top: 0px;bottom: 0px;
+    width: 49px;
+    font-size: 30px;line-height: 50px;text-align: center;
+    border-right: 1px solid #000;
+    z-index: 9;
+}
+#CategoryNav {
+    position: absolute;
+    left: 50px;top: 9px;bottom: 9px;
+    border-top: 1px solid #000;
+    border-bottom: 1px solid #000;
+    z-index: 1;
+}
+/* #Apps */
 #AppsArea {
     position: absolute;
     left: 0px;top: 51px/* #RootNav->border-bottom */;bottom: 0px;
     width: 49px;
     border-right: 1px solid #000;
 }
-    #AppsButton {
-        display: block;
-        position: absolute;
-        left: 0px;right: 0px;top: 0px;
-        height: 50px;
-        font-size: 30px;line-height: 50px;text-align: center;
-        border-bottom: 1px solid #000;
-    }
-#ListArea {
+#AppsButton {
+    display: block;
+    position: absolute;
+    left: 0px;right: 0px;top: 0px;
+    height: 50px;
+    font-size: 30px;line-height: 50px;text-align: center;
+    border-bottom: 1px solid #000;
+}
+/* #Control */
+#Control {
     position: absolute;
     left: 50px;top: 51px;bottom: 0px;
     width: 250px;
     border-right: 1px solid #000;
 }
-    #operateInList {
-        position: absolute;
-        left: 0px;right: 0px;top: 0px;
-        height: 30px;
-        overflow: hidden;
-        background: #fff;
-        border-bottom: 1px solid #000;
-    }
-    .operateInList {
-        position: absolute;
-        left: 0px;right: 0px;top: 0px;bottom: 0px;
-    }
-    #infoInList {
-        position: absolute;
-        left: 0px;right: 0px; top: 31px /*#OperateArea->height*/; bottom: 0px;
-    }
-        #InfoArea {
-            position: absolute;
-            left: 0px;right: 0px;top: 5px;bottom: 10px;
-            background: #fff;
-            overflow-y: hidden;
-        }
-#Content {
+#operateInList {
     position: absolute;
-    left: 350px /*.LeftNarrow->width*/;right: 0px;top: 80px;bottom: 0px;
-    border-left: 1px solid #000;
-    border-top: 1px solid #000;
-    border-right: 1px solid #000;
-    border-top-right-radius: 10px;
-    -moz-box-shadow: 0px 0px 8px #aaa;
-    -webkit-box-shadow: 0px 8px 8px #aaa;
+    left: 0px;right: 0px;top: 0px;
+    height: 30px;
+    overflow: hidden;
+    background: #fff;
+    border-bottom: 1px solid #000;
 }
-    #Content_Main {
-        position: absolute;
-        left: 0px;right: 200px;top: 0px;bottom: 0px;
-        overflow-x: hidden;
-    }
-    #contentExtend {
-        position: absolute;
-        right: 0px;top: 0px;bottom: 0px;
-        width: 199px;
-        border-left: 1px solid #000;
-    }
-# {
+.operateInList {
+    position: absolute;
+    left: 0px;right: 0px;top: 0px;bottom: 0px;
 }
-/* color */
-
-[contenteditable] {
-    outline-width: 0px;
-    outline-color: transparent;
+#infoInList {
+    position: absolute;
+    left: 0px;right: 0px; top: 31px /*#OperateArea->height*/; bottom: 0px;
 }
-
-/* ListArea */
+#InfoArea {
+    position: absolute;
+    left: 0px;right: 0px;top: 5px;bottom: 10px;
+    background: #fff;
+    overflow-y: hidden;
+}
+/* #Control//#List */
 .knowledge_wrap {
     position: relative;
-    overflow: hidden;
     float: right;
-    width: 230px;
-    margin: 5px 0px 0px 10px;
+    /*width: 234px;
+    padding: 5px 0px 0px 10px;*/
+    width: 100%;
+    padding: 5px 0px 0px 0px;
+    height: 23px;
+    border-bottom: 1px solid #aaa;
+}
+.knowledge_wrap:hover {
+    background: #fafafa;
 }
 .knowledge {
-    width: 230px;
+    width: 238px;
     float: right;
     display: block;
-    background: #fff;
 }
+.knowledge, .knowledge:hover { color: #666; }
 .knowledgeMenuButton {
     /*display: block;*/
     position: absolute;
 .knowledgeMenuButton img {
     width: 20px;height: 20px;
 }
-#knowledgeMenu {
+/* #Control//#Category */
+.info_title, .info_content { float:left; }
+.info_title {
+    width: 220px;height:30px;
+    margin: 10px 0 0 10px;
+    border-bottom: 3px solid #555;
+    color: #3a3a3a;
+    font-size: 25px;
+}
+.info_content {
+    width: 190px;
+    background: #fafafa;
+    margin: 0 0 0 10px;
+    padding: 5px 5px 5px 5px;
+}
+.info_content, .info_content a, .info_content a:visited {
+    color: #5a5a5a;
+    font-size: 8px;
+    font-style: italic;
+}
+.info_content a {
+    display: block;
+    height: 15px;
+    margin-left: 8px;
+    float: right;
+    font-style: italic;
+    text-decoration: underline;
+}
+/* #Content */
+#Content {
     position: absolute;
-    width: 25px;height: 83px;
-    border: 1px solid #000;
-    z-index: 100;
+    left: 350px /*.LeftNarrow->width*/;right: 0px;top: 80px;bottom: 0px;
+    border-left: 1px solid #000;
+    border-top: 1px solid #000;
+    border-right: 1px solid #000;
+    border-top-right-radius: 10px;
+    -moz-box-shadow: 0px 0px 8px #aaa;
+    -webkit-box-shadow: 0px 8px 8px #aaa;
 }
+#Content_Main {
+    position: absolute;
+    left: 0px;right: 200px;top: 0px;bottom: 0px;
+    overflow-x: hidden;
+}
+#contentExtend {
+    position: absolute;
+    right: 0px;top: 0px;bottom: 0px;
+    width: 199px;
+    border-left: 1px solid #000;
+}

File static/knowledge/js/base.js

     ajax_get(url,DOM);
 }
 function Content_AddPage(mode) {
+    KNOWLEDGE.id = '';
     var url = '/knowledge/editor_contentpart/'
     var DOM1 = '#Content_Main';
     var DOM2 = '#contentExtend';
         }
     });
 }
+function delete_knowledge() {
+    $.ajax({
+        type: 'GET',
+        url: '/knowledge/delete/?knowledge_id='+KNOWLEDGE.id,
+        success: function(status){
+            if (status=='') {
+                loading_on('can\'t be deleted');
+            } else {
+                loading_on('delete item: '+status);
+                AREA.item.remove();
+            }
+        }
+    });
+}
 ////
 $(document).ready(function() {
     // Golbal //

File static/knowledge/js/pigs.editor.js

 
 /* certify */
 function certifyMain() {
-        var t = $('#InputTitle').val();
-        var b = $('#InputBrief').val();
-        var c = $('#InputContent').val();
-        loading_on(t+'/'+b+'/');
-        if (KNOWLEDGE.ifcreated == 'false')
-        {
-            if (t!='' && b!='' && c!='') { toCreate(); }
-            else
-            {
-                $('#Submit')
-                    .html('create').css({'text-decoration':'line-through'})
-                    .unbind();
-            };
-        }
+    var t = $('#InputTitle').val();
+    var b = $('#InputBrief').val();
+    var c = $('#InputContent').val();
+    loading_on(t+'/'+b+'/');
+    if (KNOWLEDGE.ifcreated == 'false')
+    {
+        if (t!='' && b!='' && c!='') { toCreate(); }
         else
         {
-            if (t!='' && b!='' && c!='') { toSave(); }
-            else
-            {
-                $('#Submit')
-                    .html('save').css({'text-decoration':'line-through'})
-                    .unbind();
-            };
-        }
+            $('#Submit')
+                .html('create').css({'text-decoration':'line-through'})
+                .unbind();
+        };
+    }
+    else
+    {
+        if (t!='' && b!='' && c!='') { toSave(); }
+        else
+        {
+            $('#Submit')
+                .html('save').css({'text-decoration':'line-through'})
+                .unbind();
+        };
+    }
+}
+function certifyParentBrother() {
+    var t = $('#InputTitle').val();
+    var b = $('#InputBrief').val();
+    var c = $('#InputContent').val();
 }
 function certifyTip(tip) {
     Tip(tip);

File templates/knowledge/base.html

     <!--  -->
     <style type="text/css">
         .x, #x {
-            background: #eee;
         }
     </style>
 </head>
 <body>
     <div id="Header" >
-        <div id="Home"></div>
-        <div id="KnowledgeArea" class="LeftNarrow">
+        <div id="God">
+            <div id="G0"></div>
+            <div id="G1"></div>
+            <div id="G2"></div>
+        </div>
+        <div id="Navs" class="LeftNarrow">
             <a href="#knowledge" id="KnowledgeButton">K</a>
             <div id="CategoryNav" style="display:none;z-index:1;">
             {% for category in category_list %}
         <div id="AppsNav">
         </div>
     </div>
-    <div id="ListArea">
+    <div id="Control">
         <div id="operateInList">
             <div id="operate_category" class="operateInList" style="display: none">
                 <a id="entrylist_show" class="OperateButton Button_RS" onclick="InfoArea_KnowledgeList()">Tree</a>
         <div id="contentExtend">
         </div>
     </div>
-    <!---->
+    <!-- invisibles -->
     <div id="loading">Loading..</div>
     <div id="knowledgeMenu" class="hidden">
         <a href="#" id="" class="Button_KM" onclick="Content_EditPage();">Edit</a>
         <a href="#" id="" class="Button_KM" onclick="Content_AddPage('child');">Chi</a>
         <a href="#" id="" class="Button_KM" onclick="Content_AddPage('brother');">Bro</a>
-        <a href="#" id="" class="Button_KM" onclick="">Del</a>
+        <a href="#" id="" class="Button_KM" onclick="delete_knowledge()">Del</a>
     </div>
 </body>
 </html>

File templates/knowledge/infoarea_category.html

-<div>category</div>
-    <div id="x" class="CategoryInfo">name: {{ category.name }}</div>
-<hr />
-<div id="x" class="x">description<br />
-    <div id="" class="CategoryInfo">description: {{ category.description }}</div>
+<div class="info_title">Name</div>
+<div id="x" class="info_content">{{ category.name }}</div>
+
+<div class="info_title">Description</div>
+<div id="" class="info_content">{{ category.description }}</div>
+
+<div class="info_title">Source</div>
+<div id="" class="info_content">
 </div>
-<hr />
-<div id="x" class="x">source</div>
-<hr />
-<div id="x" class="x">tips</div>
+<div id="" class="info_content">
+    <a id="source_edit" href="#">edit</a>
+    <a id="source_showall" href="#">show all</a>
+</div>

File templates/knowledge/infoarea_knowledgelist.html

                     click: function(e){
                         //
                         KNOWLEDGE.id = $(this).attr('kID');
+                        AREA.item = $(this).parent();
                         //
                         var Xpx,Ypx;
                         Xpx = (Number(e.pageX)+10)+'px';