Beispiel #1
0
	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)
Beispiel #2
0
	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)
Beispiel #3
0
 def create_title2(title):
     data_cept = bytearray(Cept.set_cursor(2, 1))
     data_cept.extend(Cept.set_palette(1))
     data_cept.extend(Cept.set_screen_bg_color_simple(4))
     data_cept.extend(b'\x1b\x28\x40'  # load G0 into G0
                      b'\x0f'  # G0 into left charset
                      )
     data_cept.extend(Cept.parallel_mode())
     data_cept.extend(Cept.set_palette(0))
     data_cept.extend(Cept.code_9e())
     data_cept.extend(Cept.set_line_bg_color_simple(4))
     data_cept.extend(b'\n')
     data_cept.extend(Cept.set_line_bg_color_simple(4))
     data_cept.extend(Cept.set_palette(1))
     data_cept.extend(Cept.double_height())
     data_cept.extend(b'\r')
     data_cept.extend(Cept.from_str(title))
     data_cept.extend(b'\n\r')
     data_cept.extend(Cept.set_palette(0))
     data_cept.extend(Cept.normal_size())
     data_cept.extend(Cept.code_9e())
     data_cept.extend(Cept.set_fg_color_simple(7))
     return data_cept
Beispiel #4
0
def create_page(pageid):
	ret = None
	# generated pages
	if pageid.startswith("00000") or pageid == "9a":
		# login
		ret = Login_UI.create_page(User.user(), pageid)
		basedir = PATH_DATA + "00000/"
	if not ret and (pageid.startswith("71") or pageid.startswith("78")):
		# historic page overview
		ret = Historic_UI.create_page(User.user(), pageid)
		basedir = PATH_DATA + "8/"
	if not ret and pageid.startswith("7"):
		# user management
		ret = User_UI.create_page(User.user(), pageid)
		basedir = PATH_DATA + "7/"
	if not ret and pageid.startswith("8"):
		# messaging
		ret = Messaging_UI.create_page(User.user(), pageid)
		basedir = PATH_DATA + "8/"
	if not ret and pageid.startswith("55"):
		# wikipedia
		basedir = PATH_DATA + "55/"
		ret = MediaWiki_UI.create_page(pageid, basedir)
	if not ret and pageid.startswith("35"):
		# Congress Wiki
		basedir = PATH_DATA + "55/"
		ret = MediaWiki_UI.create_page(pageid, basedir)
	if not ret and pageid.startswith("45"):
		# c64 wiki
		basedir = PATH_DATA + "45/"
		ret = MediaWiki_UI.create_page(pageid, basedir)
	if not ret and pageid.startswith("666"):
		# images
		ret = Image_UI.create_page(pageid)
		basedir = PATH_DATA + "55/"
	if not ret and pageid.startswith("6502"):
		# RSS
		basedir = PATH_DATA + "55/"
		ret = RSS_UI.create_page(pageid, basedir)

	if ret:
		(meta, data_cept) = ret
	else:
		basedir = None
		data_cept = None
		for dir in [ "", "hist/10/", "hist/11/" ]:
			for i in reversed(range(0, len(pageid))):
				testdir = PATH_DATA + dir + pageid[:i+1]
				if os.path.isdir(testdir):
					filename = pageid[i+1:]
					sys.stderr.write("filename: '" + filename + "'\n")
					basedir = testdir + "/"
					break
	
			if basedir:
				filename_meta = basedir + filename + ".meta"
				filename_cept = basedir + filename + ".cept"
				filename_cm = basedir + filename + ".cm"

				if os.path.isfile(filename_meta):
					with open(filename_meta) as f:
						meta = json.load(f)
					if os.path.isfile(filename_cept):
						with open(filename_cept, mode='rb') as f:
							data_cept = f.read()
					elif os.path.isfile(filename_cm):
						data_cept = CM.read(filename_cm)
					break
	
		if data_cept is None:
			return None

	try:
		with open(basedir + "a.glob") as f:
			glob = json.load(f)
		meta.update(glob) # combine dicts, glob overrides meta
	except:
		pass

	cept_1 = bytearray()

	cept_1.extend(Cept.hide_cursor())

	if meta.get("clear_screen", False):
		cept_1.extend(Cept.serial_limited_mode())
		cept_1.extend(Cept.clear_screen())
		last_filename_include = ""
		sys.stderr.write("Clear Screen\n");

	cept_1.extend(create_preamble(basedir, meta))

	cept_2 = bytearray()

	if meta.get("cls2", False):
		cept_2.extend(Cept.serial_limited_mode())
		cept_2.extend(Cept.clear_screen())
		last_filename_include = ""

	# header if the data is actually there, if not ignore this
	try:
		hf = headerfooter(pageid, meta["publisher_name"], meta["publisher_color"])
		cept_2.extend(hf)
	except:
		pass

	if meta.get("parallel_mode", False):
		cept_2.extend(Cept.parallel_mode())

	# payload
	cept_2.extend(data_cept)

	cept_2.extend(Cept.serial_limited_mode())

	# footer if it exists
	try:
		cept_2.extend(hf)
	except:
		pass

	cept_2.extend(Cept.sequence_end_of_page())

	inputs = meta.get("inputs")
	return (cept_1, cept_2, meta["links"], inputs, meta.get("autoplay", False))
    def messaging_create_compose(user):
        meta = {
            "include": "a",
            "clear_screen": True,
            "links": {
                "0": "8"
            },
            "publisher_color": 7,
            "inputs": {
                "fields": [{
                    "name":
                    "user_id",
                    "type":
                    "user_id",
                    "line":
                    8,
                    "column":
                    20,
                    "height":
                    1,
                    "width":
                    16,
                    "bgcolor":
                    4,
                    "fgcolor":
                    3,
                    "validate":
                    "call:Messaging_UI.callback_validate_user_id"
                }, {
                    "name":
                    "ext",
                    "type":
                    "ext",
                    "line":
                    8,
                    "column":
                    37,
                    "height":
                    1,
                    "width":
                    1,
                    "bgcolor":
                    4,
                    "fgcolor":
                    3,
                    "default":
                    "1",
                    "validate":
                    "call:Messaging_UI.callback_validate_ext"
                }, {
                    "name": "body",
                    "line": 12,
                    "column": 1,
                    "height": 10,
                    "width": 40,
                    "bgcolor": 4,
                    "fgcolor": 3
                }],
                "action":
                "send_message",
                "price":
                30,
                "target":
                "page:8"
            }
        }

        current_date = datetime.datetime.now().strftime("%d.%m.%Y")
        current_time = datetime.datetime.now().strftime("%H:%M")

        data_cept = bytearray(Cept.set_cursor(2, 1))
        data_cept.extend(Cept.set_palette(1))
        data_cept.extend(Cept.set_screen_bg_color_simple(4))
        data_cept.extend(b'\x1b\x28\x40'  # load G0 into G0
                         )
        data_cept.extend(b'\x0f'  # G0 into left charset
                         )
        data_cept.extend(Cept.parallel_mode())
        data_cept.extend(Cept.set_palette(0))
        data_cept.extend(Cept.code_9e())
        data_cept.extend(b'\n\r')
        data_cept.extend(Cept.set_line_bg_color_simple(4))
        data_cept.extend(b'\n')
        data_cept.extend(Cept.set_line_bg_color_simple(4))
        data_cept.extend(Cept.set_palette(1))
        data_cept.extend(Cept.double_height())
        data_cept.extend(b'\r')
        data_cept.extend(Cept.from_str("Mitteilungsdienst"))
        data_cept.extend(b'\n\r')
        data_cept.extend(Cept.set_palette(0))
        data_cept.extend(Cept.normal_size())
        data_cept.extend(Cept.code_9e())
        data_cept.extend(Cept.set_fg_color_simple(7))
        data_cept.extend(Cept.from_str("Absender:"))
        data_cept.extend(Cept.from_str(user.user_id))
        data_cept.extend(Cept.set_cursor(5, 25))
        data_cept.extend(Cept.from_str(user.ext))
        data_cept.extend(Cept.set_cursor(6, 10))
        data_cept.extend(Cept.from_str(user.first_name))
        data_cept.extend(Cept.set_cursor(7, 10))
        data_cept.extend(Cept.from_str(user.last_name))
        data_cept.extend(Cept.set_cursor(5, 31))
        data_cept.extend(Cept.from_str(current_date))
        data_cept.extend(Cept.set_cursor(6, 31))
        data_cept.extend(Cept.from_str(current_time))
        data_cept.extend(b'\r\n\n')
        data_cept.extend(Cept.from_str("Tln.-Nr. Empfänger:"))
        data_cept.extend(Cept.set_cursor(8, 36))
        data_cept.extend(b'-' b'\r\n\n\n')
        data_cept.extend(b'Text:')
        data_cept.extend(b'\r\n\n\n\n\n\n\n\n\n\n\n\n')
        data_cept.extend(Cept.set_line_bg_color_simple(4))
        data_cept.extend(b'0')
        data_cept.extend(b'\x19'  # switch to G2 for one character
                         b'\x2b\xfe\x7f'  # "+."
                         )
        return (meta, data_cept)
