def app_render(): #state.app = this return e(Router, h("div", e(nav_ui.MenuNav, toggler=this.toggle_sidebar, contents=this.state["menu_nav_contents"]), e(ui.Sidebar.Pushable, e(nav_ui.SideBarNav, toggled=this.state["sidebar_toggled"]), h("div", e(ui.Segment, e(Route, path="/api", component=this.api_page), e(Route, path="/dashboard", component=this.dashboard_page), e(Route, path="/", exact=True, component=this.library_page), e(Route, path="/library", component=this.library_page), e(Route, path="/favorite", component=this.favorites_page), e(Route, path="/inbox", component=this.inbox_page), e(Route, path="/item/gallery", component=this.gallery_page), e(Route, path="/item/collection", component=this.collection_page), basic=True), ref=this.get_context_ref, className="sidebar-container", ), as_=ui.Segment, attached="bottom", className="main-content" ), e(Alert, contentTemplate=Notif, stack={'limit':6, 'spacing':20}, position="top-right", effect="slide", offset=50), className="bodyheight" ) )
def grouping_render(): title = "" fav = 0 item_id = this.state.id if this.state.data: title = this.state.data.js_name if not item_id: item_id = this.state.data.id artists = [] for a in this.state.artists: if len(a.names) > 0: artists.append(a.names[0].js_name) artist_el = [h("span", x) for x in artists] return e( ui.Segment, e( ui.Card, h( "div", e(Thumbnail, item_id=item_id, item_type=this.state.item_type, size_type=ImageSize.Medium), #e(ui.Label, e(ui.Icon, js_name="star half empty"), avg_rating, className="card-item bottom left", circular=True, size="large", color="orange"), e(ui.Icon, js_name="ellipsis vertical", bordered=True, className="card-item bottom right", link=True, inverted=True), e( ui.Label, e(ui.Icon, js_name="block layout"), len(this.state.galleries), className="card-item top right", ), className="card-content", ), e(ui.Popup, trigger=e( ui.Card.Content, e(ui.Card.Header, title, className="text-ellipsis card-header"), e(ui.Card.Meta, *artist_el, className="text-ellipsis"), ), header=title, content=h("div", *artist_el), hideOnScroll=True, position="bottom center"), link=True), stacked=True, className="no-padding-segment", )
def thumbnail_render(): img_url = "static/img/default.png" if this.state.img: img_url = this.state.img fluid = True if this.props.fluid != js_undefined: fluid = this.props.fluid if this.props.size: fluid = False # can't be defined together return h( "div", e(ui.Loader, active=this.state.loading, inverted=True), e(ui.Image, src=img_url, fluid=fluid, size=this.props.size, disabled=this.props.disabled, centered=this.props.centered, bordered=this.props.bordered, avatar=this.props.avatar, dimmer=this.props.dimmer, height=this.props.height, as_=this.props.as_, hidden=this.props.hidden, shape=this.props.shape, spaced=this.props.spaced, ui=this.props.ui, verticalAlign=this.props.verticalAlign, width=this.props.width))
def page_render(): fav = 0 title = "" item_id = this.state.id if this.state.data: title = str(this.state.data.number) if this.state.data.metatags.favorite: fav = 1 if not item_id: item_id = this.state.data.id add_cls = this.props.className or "" return e(ui.Card, h( "div", e(Thumbnail, item_id=item_id, item_type=this.state.item_type, size_type=ImageSize.Medium), e(ui.Icon, js_name="ellipsis vertical", bordered=True, className="card-item bottom right", link=True, inverted=True), className="card-content", ), e( ui.Card.Content, e(ui.Card.Header, e(ui.Label, title, circular=True), className="text-ellipsis card-header")), className=add_cls, link=True)
def Notif(props): return h( "div", h( "div", e( ui.Message, header=props.customFields.header, content=props.customFields.content, onDismiss=props.handleClose, **props.customFields.mskwargs, ), className="s-alert-box-inner", ), className=props.classNames, id=props.id, style=props.styles, )
def gallery_render(): fav = 0 title = "" rating = 0 artists = [] item_id = this.state.id if this.state.data: rating = this.state.data.rating title = this.state.data.titles[0].js_name if this.state.data.metatags.favorite: fav = 1 if not item_id: item_id = this.state.data.id for a in this.state.data.artists: if len(a.names) > 0: artists.append(a.names[0].js_name) add_cls = this.props.className or "" link = True if not this.props.link == js_undefined: link = this.props.link thumb = e( Thumbnail, item_id=item_id, item_type=this.state.item_type, size_type=ImageSize.Medium, size=this.props.size, ) if link: thumb = e(Link, thumb, to={ 'pathname': '/item/gallery', 'search': utils.query_to_string({'id': item_id}) }) return e(ui.Card, h( "div", thumb, e(ui.Rating, icon="heart", size="massive", className="card-item top left", defaultRating=fav), e(ui.Popup, e(ui.Rating, icon="star", defaultRating=rating, maxRating=10, clearable=True), trigger=e(ui.Label, e(ui.Icon, js_name="star"), rating, className="card-item bottom left", circular=True, size="large", color="yellow", as_="a"), hoverable=True, on="click", hideOnScroll=True, position="left center"), e(ui.Icon, js_name="ellipsis vertical", bordered=True, className="card-item bottom right", link=True, inverted=True), className="card-content", ), e(ui.Popup, trigger=e( ui.Card.Content, e(ui.Card.Header, title, className="text-ellipsis card-header"), e(ui.Card.Meta, *[h("span", x) for x in artists], className="text-ellipsis"), ), header=title, content=h("div", *[h("span", x) for x in artists]), hideOnScroll=True, position="bottom center"), className=add_cls, link=True)
item_view_on_update, 'render': item_view_render }) ViewOptions = createReactClass({ 'displayName': 'ViewOptions', 'getInitialState': lambda: { 'page': 0, 'limit': 50, 'infinitescroll': False, 'items': [], "element": None, "loading": True }, 'render': lambda: h("div") }) def itemdropdown_change(e, d): if this.props.query: utils.go_to(this.props.history, query={'item_type': d.value}, push=False) if this.props.on_change: this.props.on_change(e, d) def itemdropdown_render(): props = this.props item_options = [
def gallerypage_render(): fav = 0 title = "" rating = 0 artists = [] item_id = this.state.id info = "" inbox = False read_count = 0 date_pub = "" date_upd = "" date_read = "" date_added = "" urls = [] parodies = [] if this.state.data: parodies = this.state.data.parodies date_pub = utils.moment.unix(this.state.data.pub_date).format("LL") date_upd = utils.moment.unix(this.state.data.last_updated).format("LLL") date_read = utils.moment.unix(this.state.data.last_read).format("LLL") date_added = utils.moment.unix(this.state.data.timestamp).format("LLL") date_added += " (" + utils.moment.unix(this.state.data.timestamp).fromNow() + ")" date_upd += " (" + utils.moment.unix(this.state.data.last_updated).fromNow() + ")" date_read += " (" + utils.moment.unix(this.state.data.last_read).fromNow() + ")" read_count = this.state.data.times_read rating = this.state.data.rating info = this.state.data.info title = this.state.data.titles[0].js_name if this.state.data.metatags.favorite: fav = 1 inbox = this.state.data.metatags.inbox if not item_id: item_id = this.state.data.id for a in this.state.data.artists: if len(a.names) > 0: artists.append(a.names[0].js_name) for u in this.state.data.urls: urls.append(u.js_name) series_data = [] if this.state.group_data: series_data = this.state.group_data status = this.state.status_data.js_name if this.state.status_data.js_name else "Unknown" rows = [] rows.append(e(ui.Table.Row, e(ui.Table.Cell, e(ui.Header, info, as_="h5"), colSpan="2"))) rows.append(e(ui.Table.Row, e(ui.Table.Cell, e(ui.Header, "Artist(s):", as_="h5"), collapsing=True), e(ui.Table.Cell, *(e("span", x) for x in artists)))) if parodies: rows.append(e(ui.Table.Row, e(ui.Table.Cell, e(ui.Header, "Parody:", as_="h5"), collapsing=True), e(ui.Table.Cell,))) rows.append(e(ui.Table.Row, e(ui.Table.Cell, e(ui.Header, "Language:", as_="h5"), collapsing=True), e(ui.Table.Cell, this.state.lang_data.js_name))) rows.append(e(ui.Table.Row, e(ui.Table.Cell, e(ui.Header, "Status:", as_="h5"), collapsing=True), e(ui.Table.Cell, e(ui.Label, status, color={"completed":"green", "ongoing":"orange"}.get(status.lower(), "grey"))))) rows.append(e(ui.Table.Row, e(ui.Table.Cell, e(ui.Header, "Times read:", as_="h5"), collapsing=True), e(ui.Table.Cell, e(ui.Label, read_count, circular=True)))) rows.append(e(ui.Table.Row, e(ui.Table.Cell, e(ui.Header, "Rating:", as_="h5"), collapsing=True), e(ui.Table.Cell, e(ui.Rating, icon="star", defaultRating=rating, maxRating=10, size="huge", clearable=True)))) tag_rows = [] if this.state.tag_data.__namespace__: # somehow transcrypt ignores this in the loop below ns_tags = this.state.tag_data.__namespace__ ns_tags = sorted([x.js_name for x in ns_tags]) tag_rows.append( e(ui.Table.Row, e(ui.Table.Cell, e(ui.Label.Group, *[e(ui.Label, x, tag=False) for x in ns_tags], ), colSpan="2", ))) for ns in sorted(dict(this.state.tag_data).keys()): ns_tags = this.state.tag_data[ns] ns_tags = sorted([x.js_name for x in ns_tags]) tag_rows.append( e(ui.Table.Row, e(ui.Table.Cell, ns, collapsing=True), e(ui.Table.Cell, e(ui.Label.Group, *[e(ui.Label, x, tag=False) for x in ns_tags], ), ))) rows.append(e(ui.Table.Row, e(ui.Table.Cell, e(ui.Header, "Tags:", as_="h5"), collapsing=True), e(ui.Table.Cell, e(ui.Table, e(ui.Table.Body, *tag_rows, ), celled=True, basic="very", compact=True, )))) rows.append(e(ui.Table.Row, e(ui.Table.Cell, e(ui.Header, "URL(s):", as_="h5"), collapsing=True), e(ui.Table.Cell, e(ui.List, *[e(ui.List.Item, h("span", h("a", x, href=x, target="_blank"), e(ui.List.Icon, js_name="external share"))) for x in urls])))) indicators = [] if inbox: indicators.append(e(ui.Icon, js_name="inbox", size="large", title="This gallery is in your inbox")) return e(ui.Grid, e(ui.Grid.Row,e(ui.Grid.Column, e(ui.Breadcrumb, icon="right arrow",))), e(ui.Grid.Row, e(ui.Grid.Column, e(ui.Grid, e(ui.Grid.Row, e(items.Thumbnail, size_type=ImageSize.Big, item_type=this.state.item_type, item_id=item_id, size="medium", shape="rounded", bordered=True,),), e(ui.Grid.Row, e(ui.Grid.Column, e(ui.Button.Group, e(ui.Button, "Read", primary=True), e(ui.Button.Or, text="or"), e(ui.Button, "Save for later"), ), textAlign="center" ), centered=True, ), container=True, centered=True, verticalAlign="top"), tablet=4, mobile=16, computer=5, widescreen=5, largeScreen=5), e(ui.Grid.Column, e(ui.Grid, e(ui.Grid.Row, e(ui.Grid.Column, e(ui.Rating, icon="heart", size="massive", defaultRating=fav), floated="right",), e(ui.Grid.Column, *indicators, floated="right", textAlign="right"), columns=2, ), e(ui.Grid.Row, e(ui.Grid, e(ui.Grid.Row, e(ui.Grid.Column, e(ui.Header, title, as_="h3"), textAlign="center")), e(ui.Grid.Row, e(ui.Grid.Column, e(ui.Table, e(ui.Table.Body, *rows ), basic="very" ))), stackable=True, padded=False, relaxed=True, ), ), divided="vertically", ), tablet=12, mobile=16, computer=11, widescreen=11, largeScreen=11), columns=2, as_=ui.Segment, loading=this.state.loading, basic=True, ), e(ui.Grid.Row, e(ui.Grid.Column, e(ui.Label, "Date added", e(ui.Label.Detail, date_added))), e(ui.Grid.Column, e(ui.Label, "Last read", e(ui.Label.Detail, date_read))), e(ui.Grid.Column, e(ui.Label, "Last updated", e(ui.Label.Detail, date_upd))), columns=3 ), e(ui.Grid.Row, e(ui.Grid.Column, e(Slider, *[e(items.Gallery, data=x) for x in series_data], loading=this.state.loading_group, secondary=True, label="Series"), )), e(ui.Grid.Row, e(ui.Grid.Column, e(items.ItemView, item_id=item_id, item_type=ItemType.Gallery, related_type=ItemType.Page, label="Pages", container=True, secondary=True))), stackable=True, container=True )
def formatted_json(msg): return h('pre', dangerouslySetInnerHTML={'__html':msg})
Page = createReactClass({ 'displayName': 'ApiPage', 'getInitialState': lambda: { "to_server":"", "from_server":"",}, 'componentWillMount': lambda: this.props.menu(None), 'set_msg_to': lambda msg: this.setState({'to_server':msg}), 'set_msg_from': lambda msg: this.setState({'from_server':msg}), 'render': lambda: e(ui.Container, e(ui.Grid.Column, e(ui.Message, e(ui.Message.Header, tr(this, "ui.h-server-comm", "Server Communication")), h(ui.Message.Content, tr(this, "ui.t-server-comm-tutorial", "..."), as_="pre"), info=True, ), e(ui.Divider), e(ApiForm, to_server=this.set_msg_to, from_server=this.set_msg_from), e(ui.Divider), e(ui.Accordion, e(ui.Accordion.Title, e(ui.Icon, js_name="dropdown"), tr(this, "", "Message")), e(ui.Accordion.Content, e(ui.Message, formatted_json(this.state['to_server']), as_="pre", className="overflow-auto")), e(ui.Accordion.Title, e(ui.Icon, js_name="dropdown"), tr(this, "", "Response")), e(ui.Accordion.Content, e(ui.Message, formatted_json(this.state['from_server']), as_="pre", className="overflow-auto")), exclusive=False, defaultActiveIndex=[0, 1] ) )) })
def sidebar_nav_render(): if this.props['toggled']: nav_width = "very thin" else: nav_width = "thin" icon = False if nav_width == "very thin": icon = True def nav_toggle_handler(e, props): print(props) items = [] items.append(MenuItem("Dashboard", "ui.mi-dashboard", icon="home", url="/dashboard")) items.append(MenuItem("Favorites", "ui.mi-favorites", icon="heart", url="/favorite")) items.append(MenuItem("Library", "ui.mi-library", icon="grid layout", url="/library")) items.append(MenuItem("Inbox", "ui.mi-inbox", icon="inbox", url="/inbox")) items.append(MenuItem("Downloads", "ui.mi-downloads", icon="tasks", url="/downloads")) pref_item = MenuItem("Preferences", "ui.mi-preferences", modal=[e(ui.Modal.Header, tr(this, "ui.mi-preferences", "Preferences"))], icon="settings", position="right") items.append(pref_item) pref_item.children.append(MenuItem("General")) pref_item.children.append(MenuItem("Logins")) pref_item.children.append(MenuItem("Metadata")) pref_item.children.append(MenuItem("Download")) pref_item.children.append(MenuItem("Monitoring")) pref_item.children.append(MenuItem("Ignoring")) pref_item.children.append(MenuItem("Client")) pref_item.children.append(MenuItem("Server")) about_item = MenuItem("About", "ui.mi-about", modal=[e(ui.Modal.Header, tr(this, "ui.mi-about", "About"))], icon="info", position="right") items.append(about_item) about_item.children.append(MenuItem("Plugins")) about_item.children.append(MenuItem("Statistics")) about_item.children.append(MenuItem("Help")) about_item.children.append(MenuItem("Check for updates")) about_item.children.append(MenuItem("Report bug")) about_item.children.append(MenuItem("Visit homepage")) elements = [] elements_left = [] elements_right = [] for n, x in enumerate(items, 1): menu_name = x.name menu_icon = x.icon icon_size = "large" if icon: menu_name = "" if x.position == "right": container = elements_right elif x.position == "left": container = elements_left else: container = elements item_children = (e(ui.Icon, js_name=menu_icon, className="left medium-size", size=icon_size), tr(this, x.t_id, menu_name) if not icon else "",) as_link = {} if x.url: as_link = {"as":NavLink, "to":x.url, "activeClassName":"active"} menu_el = e(ui.Menu.Item, *item_children, js_name=menu_name, header=x.header, onClick=x.handler, index=n, **as_link) if x.modal: menu_el = e(ui.Modal, *x.modal, trigger=menu_el, ) container.append(menu_el) return e(ui.Sidebar, h("div", h("div", *elements_left, className="top-aligned"), h("div", *elements, className="middle-aligned"), h("div", *elements_right, className="bottom-aligned"), className="flex-container"), as_=ui.Menu, animation="push", width=nav_width, vertical=True, visible=True, icon=icon, defaultActiveIndex=3, className="sidebar-nav", size="small" )