Example #1
0
    def GET(self, topic_id):
        topics, topic = model.t_helper(topic_id)

        webinput = web.input()

        context = Storage(
            title=_(self.title),
            widgetizer_link=pc_links(self.widgetizer_link, topic_id),
            help_link=pc_links('guide', 'help_' + self.widget_link),
        )
        form = self.get_form(topic=topic)

        if not webinput.has_key("from_widget") or not form.validates():
            get_page("widgetize", context, topic, form)
        else:
            #d = Storage()
            #for k in form.d:
            #    if form.d[k]:
            #        d[k] = form.d[k]
            widget_link = widget_links(self.widget_link, topic.id, **form.d)
            result = Storage(
                link=widget_link,
                link_len=len(widget_link),
                height=form.d.height,
                width=form.d.width,
            )
            result.id = form.d.get("id", "")
            get_page("widgetize", context, topic, form, result=result)
Example #2
0
    def GET(self, format, topic_id):

        i = web.input(order="", search="", search_tags="", ol="")

        topics, topic = model.t_helper(topic_id)
        if not topics:
            # web.seeother(links("index", message=_("No such topic. Update your bookmarks.")))
            # ???
            return

        points = model.search_helper(i, topic)
        model.order_helper(points, i.order)

        points.annotate_by_comments()
        points.annotate_by_tags()
        points.annotate_by_profiles(default=DEFAULT_POINT_PROFILE)

        context = Storage(
            title=_("Topic points"),
        )

        points.last_activity()
        
        get_feed_helper(context, points,
            summary=lambda p: p.comments.list()[0].text,
            link=lambda p: pc_links('point', topic.id, p.id),
            format=format,
            with_content=(not i.ol),
        )
Example #3
0
    def GET(self, topic_id): 
        topics, topic = model.t_helper(topic_id)

        webinput = web.input()

        context = Storage(title=_(self.title),
                          widgetizer_link=pc_links(self.widgetizer_link, topic_id),
                          help_link=pc_links('guide', 'help_' + self.widget_link),
                        )
        form = self.get_form(topic=topic)

        if not webinput.has_key("from_widget") or not form.validates():
            get_page("widgetize", context, topic, form)
        else:
            #d = Storage()
            #for k in form.d:
            #    if form.d[k]:
            #        d[k] = form.d[k]
            widget_link = widget_links(self.widget_link, topic.id, **form.d)
            result = Storage(
                link=widget_link,
                link_len=len(widget_link),
                height=form.d.height,
                width=form.d.width,
            )
            result.id = form.d.get("id", "")
            get_page("widgetize", context, topic, form, result=result)
Example #4
0
    def GET(self, topic_id, onlycode=False, webinput=None):
        presets = webinput or web.input()
        try:
            presets.referer = web.ctx.environ["HTTP_REFERER"]
        except KeyError:
            presets.referer = 0

        ### compat only !!! remove 
        if "disabled_text" not in presets:
            presets.disabled_text = _("Point addition disabled.")
        ###

        context = Storage(
            presets=presets,
            offset = 14,
            framed = 0,
            onlycode=onlycode,
            title=presets.get("title", _("Add point")),
            desturl=pc_links("topic_newpoint", int(topic_id), **presets),
            submitform=pc_links("topic_newpoint", int(topic_id)),
        )

        topics, topic = model.t_helper(topic_id)

        if onlycode:
            presets.referer = ''
            return get_widget('submit', context, topic, presets)

        get_widget('submit', context, topic, presets)
Example #5
0
    def GET(self, format, topic_id):

        i = web.input(order="", search="", search_tags="", ol="")

        topics, topic = model.t_helper(topic_id)
        if not topics:
            # web.seeother(links("index", message=_("No such topic. Update your bookmarks.")))
            # ???
            return

        points = model.search_helper(i, topic)
        model.order_helper(points, i.order)

        points.annotate_by_comments()
        points.annotate_by_tags()
        points.annotate_by_profiles(default=DEFAULT_POINT_PROFILE)

        context = Storage(title=_("Topic points"), )

        points.last_activity()

        get_feed_helper(
            context,
            points,
            summary=lambda p: p.comments.list()[0].text,
            link=lambda p: pc_links('point', topic.id, p.id),
            format=format,
            with_content=(not i.ol),
        )
