Exemple #1
0
    def get_days_display (self):
        elements = Elements ();
        elements.open_element ("div", { "id":"daysearch_return_display" })
        elements.append_to_element ("""<h1 class="heading_font">{{ daysearch_returned.msg_to_user }}</h1>""")
        elements.open_element ("li", { "ng-repeat":"day in daysearch_returned.days" });
        elements.append_to_element ("""
                    <a ng-click="day_toggle_open (day)">{{ day.title }}</a>
                    <p>{{ day.description }}</p>
                    <div collapse="day.is_collapsed">
                        <div class="well well-lg">
                            <div class="g-plus" data-action="share" data-href="//www.adaythere.com/locality_days?user_id={{ day.userid }}&title={{ day.title }}></div>
                            <label>Locality: {{ day.full_locality }} </label><br>
                            <label for="day_keywords">Keywords</label>
                            <input id="day_keywords" class="form-control" type='text' ng-disabled="true" ng-model='day.keywords'></input>
                            <label for="day_description">Description</label>
                            <input id="day_description" class="form-control" type='text' ng-disabled="!day_is_editable (day)" ng-model='day.description'></input>
        """)

        dayview_places = DayViewPlaces ("day")
        elements.append_to_element (dayview_places.get ())
        dayview_photos = DayViewPhotos ("day")
        elements.append_to_element (dayview_photos.get ())

        elements.append_to_element ("""
            <p>Posted by: {{ day.name }} </p>
            Number of reviews: {{day.numberOfReviews}} - Average review: <rating readonly="true" value="day.averageReview" max="10"></rating>
            <a ng-click="show_reviews_for ($index)" style="float: right;">Reviews</a>
            <br>
            <div id="daysearch_review_display_window{{$index}}" ng-show="show_review_display[$index]" class="review_display" >
                <div ng-repeat="review in daysearch_returned.reviews[$index]" ng-style="{'background-color':'#D8D8D8'}">
                    <p>Posted by: {{ review.commenters_name }}</p>
                    <rating readonly="true" value="review.rating" max="10"></rating><br/>
                    <p>{{ review.text }}
                    <a href ng-click="execute_report_function ('review', review)" tooltip-placement="bottom" tooltip="Report" tooltip-trigger="mouseenter" style="float:right;">&#8709;</a>
                </div>
            </div>
            <button id="dayssearch_show_map_button{{$index}}" type="button" ng-click="show_map_of (day, $index)">View Map</button>
            <button ng-click="open_google_plus_window (day.userid, day.title)">Share
                <img src="https://www.gstatic.com/images/icons/gplus-16.png" alt="Share on Google+"/>
            </button>
        """)

        dayview_rater = DayViewRater ("day")
        elements.append_to_element (dayview_rater.get ())

        elements.append_to_element ("""
                        <select id="daysearch_travelmode_selector{{$index}}" ng-model="direction_mode[$index]" ng-options="mode for mode in direction_modes" style="display:none">
                        </select>

                        <div id="googlemap_of_{{$index}}"><div>
                        </div> 
                    </div>
        """)
        elements.close_element ("li");
        elements.append_to_element ("""
            <button type="button" ng-click="return_to_daysearch ()">Search Again</button>
        """);
        elements.close_element ("div");
        
        return elements.get ()
Exemple #2
0
class Modal (object):

    def __init__ (self, template_id):
        self.elements = Elements ()
        self.elements.open_element ("script", {"type":"text/ng-template", "id":template_id});
        
        self.header_contents = Elements ()
        self.header_contents.open_element ("div", {"class":"modal-header"})

        self.body_contents = Elements ()
        self.body_contents.open_element ("div", {"class":"modal-body"})

        self.footer_contents = Elements ()
        self.footer_contents.open_element ("div", {"class":"modal-footer"})
        

    def add_header_content (self, elements):
        self.header_contents.append_to_element (elements.get ())

    def add_body_content (self, elements):
        self.body_contents.append_to_element (elements.get ())

    def add_footer_content (self, elements):
        self.footer_contents.append_to_element (elements.get ())


    def get (self):
        self.header_contents.close_element ("div")
        self.body_contents.close_element ("div")
        self.footer_contents.close_element ("div")

        self.elements.append_to_element (self.header_contents.get ())
        self.elements.append_to_element (self.body_contents.get ())
        self.elements.append_to_element (self.footer_contents.get ())

        self.elements.close_element ("script")

        return self.elements.get ()
