def detectTags(request): text = request.POST.get("text") tagsCount = CONTAINER.getTagManager().tagsCount() minPart = calculateMinPart(tagsCount) tags = CONTAINER.getTagDetector().detect(text, limit=5, minPart = minPart) tagsNames = [tag.name for tag in tags] return HttpResponse(", ".join(tagsNames), content_type="text/plain")
def index(request): tags = CONTAINER.getTagManager().getTags() tagMax = tags and max([tag.count for tag in tags]) or 0 thoughts = CONTAINER.getThoughtManager().latest(settings.THOUGHTS_PER_PAGE) showMore = len(thoughts) == settings.THOUGHTS_PER_PAGE loadMoreUrl = reverse("latestPage", args=[1]) return render(request, "thought/index.html", {'thoughts': thoughts, 'tags': tags, 'tagMax': tagMax, 'showMore': showMore, 'loadMoreUrl': loadMoreUrl})
def tag(request, tag): tags = CONTAINER.getTagManager().getTags() tagMax = tags and max([each.count for each in tags]) or 0 thoughts = CONTAINER.getThoughtManager().searchByTag(tag, settings.THOUGHTS_PER_PAGE) showMore = len(thoughts) == settings.THOUGHTS_PER_PAGE loadMoreUrl = reverse("tagPage", args=[tag, 1]) return render(request, "thought/tag.html", { "tag": tag, 'thoughts': thoughts, 'tags': tags, 'tagMax': tagMax, 'showMore': showMore, 'loadMoreUrl': loadMoreUrl })
def searchTags(request, keyword): tags = CONTAINER.getTagManager().searchTags(keyword) tagNames = [tag.name for tag in tags] return HttpResponse(",".join(tagNames), content_type="text/plain")