Repository: benbusby/whoogle-search
File: app/routes.py (Python)

Code before:
                     "($|( *[^a-z0-9] *(((addres|address|adres|adress)|a)?" +
                     " *$)))", query.lower()):
            # HTML IP card tag
            ip_tag = html_soup.new_tag("div")
            ip_tag["class"] = "ZINbbc xpd O9g5cc uUPGi"

            # What is my IP tag
            q_tag = html_soup.new_tag("div")
            q_tag["class"] = "kCrYT"
            q_tag.string = "What's my IP"

            # Distinction boundary
            line = html_soup.new_tag("div")
            line["class"] = "x54gtf"

            # For IP Address html tag
            ip_address = html_soup.new_tag("div")
            ip_address["class"] = "kCrYT"
            ip_address["style"] = "padding-bottom:0;"
            ip_address.string = request.remote_addr

            # Text below the IP address
            ip_text = html_soup.new_tag("div")
            ip_text.string = "Your public IP address"
            ip_text["class"] = "kCrYT"
            ip_text["style"] = "padding-top: 0; color: #9e9e9e!important;"

            # Adding all the above html tags to the IP card
            ip_tag.append(q_tag)
            ip_tag.append(line)
            ip_tag.append(ip_address)
            ip_tag.append(ip_text)

            # Finding the element before which the IP card would be placed
            f_link = html_soup.select_one(".BNeawe.vvjwJb.AP7Wnd")
            ref_element = f_link.find_parent(class_="ZINbbc xpd O9g5cc" +
                                                    " uUPGi")

            # Inserting the element
            ref_element.insert_before(ip_tag)

            response = html_soup

    return render_template(
        'display.html',
        query=urlparse.unquote(query),
        search_type=search_util.search_type,
        config=g.user_config,
        lingva_url=app.config['TRANSLATE_URL'],
        translation=translation,
        translate_to=translate_to,

Review comment (suggestion):
Same comment as above regarding styling, but this element's text color here should be defined:
- in `light-theme.css` as `color: var(--whoogle-secondary-text)` 
- in `dark-theme.css` as `color: var(--whoogle-dark-secondary-text)`

Code after:
    return render_template(
        'display.html',
        query=urlparse.unquote(query),
        search_type=search_util.search_type,
        config=g.user_config,
        lingva_url=app.config['TRANSLATE_URL'],
        translation=translation,
        translate_to=translate_to,
        translate_str=query.replace(
            'translate', ''
        ).replace(
            translation['translate'], ''
        ),
        is_translation=any(
            _ in query.lower() for _ in [translation['translate'], 'translate']
        ) and not search_util.search_type,  # Standard search queries only
        response=response,
        version_number=app.config['VERSION_NUMBER'],
        search_header=(render_template(
            'header.html',
            config=g.user_config,
            logo=render_template('logo.html', dark=g.user_config.dark),
            query=urlparse.unquote(query),
            search_type=search_util.search_type,
            mobile=g.user_request.mobile)
                       if 'isch' not in
                          search_util.search_type else '')), resp_code


@app.route('/config', methods=['GET', 'POST', 'PUT'])
@auth_required
def config():
    config_disabled = app.config['CONFIG_DISABLE']
    if request.method == 'GET':
        return json.dumps(g.user_config.__dict__)
    elif request.method == 'PUT' and not config_disabled:
        if 'name' in request.args:
            config_pkl = os.path.join(
                app.config['CONFIG_PATH'],
                request.args.get('name'))
            session['config'] = (pickle.load(open(config_pkl, 'rb'))
                                 if os.path.exists(config_pkl)
                                 else session['config'])
            return json.dumps(session['config'])
        else:
            return json.dumps({})
    elif not config_disabled:
        config_data = request.form.to_dict()
        if 'url' not in config_data or not config_data['url']:
            config_data['url'] = g.user_config.url