Exemple #3
0
class Html5Document:

    def __init__(self, title, attributes=None):
        """
            initializes the html doc string
            title - the doc title
            attributes - a dict to be turned into the attributes
            if a value is set to None then the attribute will be empty, however
            an empty string will be preserved as such
        """

        attribute_str = ""

        if attributes is not None:
            for k, v in attributes.iteritems():
                if v is not None:
                    attribute_str += ' {0}="{1}"'.format(k, v)
                else:
                    attribute_str += ' {0}'.format(k)

        self.html = """
            <!DOCTYPE html>
            <html {0}>
        """.format(attribute_str)

        self.head = """
                <head>
                    <title>{0}</title>
        """.format(title)

        self.elements = Elements()
        self.scripts = ""
        self.body = None


    def add_meta_tags(self, tags):
        """
            tags - a list of dicts to be turned into meta tags
            i.e. [{"name":"description", "content":"Helo World"}, {"charset":"UTF-8"}]
            if a value is set to None then the attribute will be empty, however
            an empty string will be preserved as such
        """

        for tag in tags:
            self.head += """
                    <meta """

            for k, v in tag.iteritems():
                if v is not None:
                    self.head += ' {0}="{1}"'.format(k, v)
                else :
                    self.head += ' {0}'.format(k)
            self.head += ">"

        return self


    def add_links(self, links):
        """
            a list of dicts to be turned into link tags
            i.e. [{"rel":"stylesheet", "href":"css/main.css"}, {"rel":"stylesheet", "type":"text/css", "href":"theme.css"}]
            if a value is set to None then the attribute will be empty, however
            an empty string will be preserved as such
        """

        for link in links:
            self.head += """
                    <link """

            for k, v in link.iteritems():
                if v is not None:
                    self.head += ' {0}="{1}"'.format(k, v)
                else :
                    self.head += ' {0}'.format(k)
            self.head += ">"

        return self


    def add_script_tags_for_head(self, scripts):
        """
            a list of dicts to be turned into script tags
            i.e. [{"src":"js/vendor/modernizr-2.7.1.min.js"}]
            if a value is set to None then the attribute will be empty, however
            an empty string will be preserved as such
        """

        for script in scripts:
            self.head += """
                    <script """

            for k, v in script.iteritems():
                if v is not None:
                    self.head += ' {0}="{1}"'.format(k, v)
                else :
                    self.head += ' {0}'.format(k)
            self.head += "></script>"

        return self


    def add_script_tags_for_body(self, scripts):
        """
            a list of dicts to be turned into script tags
            i.e. [{"src":"js/vendor/modernizr-2.7.1.min.js"}]
            if a value is set to None then the attribute will be empty, however
            an empty string will be preserved as such
        """
        self.scripts = ""

        for script in scripts:
            self.scripts += """
                    <script """

            for k, v in script.iteritems():
                if v is not None:
                    self.scripts += ' {0}="{1}"'.format(k, v)
                else :
                    self.scripts += ' {0}'.format(k)
            self.scripts += "></script>"

        return self


    def add_attributes_to_body(self, attributes):
        """
            attribute - a dict of attributes to be added to the body tag
        """

        attribute_str = ""

        if attributes is not None:
            for k, v in attributes.iteritems():
                if v is not None:
                    attribute_str += ' {0}="{1}"'.format(k, v)
                else :
                    attribute_str += ' {0}'.format(k)

        self.body = """
            <body{0}>""".format(attribute_str)


    def open_element(self, tag, attributes=None, text=""):

        self.elements.open_element(tag, attributes, text)
        return self

    def append_to_element(self, text):

        self.elements.append_to_element(text)
        return self


    def close_element(self, tag):

        self.elements.close_element(tag)
        return self


    def __shiv(self):

        self.head += """
                <!--[if lt IE 9]>
                    <script src="js/html5shiv.js"></script>
                    <script src="js/respond.min.js"></script>
                <![endif]-->
        """


    def get(self):
        """
            returns the html document
        """

        self.__shiv()

        if self.body is None:
            self.body = """
            <body>
            """

        self.html += self.head
        self.html += """
            </head>
        """
        self.html += self.body
        self.html += self.elements.get()
        self.html += self.scripts
        self.html += """
            </body>
        """
        self.html += """
        </html>
        """

        return self.html