Example #6
0
    def GET(self, topic_id, onlycode=False, webinput=None):

        presets = webinput or web.input()
        try:
            presets.referer = web.ctx.environ["HTTP_REFERER"]
        except KeyError:
            presets.referer = 0

        context = Storage(
            presets=presets,
            offset = 10,
            framed = 1,
            onlycode=onlycode,
            title=presets.get("title", _("Links")),
            desturl=pc_links("topic", int(topic_id), **presets),
        )

        topics, topic = model.t_helper(topic_id)

        topics.annotate_by_datasources()
        topics.annotate_by_points()

        number_of_points = int(presets.get("number_of_links",
            config.links_per_page))

        if onlycode:
            presets.referer = ''
            return get_widget('topic_links', context, presets, topic)

        get_widget('topic_links', context, presets, topic)
Example #7
0
    def GET(self, topic_id):
        topics, topic = model.t_helper(topic_id)

        if not topics:
            # web.seeother(links("index", message=_("No such topic. Update your bookmarks.")))
            # ???
            return

        points = model.Points(project=topic, external=None)
        points.annotate_by_comments()
        points.annotate_by_tags()
        points.annotate_by_profiles(default=DEFAULT_POINT_PROFILE)

        web.header("content-type", "text/csv; charset=utf-8; header=present")
        import codecs
        print codecs.BOM_UTF8 + csv_report.report(points)
Example #8
0
    def GET(self, topic_id, onlycode=False, webinput=None):

        presets = webinput or web.input()
        try:
            presets.referer = web.ctx.environ["HTTP_REFERER"]
        except KeyError:
            presets.referer = 0

        context = Storage(
            presets=presets,
            offset = 10,
            framed = 1,
            onlycode=onlycode,
            title=presets.get("title", _("Points")),
            desturl=pc_links("topic", int(topic_id), **presets),
#            submitform=pc_links("topic_newpoint", int(topic_id)),
        )

        topics, topic = model.t_helper(topic_id)

#        if not topics:
#            web.seeother(links("index", message=_("No such topic. Update your bookmarks.")))
#            return

        topics.annotate_by_datasources()
        topics.annotate_by_points()

        number_of_points = int(presets.get("number_of_points",
            config.points_per_page))

        points = model.Points(project=topic, external=None)
        
        model.order_helper(points, presets.get('order', 
            config.main_page_point_orders[0]))

        points.limit_by_page(1, length=number_of_points)
        points.annotate_by_comments()
        points.annotate_by_tags()
        points.annotate_by_profiles(default=DEFAULT_POINT_PROFILE)


        if onlycode:
            presets.referer = ''
            return get_widget('topic_points', context, presets, points, topic)

        get_widget('topic_points', context, presets, points, topic)
Example #9
0
    def GET(self, topic_id):
        topics, topic = model.t_helper(topic_id)

        if not topics:
            # web.seeother(links("index", message=_("No such topic. Update your bookmarks.")))
            # ???
            return

        points = model.Points(project=topic, external=None)
        points.annotate_by_comments()
        points.annotate_by_tags()
        points.annotate_by_profiles(default=DEFAULT_POINT_PROFILE)

        web.header("content-type", 
                   "text/csv; charset=utf-8; header=present")
        import codecs
        print codecs.BOM_UTF8 + csv_report.report(points)
Example #10
0
    def POST(self):
        presets = i = web.input(file={})

        topics, topic = model.t_helper(presets.topic_id)

        user = get_user()

        # this is security loophole: topic owner
        # can allow contribution without checking captcha
        if not acl.authorize.add_point(topic):  # no login needed
            print "ERROR: user not authorized to add points"
            return

        if "create":  # == True. in case other commands will be added
            user_loc = user_location()
            if not user_loc[0]:
                MobileMap().GET()  #!!! should never happen
                return

            presets.origin = ''
            presets.address = ''
            presets.url = ''
            tags = presets.get("tags", "")
            presets.lat = float(user_loc[0])
            presets.lon = float(user_loc[1])
            model.encode_coordinates(presets)

            point = model.Points.create(
                user=user,
                name=presets.name,
                lat=presets.lat,
                lon=presets.lon,
                url=presets.url,
                origin=presets.origin,
                tags=tags,
                description="<p>" +
                presets.description.replace("\n", "</p><p>") + "</p>",
                address=presets.address,
                project_id=topic.id,
                fileinfo=i.file,
            )

            web.seeother(links("point", t_id=topic.id, p_id=point.id))
            return
