Ejemplo n.º 1
0
def search(request):
    if request.method == 'GET' and 'search_string' in request.GET and request.GET['search_string'].strip():
        query_string = request.GET['search_string']
        textNode_query = get_query(query_string, ['text', ])
        textNodes = TextNode.objects.filter(textNode_query).order_by("-id")
        search_results = []
        for node in textNodes:
            search_results.append({"path": node.getTextPath(), "snippet": node.text[:min(len(node.text), 140)]})
        root = getRootNode()
        anchor_nodes = json.dumps({"Anchors": [getGraphInfoForNode(root)], "related_nodes": [], "connections": []})
        Entry_query = get_query(query_string, ['content', ])
        activities = [convertEntryToBlogPost(e) for e in Entry.objects.filter(Entry_query).order_by("-time")]
        return render_to_response("search_results.html",
            {"pagename": "Root",
             "this_url": "/",
             "authForm": AuthenticationForm(),
             "navigation": getNavigationData(request, root.id, root.getType()),
             "anchor_nodes": anchor_nodes,
             "selected_id": root.id,
             "search_string": query_string,
             "search_results": search_results,
             "activities": activities
            },
            context_instance=RequestContext(request))
    else:
        return HttpResponseRedirect('/') # No search
Ejemplo n.º 2
0
def create_node(request, parent_id):
    parent = Slot.objects.get(pk=parent_id)
    createTextNodeForm = CreateTextForm({'text' : "", 'slot_id' : parent_id})
    anchor_nodes = getDataForAlternativesGraph(request, parent.id)
    return render_to_response("node/create.html",
            {"pagename": "Alternative erstellen in "+parent.getShortTitle(),
             "slot_title": parent.getShortTitle(),
             "authForm": AuthenticationForm(),
             "navigation" : getNavigationData(request, parent_id, parent.getType()),
             "anchor_nodes" : anchor_nodes,
             "alternative_form" : createTextNodeForm
            },
        context_instance=RequestContext(request))
Ejemplo n.º 3
0
def home(request):
    root = getRootNode()
    anchor_nodes = json.dumps({"Anchors": [getGraphInfoForNode(root)],
                               "related_nodes" : [],
                               "connections" : []})
    return render_to_response("index.html",
            {"pagename":"Root",
             "this_url": "/",
             "authForm": AuthenticationForm(),
             "navigation" : getNavigationData(request, root.id, root.getType()),
             "anchor_nodes" : anchor_nodes,
             "selected_id" : root.id
             },
        context_instance=RequestContext(request))
Ejemplo n.º 4
0
def refine_structure_node(request, id):
    pattern_node = StructureNode.objects.get(pk=id)
    createTextForm = CreateTextForm({'text' : pattern_node.getText(), 'slot_id' : pattern_node.parent_id})
    anchor_nodes = getDataForAlternativesGraph(request, pattern_node.parent_id)
    return render_to_response("node/refine.html",
        {"pagename": "Verbessern oder erweitern von "+pattern_node.getShortTitle(),
         "pattern_title": pattern_node.getShortTitle(),
         "pattern_text": pattern_node.getText(),
         "this_url": pattern_node.getTextPath(),
         "authForm": AuthenticationForm(),
         "navigation" : getNavigationData(request, pattern_node.id, pattern_node.getType()),
         "anchor_nodes" : anchor_nodes,
         "selected_id" : pattern_node.id,
         "parent_id" : pattern_node.parent_id,
         "refine_form" : createTextForm
        },
        context_instance=RequestContext(request))
Ejemplo n.º 5
0
def path(request, path):
    node = getNodeForPath(path).as_leaf_class()
    if isinstance(node, Slot):
        node = node.node_set.order_by('-rating')[0].as_leaf_class()

    ## structure : Graph  : get top rated siblings and select node
    ###            Path   : path to parent select node
    ###            Content: slots
    ## text      : Graph  : get top rated siblings and select node
    ###            Path   : path to parent select node
    ###            Content: slots

    anchor_nodes = getDataForAlternativesGraph(request, node.parent_id, include_node=node.id)
    return render_to_response("node/show.html",
        {"pagename": node.getShortTitle(),
         "this_url": node.getTextPath(),
         "authForm": AuthenticationForm(),
         "navigation": getNavigationData(request, node.id, node.getType()),
         "anchor_nodes": anchor_nodes,
         "selected_id": node.id
        },
        context_instance=RequestContext(request))