Exemple #4
0
    def __init__ (self, logged_in):
        if logged_in:
            element = Elements () 
            element.open_element ("accordion", {"close-others":"true"})
            
            element.open_element ("accordion-group",{"heading":"Saved Days", "is-open":"true"})
            element.append_to_element ("""
                <div class="ng-cloak" ng-show='my_days.length > 0'><input id="my_days_expander" type='button' value="Expand All" ng-click='my_days_expand ()'></input></div>
                <li ng-repeat="day in my_days">
                    <a ng-click="my_day_toggle_open (day)">{{ day.title }}</a>
                    <button type="button" ng-click="delete_day (day)">Delete</button>
                    <div collapse="day.is_collapsed">
                        <div class="well well-lg">
                            <label>Locality: {{ day.full_locality }} </label><br>
                            <label for="day_keywords">Keywords</label>
                            <input id="day_keywords" class="form-control" type='text' ng-disabled="true" ng-model='day.keywords'></input>
                            <label for="day_description">Description</label>
                            <input id="day_description" class="form-control" type='text' ng-disabled="!day_is_editable (day)" ng-model='day.description'></input>
            """)

            dayview_places = DayViewPlaces ("day")
            element.append_to_element (dayview_places.get ())
            dayview_photos = DayViewPhotos ("day")
            element.append_to_element (dayview_photos.get ())

            element.append_to_element ("""
                            <button type="button" ng-disabled="day_is_editable (day)" ng-click="set_day_editable (day, $index)">Edit</button>
                            <button type="button" ng-disabled="!day_is_editable (day)" ng-click="save_modified_day (day)">Save</button>
                            <button type="button" ng-disabled="day_is_editable (day)" ng-click="copy_day_as (day)">Copy As</button>
                            <button type="button" ng-disabled="!day_is_editable (day)" ng-click="cancel_changes_to_day (day)">Cancel</button>
                            <input id="display_day_view_button_{{ $index }}" type="button" ng-click="display_day_view (day, $index)" value="Display"></input>
                            <select ng-model="direction_mode[$index]" ng-options="mode for mode in direction_modes">
                            </select>
                        </div> 
                    </div>
                </li>
            """)
            element.close_element ("accordion-group")
            
            element.open_element ("accordion-group",{"heading":"Deleted Days", "is-open":"false"})
            element.append_to_element ("""
                    <div class="ng-cloak" ng-show='my_deleted_days.length > 0'>
                        <input id="my_deleted_days_expander" type='button' value="Expand All" ng-click='my_deleted_days_expand ()'></input>
                    </div>
                    <li ng-repeat="day in my_deleted_days">
                        <a ng-click="my_day_toggle_open (day)">{{ day.title }}</a>
                        <button type="button" ng-click="restore_day (day)">Restore</button>
                        <div collapse="day.is_collapsed">
                            <div class="well well-lg">
                                <label>Locality: {{ day.full_locality }} </label><br>
                                <label for="deleted_day_keywords">Keywords</label>
                                <input id="deleted_day_keywords" class="form-control" type='text' ng-disabled="true" ng-model='day.keywords'></input>
                                <label for="deleted_day_description">Description</label>
                                <input id="deleted_day_description" class="form-control" type='text' ng-disabled="!day_is_editable (day)" ng-model='day.description'></input>
            """)

            dayview_places = DayViewPlaces ("day")
            element.append_to_element (dayview_places.get ())
            dayview_photos = DayViewPhotos ("day")
            element.append_to_element (dayview_photos.get ())
            
            element.append_to_element ("""
                                <input id="display_day_view_button_{{ $index }}" type="button" ng-click="display_day_view (day, $index)" value="Display"></input>
                                <select ng-model="direction_mode[$index]" ng-options="mode for mode in direction_modes">
                                </select>
                            </div> 
                        </div>
                    </li>
            """)
            element.close_element ("accordion-group")
            element.close_element ("accordion")

            self.html = element.get ()
        else:
            self.html = """