Beispiel #6
0
    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)
Beispiel #7
0
	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)
Beispiel #8
0
	def create_start(user):
		links = { "#": "0" }
		
		if user.messaging.has_new_messages():
			links["8"] = "88"

		if user.user_id == "0":
			links["7"] = "77"

		meta = {
			"include": "a",
			"clear_screen": True,
			"links": links,
			"publisher_color": 7
		}

		t = datetime.datetime.now()
		current_date = t.strftime("%d.%m.%Y  %H:%M")
		if user.stats.last_login is not None:
			t = datetime.datetime.fromtimestamp(user.stats.last_login)
			last_date = t.strftime("%d.%m.%Y")
			last_time = t.strftime("%H:%M")
		else:
			last_date = "--.--.----"
			last_time = "--:--"

		user_name = ""
		if user.salutation:
			user_name += user.salutation + "\n"
		if user.first_name:
			user_name += user.first_name + "\n"
		if user.last_name:
			user_name += user.last_name + "\n"

		notifications = Login_UI.notifications(user)

		data_cept = bytearray()
		data_cept.extend(Cept.clear_screen())
		data_cept.extend(Cept.cursor_home())
		data_cept.extend(b'\n')
		data_cept.extend(Cept.set_palette(1))
		data_cept.extend(Cept.set_screen_bg_color_simple(4))
		data_cept.extend(Cept.load_g0_g0())
		data_cept.extend(Cept.set_left_g0())
		data_cept.extend(Cept.parallel_mode())
		data_cept.extend(Cept.set_palette(0))
		data_cept.extend(Cept.code_9e())
		data_cept.extend(Cept.set_fg_color_simple(7))
		data_cept.extend(Cept.load_g0_drcs())
		data_cept.extend(Cept.set_left_g0())
		data_cept.extend(b'!"#\r\n$%&')
		data_cept.extend(Cept.cursor_up())
		data_cept.extend(Cept.cursor_right())
		data_cept.extend(Cept.load_g0_g0())
		data_cept.extend(Cept.set_left_g0())
		data_cept.extend(b'\n')
		data_cept.extend(Cept.double_height())
		data_cept.extend(Cept.from_str("Bildschirmtext"))
		data_cept.extend(b'\r\n')
		data_cept.extend(Cept.set_line_bg_color_simple(4))
		data_cept.extend(b'\n')
		data_cept.extend(Cept.set_line_bg_color_simple(4))
		data_cept.extend(Cept.set_palette(1))
		data_cept.extend(Cept.double_height())
		data_cept.extend(b'\r')
		data_cept.extend(Cept.from_str("Deutsche Bundespost"))
		data_cept.extend(b'\n\r')
		data_cept.extend(Cept.set_palette(0))
		data_cept.extend(Cept.normal_size())
		data_cept.extend(Cept.code_9e())
		data_cept.extend(b'\r\n')
		data_cept.extend(Cept.set_fg_color_simple(3))
		data_cept.extend(Cept.from_str(current_date))
		data_cept.extend(Cept.set_fg_color_simple(7))
		data_cept.extend(b'\r\n\n')
		data_cept.extend(Cept.from_str("Guten Tag"))
		data_cept.extend(b'\r\n')
		data_cept.extend(Cept.from_str(user_name))
		data_cept.extend(b'\r\n')
		data_cept.extend(Cept.set_fg_color_simple(3))
		data_cept.extend(Cept.from_str(notifications))
		data_cept.extend(Cept.set_fg_color_simple(7))
		data_cept.extend(Cept.set_cursor(19, 1))
		data_cept.extend(Cept.from_str("Sie benutzten Bildschirmtext zuletzt"))
		data_cept.extend(b'\r\n')
		data_cept.extend(Cept.from_str("am "))
		data_cept.extend(Cept.set_fg_color_simple(3))
		data_cept.extend(Cept.from_str(last_date))
		data_cept.extend(Cept.set_fg_color_simple(7))
		data_cept.extend(Cept.from_str(" bis "))
		data_cept.extend(Cept.set_fg_color_simple(3))
		data_cept.extend(Cept.from_str(last_time))
		data_cept.extend(Cept.set_fg_color_simple(7))
		data_cept.extend(b'\r\n\r\n\r\n')
		data_cept.extend(Cept.set_line_bg_color_simple(4))
		data_cept.extend(Cept.from_str("Weiter mit #  oder  *Seitennummer#"))
		return (meta, data_cept)