Example #11
0
    def POST(self):
        presets = i = web.input(file={})

        topics, topic = model.t_helper(presets.topic_id)

        user = get_user()

        # this is security loophole: topic owner
        # can allow contribution without checking captcha
        if not acl.authorize.add_point(topic):  # no login needed
            print "ERROR: user not authorized to add points"
            return


        if "create":  # == True. in case other commands will be added
            user_loc = user_location()
            if not user_loc[0]:
                MobileMap().GET()  #!!! should never happen
                return

            presets.origin = ''
            presets.address = ''
            presets.url = ''
            tags = presets.get("tags", "")
            presets.lat = float(user_loc[0])
            presets.lon = float(user_loc[1])
            model.encode_coordinates(presets)

            point = model.Points.create(
                user=user,
                name=presets.name,
                lat=presets.lat,
                lon=presets.lon,
                url=presets.url,
                origin=presets.origin,
                tags=tags,
                description="<p>" + presets.description.replace("\n", "</p><p>") + "</p>",
                address=presets.address,
                project_id=topic.id,
                fileinfo=i.file,
            )

            web.seeother(links("point", t_id=topic.id, p_id=point.id))
            return
Example #12
0
    def GET(self, topic_id, onlycode=False, webinput=None):
        presets = webinput or web.input()
        try:
            presets.referer = web.ctx.environ["HTTP_REFERER"]
        except KeyError:
            presets.referer = 0

        context = Storage(
            presets=presets,
            offset=14,
            framed=0,
            onlycode=onlycode,
            title=presets.get("title", _("Note")),
        )

        topics, topic = model.t_helper(topic_id)

        if onlycode:
            presets.referer = ''
            return get_widget('note', context, topic, presets)

        get_widget('note', context, topic, presets)
Example #13
0
    def POST(self, topic_id):

        #1a
        # wsse auth
        # user = ...
        user = get_wsse_user()
        if user is None:
            unauthorized('um')
            return

        topics, topic = model.t_helper(topic_id)
        if not topics:
            web.notfound()
            return

        # 1b authorize
        if not acl.authorize.add_point(topic):
            forbidden()
            return

        #2 parse XML and store the point
        fc = web.webapi.data()
        entry = model.Point(feed_data.parse_entry(fc))

        point = model.Points.create(
            user=user,
            name=entry.title,
            lat=entry.lat,
            lon=entry.lon,
            url='',
            origin='',
            tags=entry.tags,
            description=entry.description,
            address='',
            project_id=topic_id,
        )

        created(pc_links("point", topic_id, point.id))
Example #14
0
    def POST(self, topic_id):
        
        #1a
        # wsse auth
        # user = ...
        user = get_wsse_user()
        if user is None:
            unauthorized('um')
            return

        topics, topic = model.t_helper(topic_id)
        if not topics:
            web.notfound()
            return

        # 1b authorize
        if not acl.authorize.add_point(topic):
            forbidden()
            return

        #2 parse XML and store the point
        fc = web.webapi.data()
        entry = model.Point(feed_data.parse_entry(fc))

        point = model.Points.create(
                user=user,
                name=entry.title,
                lat=entry.lat,
                lon=entry.lon,
                url='',
                origin='',
                tags=entry.tags,
                description=entry.description,
                address='',
                project_id=topic_id,
            )

        created(pc_links("point", topic_id, point.id))
Example #15
0
    def GET(self, topic_id):
        topics, topic = model.t_helper(topic_id)

        webinput = web.input()

        context = Storage(title=_("Widget Editor"))

        q = webutil.get_query(webinput.url)
        q.id = webinput.id  # comment id

        # !!! ugly! make better
        if "/submit" in webinput.url:
            web.seeother(pc_links("tools_submit_widgetize", topic.id, q))
        elif "/note" in webinput.url:
            web.seeother(pc_links("tools_note_widgetize", topic.id, q))
        elif "/container" in webinput.url:
            web.seeother(pc_links("tools_container_widgetize", topic.id, q))
        elif "/topic_points" in webinput.url:
            web.seeother(pc_links("tools_topic_points_widgetize", topic.id, q))
        elif "/topic_links" in webinput.url:
            web.seeother(pc_links("tools_topic_links_widgetize", topic.id, q))
        elif "/map" in webinput.url:
            web.seeother(pc_links("tools_map_widgetize", topic.id, q))
