()
| 1134 | @app.route("/tools") |
| 1135 | @app.route("/tools/") |
| 1136 | def tools_home(): |
| 1137 | target = (request.args.get("url") or "").strip() |
| 1138 | width = request.args.get("width", "mobile") |
| 1139 | width_map = {"mobile": 430, "tablet": 768, "desktop": 1280} |
| 1140 | if width not in width_map: |
| 1141 | width = "mobile" |
| 1142 | frame_width = width_map[width] |
| 1143 | captures = sorted(SCREENSHOT_DIR.glob("*.png"), key=lambda x: x.stat().st_mtime, reverse=True)[:12] |
| 1144 | body = render_template_string( |
| 1145 | """ |
| 1146 | <section class="hero stack"> |
| 1147 | <div class="sectionTitle"> |
| 1148 | <div> |
| 1149 | <div class="muted small">Tools</div> |
| 1150 | <h1>Capture a full-page screenshot.</h1> |
| 1151 | <div class="muted">Open a link in a clean embedded browser view, then save the whole page as a PNG.</div> |
| 1152 | </div> |
| 1153 | <a class="btn" href="{{ url_for('browser_home') }}">Browser</a> |
| 1154 | </div> |
| 1155 | |
| 1156 | <form class="row" method="get" action="{{ url_for('tools_home') }}"> |
| 1157 | <input name="url" value="{{ target }}" placeholder="https://example.com" style="flex:1;min-width:240px" required> |
| 1158 | <select name="width" style="max-width:170px"> |
| 1159 | <option value="mobile" {% if width == 'mobile' %}selected{% endif %}>Mobile</option> |
| 1160 | <option value="tablet" {% if width == 'tablet' %}selected{% endif %}>Tablet</option> |
| 1161 | <option value="desktop" {% if width == 'desktop' %}selected{% endif %}>Desktop</option> |
| 1162 | </select> |
| 1163 | <button class="btn primary" type="submit">Preview</button> |
| 1164 | </form> |
| 1165 | |
| 1166 | {% if target %} |
| 1167 | <div class="card stack"> |
| 1168 | <div class="row spread"> |
| 1169 | <div> |
| 1170 | <div class="muted small">Preview</div> |
| 1171 | <div class="small mono" style="word-break:break-all">{{ target }}</div> |
| 1172 | </div> |
| 1173 | <div class="row"> |
| 1174 | <a class="btn" target="_blank" rel="noreferrer" href="{{ url_for('browser_open') }}?url={{ target|urlencode }}">Open live</a> |
| 1175 | <button class="btn primary" type="button" onclick="captureFullPage()">Capture PNG</button> |
| 1176 | </div> |
| 1177 | </div> |
| 1178 | |
| 1179 | <div id="shotStatus" class="muted small">Load the preview, then tap Capture PNG.</div> |
| 1180 | |
| 1181 | <div style="overflow:auto;border:1px solid var(--line);border-radius:18px;background:rgba(0,0,0,.16);padding:10px;"> |
| 1182 | <div style="width:{{ frame_width }}px;max-width:none;margin:0 auto;border:1px solid var(--line);border-radius:16px;overflow:hidden;background:#fff;"> |
| 1183 | <iframe id="shotFrame" |
| 1184 | src="{{ url_for('browser_open') }}?url={{ target|urlencode }}&embed=1" |
| 1185 | style="display:block;width:{{ frame_width }}px;height:720px;border:0;background:#fff"></iframe> |
| 1186 | </div> |
| 1187 | </div> |
| 1188 | |
| 1189 | <form id="captureForm" method="post" action="{{ url_for('tools_save_screenshot') }}"> |
| 1190 | <input type="hidden" name="source_url" value="{{ target }}"> |
| 1191 | <input type="hidden" name="width_mode" value="{{ width }}"> |
| 1192 | <input type="hidden" name="image_data" id="image_data"> |
| 1193 | <input type="hidden" name="page_title" id="page_title"> |
nothing calls this directly
no test coverage detected