def create_search_page(mediawiki, basedir): meta = { "clear_screen": True, "links": { "0": "0" }, "inputs": { "fields": [ { "name": "search", "line": 18, "column": 9, "height": 1, "width": 31, "bgcolor": 0, "fgcolor": 15, "validate": "call:MediaWiki_UI.callback_validate_search:" + str(mediawiki.id) } ], "confirm": False, "target": "call:MediaWiki_UI.callback_search:" + str(mediawiki.id) }, "publisher_color": 0 } data_cept = bytearray() data_cept.extend(Cept.parallel_mode()) data_cept.extend(Cept.set_screen_bg_color(7)) data_cept.extend(Cept.set_cursor(2, 1)) data_cept.extend(Cept.set_line_bg_color(0)) data_cept.extend(b'\n') data_cept.extend(Cept.set_line_bg_color(0)) data_cept.extend(Cept.double_height()) data_cept.extend(Cept.set_fg_color(7)) data_cept.extend(Cept.from_str(mediawiki.title)) data_cept.extend(b'\r\n') data_cept.extend(Cept.normal_size()) data_cept.extend(b'\n') data_cept.extend(Cept.set_cursor(18, 1)) data_cept.extend(Cept.set_fg_color(0)) data_cept.extend(Cept.from_str(mediawiki.search_string)) # trick: show cursor now so that user knows they can enter text, even though more # data is loading data_cept.extend(Cept.show_cursor()) image = Image_UI(basedir + mediawiki.image, colors = 4) # image = Image_UI(basedir + "wikipedia.png", colors = 4) data_cept.extend(Cept.define_palette(image.palette)) data_cept.extend(image.drcs) data_cept.extend(Cept.hide_cursor()) y = 6 for l in image.chars: data_cept.extend(Cept.set_cursor(y, int((41 - len(image.chars[0])) / 2))) data_cept.extend(Cept.load_g0_drcs()) data_cept.extend(l) y += 1 return (meta, data_cept)
def create_logout(): meta = { "clear_screen": False, "links": { "#": "00000" }, "publisher_color": 7 } data_cept = bytearray() data_cept.extend(Cept.parallel_mode()) data_cept.extend(Cept.clear_screen()) data_cept.extend(Cept.set_cursor(2, 1)) data_cept.extend(Cept.set_screen_bg_color(12)) data_cept.extend(Cept.set_fg_color(7)) data_cept.extend(Login_UI.btx_logo()) data_cept.extend(Cept.set_left_g3()) data_cept.extend(Cept.set_fg_color(15)) data_cept.extend(Cept.repeat("Q", 40)) data_cept.extend(Cept.set_fg_color(7)) data_cept.extend(Cept.set_left_g0()) data_cept.extend(Cept.set_cursor(19, 8)) data_cept.extend(Cept.from_str("Vielen Dank für Ihren Anruf!")) data_cept.extend(b'\r\n') data_cept.extend(b'\r\n') data_cept.extend(Cept.set_left_g3()) data_cept.extend(Cept.set_fg_color(15)) data_cept.extend(Cept.repeat("Q", 40)) return (meta, data_cept)
def create_article_page(sheet_number): is_first_page = sheet_number == 0 if not RSS_UI.feed: RSS_UI.feed = feedparser.parse( "https://www.pagetable.com/?feed=rss2") entry = RSS_UI.feed["entries"][6] title = entry["title"] html = entry["content"][0]["value"] soup = BeautifulSoup(html, 'html.parser') page = Cept_page_from_HTML() page.soup = soup page.article_prefix = "XXX" page.insert_html_tags(soup.children) meta = { "clear_screen": True, "links": { "0": "0" }, "publisher_color": 0 } data_cept = bytearray() data_cept.extend(Cept.parallel_mode()) if is_first_page: data_cept.extend(Cept.set_screen_bg_color(7)) data_cept.extend(Cept.set_cursor(2, 1)) data_cept.extend(Cept.set_line_bg_color(0)) data_cept.extend(b'\n') data_cept.extend(Cept.set_line_bg_color(0)) data_cept.extend(Cept.double_height()) data_cept.extend(Cept.set_fg_color(7)) data_cept.extend(Cept.from_str(title[:39])) data_cept.extend(b'\r\n') data_cept.extend(Cept.normal_size()) data_cept.extend(b'\n') # print navigation # * on sheet 0, so we don't have to print it again on later sheets # * on the last sheet, because it doesn't show the "#" text # * on the second last sheet, because navigating back from the last one needs to show "#" again if sheet_number == 0 or sheet_number >= page.number_of_sheets() - 2: data_cept.extend(Cept.set_cursor(23, 1)) data_cept.extend(Cept.set_line_bg_color(0)) data_cept.extend(Cept.set_fg_color(7)) data_cept.extend(Cept.from_str("0 < Back")) s = "# > Next" data_cept.extend(Cept.set_cursor(23, 41 - len(s))) if sheet_number == page.number_of_sheets() - 1: data_cept.extend(Cept.repeat(" ", len(s))) else: data_cept.extend(Cept.from_str(s)) data_cept.extend(Cept.set_cursor(5, 1)) # add text data_cept.extend(page.cept_for_sheet(sheet_number)) return (meta, data_cept)
def create_login(): meta = { "clear_screen": False, "links": { }, "publisher_color": 7, "inputs": { "fields": [ { "name": "user_id", "hint": "Teilnehmernummer oder # eingeben", "line": 18, "column": 26, "height": 1, "width": 10, "bgcolor": 12, "fgcolor": 3 }, { "name": "ext", "hint": "Mitbenutzer oder # eingeben", "line": 18, "column": 37, "height": 1, "width": 1, "bgcolor": 12, "fgcolor": 3, "type": "number", "cursor_home": True, "default": "1" }, { "name": "password", "hint": "Nächstes Feld mit #; Leer für Gast", "line": 20, "column": 26, "height": 1, "width": 14, "bgcolor": 12, "fgcolor": 3, "type": "password", "validate": "call:Login_UI.callback_login" } ], "confirm": False, "target": "page:000001a", "no_navigation": True } } data_cept = bytearray() data_cept.extend(Cept.parallel_mode()) data_cept.extend(Cept.clear_screen()) data_cept.extend(Cept.set_cursor(2, 1)) data_cept.extend(Cept.set_screen_bg_color(12)) data_cept.extend(Cept.set_fg_color(7)) data_cept.extend(Login_UI.btx_logo()) data_cept.extend(Cept.set_left_g3()) data_cept.extend(Cept.set_fg_color(15)) data_cept.extend(Cept.repeat("Q", 40)) data_cept.extend(Cept.set_fg_color(7)) data_cept.extend(Cept.set_left_g0()) data_cept.extend(Cept.set_cursor(18, 8)) data_cept.extend(Cept.from_str("Teilnehmer")) data_cept.extend(Cept.set_cursor(18, 25)) data_cept.extend(b":") data_cept.extend(Cept.set_cursor(18, 36)) data_cept.extend(Cept.set_fg_color(3)) data_cept.extend(b'-') data_cept.extend(Cept.set_fg_color(7)) data_cept.extend(Cept.set_cursor(20, 8)) data_cept.extend(Cept.from_str("persönl. Kennwort:")) data_cept.extend(b'\r\n') data_cept.extend(Cept.set_left_g3()) data_cept.extend(Cept.set_fg_color(15)) data_cept.extend(Cept.repeat("Q", 40)) return (meta, data_cept)