Example #16
0
    def GET(self, topic_id): 
        topics, topic = model.t_helper(topic_id)

        webinput = web.input()

        context = Storage(title=_("Widget Editor"))

        q = webutil.get_query(webinput.url)
        q.id = webinput.id  # comment id

        # !!! ugly! make better
        if "/submit" in webinput.url:
            web.seeother(pc_links("tools_submit_widgetize", topic.id, q))
        elif "/note" in webinput.url:
            web.seeother(pc_links("tools_note_widgetize", topic.id, q))
        elif "/container" in webinput.url:
            web.seeother(pc_links("tools_container_widgetize", topic.id, q))
        elif "/topic_points" in webinput.url:
            web.seeother(pc_links("tools_topic_points_widgetize", topic.id, q))
        elif "/topic_links" in webinput.url:
            web.seeother(pc_links("tools_topic_links_widgetize", topic.id, q))
        elif "/map" in webinput.url:
            web.seeother(pc_links("tools_map_widgetize", topic.id, q))
Example #17
0
    def GET(self):
        user = get_user()

        i = web.input(page="1", order="", 
                lat="", lon="", search_nearby="", topic_id="",
                search="", search_tags="", mode="list")
        page = int(i.page)

        if i.topic_id:
            topics, topic = model.t_helper(i.topic_id)
        else:
            topic = None

        user_lat, user_lon = user_location()
        if not i.search and not i.search_nearby:
            # in absense of search terms, search nearby
            if user_lat:
                i.search_nearby = "1"
                i.lat, i.lon = float(user_lat), float(user_lon)

        if not topic:
            i.setdefault("nearby_radius", config.nearby_radius)
        else:
            i.nearby_radius = None

        points = model.search_helper(i)

        total_num_of_pages = points.num_of_pages(length=config.points_per_page)
        tags = model.tags_helper()

        model.order_helper(points, i.order)

        if i.mode != "map":  # map shows all points, not just one page
            points.limit_by_page(page, length=config.points_per_page)
        points.annotate_by_comments()
        points.annotate_by_tags()
        points.annotate_by_projects()
        points.annotate_by_profiles(default=DEFAULT_POINT_PROFILE)
        if user_lat:
            points.annotate_by_distance(user_lat, user_lon)

        context = Storage(
            title=_("List of points"),
            nearby_radius=i.nearby_radius,
            search=i.search,
            search_nearby=i.search_nearby,
            status=Storage(
                add="add",
                loc=location_indicator(),  # !!! define better later
                hom="home",
                sea="search",
                inf="info",                 
            ), 
        )

        page_nav_data = Storage(
            nav_data = nav_data(
                add=links.add_point,
                loc=links.place,
                hom=None,
                sea=links.search,
                inf=links.info,
            ),
        )


        context.page_nav_data = page_nav_data

        topics_set = set()
        topics_points = []
        topics_dict = {}
        for p in points:
            for t in p.projects:
                if t.id not in topics_set:
                    topics_set.add(t.id)
                    if topic is None or topic.id != t.id:
                        # do not show topic twice
                        topics_points.append(t)
                    topics_dict[t.id] = t
                    t.points = [p]
                else:
                    topics_dict[t.id].points.append(p)

        if topic is not None:
            if topic.id not in topics_set:
                points = []
            else:
                points = topics_dict[topic.id].points

        get_page('point_list', context, points, topics_points, topic)
Example #18
0
    def GET(self):
        user = get_user()

        i = web.input(page="1",
                      order="",
                      lat="",
                      lon="",
                      search_nearby="",
                      topic_id="",
                      search="",
                      search_tags="",
                      mode="list")
        page = int(i.page)

        if i.topic_id:
            topics, topic = model.t_helper(i.topic_id)
        else:
            topic = None

        user_lat, user_lon = user_location()
        if not i.search and not i.search_nearby:
            # in absense of search terms, search nearby
            if user_lat:
                i.search_nearby = "1"
                i.lat, i.lon = float(user_lat), float(user_lon)

        if not topic:
            i.setdefault("nearby_radius", config.nearby_radius)
        else:
            i.nearby_radius = None

        points = model.search_helper(i)

        total_num_of_pages = points.num_of_pages(length=config.points_per_page)
        tags = model.tags_helper()

        model.order_helper(points, i.order)

        if i.mode != "map":  # map shows all points, not just one page
            points.limit_by_page(page, length=config.points_per_page)
        points.annotate_by_comments()
        points.annotate_by_tags()
        points.annotate_by_projects()
        points.annotate_by_profiles(default=DEFAULT_POINT_PROFILE)
        if user_lat:
            points.annotate_by_distance(user_lat, user_lon)

        context = Storage(
            title=_("List of points"),
            nearby_radius=i.nearby_radius,
            search=i.search,
            search_nearby=i.search_nearby,
            status=Storage(
                add="add",
                loc=location_indicator(),  # !!! define better later
                hom="home",
                sea="search",
                inf="info",
            ),
        )

        page_nav_data = Storage(nav_data=nav_data(
            add=links.add_point,
            loc=links.place,
            hom=None,
            sea=links.search,
            inf=links.info,
        ), )

        context.page_nav_data = page_nav_data

        topics_set = set()
        topics_points = []
        topics_dict = {}
        for p in points:
            for t in p.projects:
                if t.id not in topics_set:
                    topics_set.add(t.id)
                    if topic is None or topic.id != t.id:
                        # do not show topic twice
                        topics_points.append(t)
                    topics_dict[t.id] = t
                    t.points = [p]
                else:
                    topics_dict[t.id].points.append(p)

        if topic is not None:
            if topic.id not in topics_set:
                points = []
            else:
                points = topics_dict[topic.id].points

        get_page('point_list', context, points, topics_points, topic)
Example #19
0
    def GET(self, topic_id, onlycode=False, webinput=None):

        presets = webinput or web.input()
        try:
            presets.referer = web.ctx.environ["HTTP_REFERER"]
        except KeyError:
            presets.referer = 0

        context = Storage(
            presets=presets,
            offset = 10,
            framed = 1,
            onlycode=onlycode,
            title=presets.get("title", _("Points")),
            desturl=pc_links("topic", int(topic_id), **presets),
#            submitform=pc_links("topic_newpoint", int(topic_id)),
        )

        topics, topic = model.t_helper(topic_id)

        topics.annotate_by_datasources()
        topics.annotate_by_points()

        number_of_points = int(presets.get("number_of_points",
            config.points_per_page))

        points = model.Points(project=topic, external=None)
        points.limit_by_page(1, length=number_of_points)
        points.annotate_by_comments()
        points.annotate_by_tags()
        points.annotate_by_profiles(default=DEFAULT_POINT_PROFILE)

        feed_link = feed_links("topic_points",
            topic.id, presets, page=None)

        if "zoom" in topic.profile and topic.profile.zoom != "auto":
            c_lat, c_lon, c_zoom = \
                topic.lat, topic.lon, topic.profile.zoom
            c_zoom = int(c_zoom)
        else:
            c_lat, c_lon, c_zoom = points.central_point(
                config.center_lat, config.center_lon, 14)

        map_context = Storage(
            getmap_url=pc_links.getmap,
            getmap_layers=config.getmap_layers,
            getmap_layers1=config.getmap_layers1,
            getmap_layers2=config.getmap_layers2,
            map_params=config.getmap_params,
            getmap_custom=config.getmap_custom,
            getmap_custom_init=config.getmap_custom_init,
            lat=c_lat,
            lon=c_lon,
            zoom=c_zoom + config.getmap_zoomshift,
            initial_feed=feed_link,
            has_new_point="false",
            getmap_zoom1=config.getmap_zoom1 + config.getmap_zoomshift,
            getmap_zoom2=config.getmap_zoom2 + config.getmap_zoomshift,
        )
        model.encode_coordinates(map_context)

        context.map_context = map_context
        context.page_specific_js = macros.map_js(map_context)

        if onlycode:
            presets.referer = ''
            # !!! map widget can't be part of combo
            self_link = links('map', topic_id, **presets)
            return """<iframe src="%s" style="height:%spx;width:%spx;border:none;"></iframe>""" % \
                (self_link, presets.height, presets.width)


        get_widget('map', context, topic, presets)