1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

'v3.6.3.1'

This commit is contained in:
gnosygnu
2016-06-19 23:58:10 -04:00
parent 96636f3161
commit d4e8590345
1960 changed files with 20790 additions and 9272 deletions

View File

@@ -16,23 +16,27 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.wikis.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import gplx.xowa.wikis.pages.tags.*;
public class Xopage_html_data {
public Xopage_html_data(byte[] display_ttl, byte[] body) {
this.display_ttl = display_ttl;
this.body = body;
}
public byte[] Display_ttl() {return display_ttl;} private byte[] display_ttl;
public byte[] Body() {return body;} private final byte[] body;
public Xopg_tag_mgr Head_tags() {return head_tags;} private final Xopg_tag_mgr head_tags = new Xopg_tag_mgr();
public Xopg_tag_mgr Tail_tags() {return tail_tags;} private final Xopg_tag_mgr tail_tags = new Xopg_tag_mgr();
public byte[] Display_ttl() {return display_ttl;} private byte[] display_ttl;
public byte[] Body() {return body;} private final byte[] body;
public boolean Cbk_enabled() {return cbk_enabled;} private boolean cbk_enabled; public void Cbk_enabled_y_() {this.cbk_enabled = true;}
public Xopg_tag_mgr Head_tags() {return head_tags;} private final Xopg_tag_mgr head_tags = new Xopg_tag_mgr(Bool_.Y);
public Xopg_tag_mgr Tail_tags() {return tail_tags;} private final Xopg_tag_mgr tail_tags = new Xopg_tag_mgr(Bool_.N);
public void Apply(Xoa_page page) {
page.Html_data().Html_restricted_n_();
page.Html_data().Skip_parse_(Bool_.Y);
page.Html_data().Display_ttl_(display_ttl);
page.Html_data().Custom_body_(this.Body());
page.Html_data().Custom_head_tags().Copy(head_tags);
page.Html_data().Custom_tail_tags().Copy(tail_tags);
Xopg_html_data html_data = page.Html_data();
html_data.Html_restricted_n_();
html_data.Skip_parse_(Bool_.Y);
html_data.Display_ttl_(display_ttl);
html_data.Custom_body_(this.Body());
html_data.Custom_head_tags().Copy(head_tags);
html_data.Custom_tail_tags().Copy(tail_tags);
html_data.Cbk_enabled_(cbk_enabled);
}
public static Xopage_html_data err_(String msg) {return new Xopage_html_data(Bry_.Empty, Bry_.new_u8(msg));}

View File

@@ -20,8 +20,8 @@ import gplx.xowa.htmls.core.makes.imgs.*; import gplx.xowa.files.*;
import gplx.xowa.parsers.lnkis.redlinks.*;
public class Xopg_hdump_data {
public byte[] Body() {return body;} public void Body_(byte[] v) {body = v;} private byte[] body;
public Xopg_redlink_idx_list Redlink_mgr() {return redlink_mgr;} private final Xopg_redlink_idx_list redlink_mgr = new Xopg_redlink_idx_list();
public List_adp Imgs() {return imgs;} private final List_adp imgs = List_adp_.new_();
public Xopg_redlink_idx_list Redlink_mgr() {return redlink_mgr;} private final Xopg_redlink_idx_list redlink_mgr = new Xopg_redlink_idx_list();
public List_adp Imgs() {return imgs;} private final List_adp imgs = List_adp_.New();
public void Imgs_add(Xohd_img_itm itm) {imgs.Add(itm);}
public void Imgs_add_img(Xohd_img_itm__base img, Xof_file_itm xfer, int tid) {
img.Data_init_base

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.wikis.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import gplx.langs.htmls.*; import gplx.xowa.htmls.heads.*; import gplx.xowa.wikis.pages.skins.*; import gplx.xowa.xtns.indicators.*;
import gplx.xowa.xtns.pagebanners.*;
import gplx.xowa.xtns.pagebanners.*; import gplx.xowa.wikis.pages.tags.*;
public class Xopg_html_data {
private Ordered_hash ctg_hash;
public boolean Html_restricted() {return html_restricted;} private boolean html_restricted = true;
@@ -31,17 +31,20 @@ public class Xopg_html_data {
? display_ttl_vnt // return variant title; DATE:2014-08-29
: display_ttl // return normal title
;
}
}
public Xopg_html_data Display_ttl_(byte[] v) {display_ttl = v; return this;} private byte[] display_ttl;
public boolean Mode_wtxt_shown() {synchronized (this) {return mode_wtxt_shown;}} public void Mode_wtxt_shown_y_() {synchronized (this) {this.mode_wtxt_shown = true;}} private boolean mode_wtxt_shown;
public byte[] Display_ttl_vnt() {return display_ttl_vnt;} public void Display_ttl_vnt_(byte[] v) {display_ttl_vnt = v;} private byte[] display_ttl_vnt;
public byte[] Content_sub() {return content_sub;} public void Content_sub_(byte[] v) {content_sub = v;} private byte[] content_sub;
public Xopg_page_heading Page_heading() {return page_heading;} private final Xopg_page_heading page_heading = new Xopg_page_heading();
public String Bmk_pos() {return html_bmk_pos;} public void Bmk_pos_(String v) {html_bmk_pos = v;} private String html_bmk_pos;
public Bry_bfr Portal_div_xtn() {return portal_div_xtn;} private Bry_bfr portal_div_xtn = Bry_bfr.reset_(255);
public Bry_bfr Portal_div_xtn() {return portal_div_xtn;} private Bry_bfr portal_div_xtn = Bry_bfr_.Reset(255);
public byte[] Edit_preview_w_dbg() {return Bry_.Add(xtn_scribunto_dbg, edit_preview);} public void Edit_preview_(byte[] v) {edit_preview = v;} private byte[] edit_preview = Bry_.Empty;
public int Lnke_autonumber_next() {return lnke_autonumber++;} private int lnke_autonumber = 1;
public int Sect_uid() {return sect_uid;} private int sect_uid = -1; public int Sect_uid_next() {return ++sect_uid;}
public boolean Cbk_enabled() {return cbk_enabled;} private boolean cbk_enabled; public void Cbk_enabled_(boolean v) {this.cbk_enabled = v;}
public boolean Hdump_exists() {return hdump_exists;} private boolean hdump_exists; public void Hdump_exists_(boolean v) {this.hdump_exists = v;}
public boolean Lang_convert_content() {return lang_convert_content;} public void Lang_convert_content_(boolean v) {lang_convert_content = v;} private boolean lang_convert_content = true;
public boolean Lang_convert_title() {return lang_convert_title;} public void Lang_convert_title_(boolean v) {lang_convert_title = v;} private boolean lang_convert_title = true;
public Xopg_xtn_skin_mgr Xtn_skin_mgr() {return xtn_skin_mgr;} private Xopg_xtn_skin_mgr xtn_skin_mgr = new Xopg_xtn_skin_mgr();
@@ -55,8 +58,8 @@ public class Xopg_html_data {
public Pgbnr_itm Xtn_pgbnr() {return xtn_pgbnr;} public void Xtn_pgbnr_(Pgbnr_itm v) {xtn_pgbnr = v;} private Pgbnr_itm xtn_pgbnr;
public Xoh_head_mgr Head_mgr() {return module_mgr;} private Xoh_head_mgr module_mgr = new Xoh_head_mgr();
public boolean Skip_parse() {return skip_parse;} public void Skip_parse_(boolean v) {skip_parse = v;} private boolean skip_parse;
public Xopg_tag_mgr Custom_head_tags() {return head_tags;} private final Xopg_tag_mgr head_tags = new Xopg_tag_mgr();
public Xopg_tag_mgr Custom_tail_tags() {return tail_tags;} private final Xopg_tag_mgr tail_tags = new Xopg_tag_mgr();
public Xopg_tag_mgr Custom_head_tags() {return head_tags;} private final Xopg_tag_mgr head_tags = new Xopg_tag_mgr(Bool_.Y);
public Xopg_tag_mgr Custom_tail_tags() {return tail_tags;} private final Xopg_tag_mgr tail_tags = new Xopg_tag_mgr(Bool_.N);
public byte[] Custom_html() {return custom_html;} public Xopg_html_data Custom_html_(byte[] v) {custom_html = v; return this;} private byte[] custom_html;
public byte[] Custom_body() {return custom_body;} public Xopg_html_data Custom_body_(byte[] v) {custom_body = v; return this;} private byte[] custom_body;
public byte[] Custom_tab_name() {return custom_tab_name;} public Xopg_html_data Custom_tab_name_(byte[] v) {custom_tab_name = v; return this;} private byte[] custom_tab_name;

View File

@@ -20,7 +20,7 @@ import gplx.xowa.guis.views.*;
public class Xopg_tab_data {
public Xog_tab_itm Tab() {return tab;} public void Tab_(Xog_tab_itm v) {this.tab = v;} private Xog_tab_itm tab;
public boolean Cancel_show() {return cancel_show;} public void Cancel_show_y_() {this.cancel_show = true;} private boolean cancel_show; // used for Special:Search
public Xog_tab_close_mgr Close_mgr() {return close_mgr;} private final Xog_tab_close_mgr close_mgr = new Xog_tab_close_mgr();
public Xog_tab_close_mgr Close_mgr() {return close_mgr;} private final Xog_tab_close_mgr close_mgr = new Xog_tab_close_mgr();
public void Clear() {
this.cancel_show = false;
this.tab = null;

View File

@@ -1,70 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.wikis.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import gplx.langs.htmls.*;
public class Xopg_tag_itm {
public Xopg_tag_itm(byte[] name, byte[] text, Keyval... atrs_ary) {
this.Name = name;
this.Text = text;
this.Atrs_ary = atrs_ary;
}
public final byte[] Name;
public final byte[] Text;
public final Keyval[] Atrs_ary;
public void To_html(Bry_bfr bfr) {
bfr.Add_byte(Byte_ascii.Angle_bgn);
bfr.Add(Name);
int len = Atrs_ary.length;
for (int i = 0; i < len; ++i) {
bfr.Add_byte_space();
Keyval atr = Atrs_ary[i];
bfr.Add_str_a7(atr.Key());
bfr.Add_byte(Byte_ascii.Eq);
bfr.Add_byte(Byte_ascii.Quote);
bfr.Add_str_a7(atr.Val_to_str_or_empty());
bfr.Add_byte(Byte_ascii.Quote);
}
bfr.Add_byte(Byte_ascii.Angle_end);
if (Bry_.Eq(Name, Gfh_tag_.Bry__link)) return;
if (Text != null) {
bfr.Add_byte_nl();
bfr.Add(Text);
bfr.Add_byte_nl();
}
bfr.Add_byte(Byte_ascii.Angle_bgn).Add_byte(Byte_ascii.Slash);
bfr.Add(Name);
bfr.Add_byte(Byte_ascii.Angle_end);
}
public static Xopg_tag_itm New_css_file(Io_url href) {
return new Xopg_tag_itm(Gfh_tag_.Bry__link , null, Keyval_.new_("type", "text/css"), Keyval_.new_("rel", "stylesheet"), Keyval_.new_("href", href.To_http_file_str()));
}
public static Xopg_tag_itm New_css_code(byte[] code) {
return new Xopg_tag_itm(Gfh_tag_.Bry__style , code, Keyval_.new_("type", "text/css"));
}
public static Xopg_tag_itm New_js_file(Io_url src) {
return new Xopg_tag_itm(Gfh_tag_.Bry__script , null, Keyval_.new_("type", "text/javascript"), Keyval_.new_("src", src.To_http_file_str()));
}
public static Xopg_tag_itm New_js_code(byte[] code) {
return new Xopg_tag_itm(Gfh_tag_.Bry__script , code, Keyval_.new_("type", "text/javascript"));
}
public static Xopg_tag_itm New_html_code(Io_url url, String tmpl) {
byte[] html = Io_mgr.Instance.LoadFilBry(url);
return new Xopg_tag_itm(Gfh_tag_.Bry__script , html, Keyval_.new_("type", "text/html"), Keyval_.new_("id", tmpl));
}
}

View File

@@ -0,0 +1,152 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.wikis.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*; import gplx.xowa.langs.vnts.*;
import gplx.xowa.guis.views.*; import gplx.xowa.parsers.utils.*;
public class Xow_page_mgr implements Gfo_invk {
private final Xowe_wiki wiki;
public Xow_page_mgr(Xowe_wiki wiki) {this.wiki = wiki;}
public Xoae_page Load_page_by_ttl (Xoa_ttl ttl) {return Load_page(ttl, Bool_.N);}
public Xoae_page Load_page_by_ttl_for_msg (Xoa_ttl ttl) {return Load_page(ttl, Bool_.Y);}
private Xoae_page Load_page(Xoa_ttl ttl, boolean called_from_msg) {
Xoae_page rv = Xoae_page.New(wiki, ttl);
Load_by_ns(rv, wiki.Utl__url_parser().Parse(ttl.Raw()), ttl, called_from_msg);
return rv;
}
private void Load_by_ns(Xoae_page rv, Xoa_url url, Xoa_ttl ttl, boolean called_from_msg) {
rv.Url_(url); // NOTE: must update page.Url(); should combine with Xoae_page.New()
Xow_ns ns = ttl.Ns();
switch (ns.Id()) {
case Xow_ns_.Tid__special: // Special pages are built (not loaded from db)
wiki.Special_mgr().Special__gen(wiki.App(), wiki, rv, url, ttl);
if (rv.Redirect_to_ttl() != null) {
ttl = wiki.Ttl_parse(rv.Redirect_to_ttl());
url = wiki.Utl__url_parser().Parse(ttl.Raw());
rv.Redirect_to_ttl_(null);
Load_by_ns(rv, url, ttl, called_from_msg);
}
return;
case Xow_ns_.Tid__mediawiki: // MediaWiki msgs can either be loaded from memory, or from database
if ( !called_from_msg // if called_from_msg, fall through to actual data retrieval below, else infinite loop; DATE:2014-05-09
&& Xow_page_tid.Identify_by_ttl(ttl.Page_db()) == Xow_page_tid.Tid_wikitext // skip ".js" and ".css" pages in MediaWiki; DATE:2014-06-13
) {
Xol_lang_itm lang = wiki.Lang();
byte[] msg_key = ttl.Page_db();
Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_b512();
msg_key = lang.Case_mgr().Case_build_1st_lower(tmp_bfr, msg_key, 0, msg_key.length);
byte[] msg_val = Xol_msg_mgr_.Get_msg_itm(tmp_bfr, wiki, wiki.Lang(), msg_key).Val(); // NOTE: do not change to Get_msg_val; Get_msg_val, also replaces $1 with values, and $1 needs to be preserved for callers;
rv.Data_raw_(msg_val);
tmp_bfr.Mkr_rls();
return;
}
break;
}
Load_from_db(rv, ns, ttl, url.Qargs_mgr().Match(Xoa_url_.Qarg__redirect, Xoa_url_.Qarg__redirect__no));
}
private void Load_from_db(Xoae_page rv, Xow_ns ns, Xoa_ttl ttl, boolean redirect_force) {
int redirects = 0;
Xowd_page_itm page_row = Xowd_page_itm.new_tmp();
while (true) { // loop until (a) no more redirects or (b) page not found
// load from page table
boolean exists = wiki.Db_mgr().Load_mgr().Load_by_ttl(page_row, ns, ttl.Page_db());
if (!exists) {rv.Missing_(); return;}
if (wiki.App().Mode().Tid_is_gui()) // NOTE: must check if gui, else will write during mass build; DATE:2014-05-03
wiki.Appe().Usr_dlg().Prog_many("", "", "loading page for ~{0}", ttl.Raw());
// load from text table
wiki.Db_mgr().Load_mgr().Load_page(page_row, ns);
byte[] wtxt = page_row.Text();
rv.Data_raw_(wtxt).Revision_data().Modified_on_(page_row.Modified_on()).Id_(page_row.Id()).Html_db_id_(page_row.Html_db_id());
if (redirect_force) return; // redirect_force passed; return page now, even if page is a redirect elsewhere
// handle redirects
Xoa_ttl redirect_ttl = wiki.Redirect_mgr().Extract_redirect(wtxt);
if ( redirect_ttl == null // not a redirect
|| redirects++ > 4) // too many redirects; something went wrong
return;
// redirect; do some bookkeeping and reset ns / ttl
rv.Redirected_ttls().Add(ttl.Full_url()); // NOTE: must be url_encoded; EX: "en.wikipedia.org/?!" should generate link of "en.wikipedia.org/%3F!?redirect=no"
if (rv.Redirected_src() == null) rv.Redirected_src_(wtxt); // only add src for first redirect; DATE:2014-07-11
rv.Ttl_(redirect_ttl);
ns = redirect_ttl.Ns();
ttl = redirect_ttl;
}
}
public Xoae_page Load_page_and_parse(Xoa_url url, Xoa_ttl ttl) {return Load_page_and_parse(url, ttl, wiki.Lang(), wiki.Appe().Gui_mgr().Browser_win().Active_tab(), true);}
public Xoae_page Load_page_and_parse(Xoa_url url, Xoa_ttl ttl, Xol_lang_itm lang, Xog_tab_itm tab, boolean parse_page) {
wiki.Init_assert();
Xoae_page page = Xoae_page.New(wiki, ttl); page.Tab_data().Tab_(tab);
// COMMENT: breaks bookmark; if (tab != null) tab.Page_ref_(page); // HACK: (1) null check for http server; (2) Page_ref_(page) needed for log in xobc
this.Load_by_ns(page, url, ttl, false);
if (page.Missing()) { // page doesn't exist; try variants
boolean vnt_missing = true;
Xol_vnt_mgr vnt_mgr = lang.Vnt_mgr();
if (vnt_mgr.Enabled()) { // if vnt enabled, then try to load by vnt form; DATE:2015-09-15
gplx.xowa.wikis.data.tbls.Xowd_page_itm page_itm = vnt_mgr.Convert_mgr().Convert_ttl(wiki, ttl);
if (page_itm != null && page_itm.Exists()) {
Xoa_ttl vnt_ttl = Xoa_ttl.parse(wiki, ttl.Ns().Id(), page_itm.Ttl_page_db());
page = this.Load_page(vnt_ttl, false);
vnt_missing = page.Missing();
}
}
if (vnt_missing) {
if (ttl.Ns().Id_is_file()) {
Xowe_wiki commons_wiki = (Xowe_wiki)wiki.Appe().Wiki_mgr().Get_by_or_null(wiki.Commons_wiki_key());
if (commons_wiki != null) { // commons exists
if (!Bry_.Eq(wiki.Domain_bry(), commons_wiki.Domain_bry())) { // !Bry_.Eq is recursion guard
Xoae_page rv = commons_wiki.Data_mgr().Load_page_and_parse(url, ttl, wiki.Lang(), tab, true);
if (rv.Exists()) {
rv.Commons_mgr().Source_wiki_(wiki);
return rv;
}
else {
page.Missing_(false);
page.Commons_mgr().Xowa_mockup_(true);
return page;
}
}
}
}
else
return page.Missing_();
}
}
if (page.Missing()) return page; // NOTE: commons can return null page
page.Tab_data().Tab_(tab);
page.Lang_(lang);
if (parse_page)
wiki.Parser_mgr().Parse(page, false); // NOTE: do not clear page b/c reused for search
return page;
}
public void Redirect(Xoae_page page, byte[] page_bry) {
Xoa_ttl trg_ttl = Xoa_ttl.parse(wiki, page_bry);
Xoa_url trg_url = Xoa_url.new_(wiki.Domain_bry(), page_bry);
page.Ttl_(trg_ttl).Url_(trg_url).Redirected_(true);
wiki.Data_mgr().Load_from_db(page, trg_ttl.Ns(), trg_ttl, trg_url.Qargs_mgr().Match(Xoa_url_.Qarg__redirect, Xoa_url_.Qarg__redirect__no));
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_create_enabled_)) wiki.Db_mgr().Save_mgr().Create_enabled_(m.ReadYn("v"));
else if (ctx.Match(k, Invk_update_modified_on_enabled_)) wiki.Db_mgr().Save_mgr().Update_modified_on_enabled_(m.ReadYn("v"));
else return Gfo_invk_.Rv_unhandled;
return this;
}
private static final String Invk_create_enabled_ = "create_enabled_", Invk_update_modified_on_enabled_ = "update_modified_on_enabled_";
}

View File

@@ -0,0 +1,46 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.wikis.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import gplx.xowa.guis.views.*;
public class Xowe_page_mgr {
private final Xowe_wiki wiki;
public Xowe_page_mgr(Xowe_wiki wiki) {this.wiki = wiki;}
public Xoae_page Load_page(Xoa_url url, Xoa_ttl ttl, Xog_tab_itm tab) {
Xoa_app_.Usr_dlg().Log_many("", "", "page.load: url=~{0}", url.To_str());
Wait_for_popups();
Xowe_wiki_.Rls_mem_if_needed(wiki);
// load page meta; wait_for_popups
Xoae_page page = wiki.Data_mgr().Load_page_and_parse(url, ttl, wiki.Lang(), tab, false);
boolean hdump_exists = page.Revision_data().Html_db_id() != -1 && wiki.Appe().Api_root().Wiki().Hdump().Read_preferred();
page.Html_data().Hdump_exists_(hdump_exists);
Wait_for_popups();
// load page text
if (hdump_exists)
wiki.Html__hdump_mgr().Load_mgr().Load_by_edit(page);
else
wiki.Parser_mgr().Parse(page, false);
return page;
}
private static void Wait_for_popups() {// HACK: wait for popups to finish, else thread errors due to popups and loader mutating cached items
int wait_count = 0;
while (gplx.xowa.htmls.modules.popups.Xow_popup_mgr.Running() && ++wait_count < 100)
gplx.core.threads.Thread_adp_.Sleep(10);
}
}

View File

@@ -0,0 +1,31 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.wikis.pages.tags; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
import gplx.xowa.guis.cbks.*; import gplx.core.gfobjs.*;
public class Xopg_alertify_ {
public static void Add_tags(Xopg_tag_mgr head_tags, Io_url http_root) {
Io_url alertify_root = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "lib", "alertify");
head_tags.Add(Xopg_tag_itm.New_css_file(alertify_root.GenSubFil_nest("themes", "alertify.core.css")));
head_tags.Add(Xopg_tag_itm.New_css_file(alertify_root.GenSubFil_nest("themes", "alertify.bootstrap.css")));
head_tags.Add(Xopg_tag_itm.New_js_file(alertify_root.GenSubFil_nest("lib", "alertify-0.3.11.js")));
head_tags.Add(Xopg_tag_itm.New_js_file(alertify_root.GenSubFil_nest("lib", "xo-alertify-0.0.1.js")));
}
public static void Exec_log(Xog_json_wkr wkr, String msg) {
wkr.Send_json("xo.alertify.log_by_str", Gfobj_nde.New().Add_str("msg", msg));
}
}

View File

@@ -0,0 +1,88 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.wikis.pages.tags; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
import gplx.langs.htmls.*;
public class Xopg_tag_itm {
Xopg_tag_itm(byte tid, byte[] node, byte[] href, byte[] body, Keyval... atrs) {
this.tid = tid;
this.node = node;
this.href = href;
this.body = body;
this.atrs = atrs;
}
public final String Source = "xowa";
public byte Tid() {return tid;} private final byte tid;
public byte[] Node() {return node;} private final byte[] node;
public byte[] Href() {return href;} private final byte[] href;
public byte[] Body() {return body;} private final byte[] body;
public Keyval[] Atrs() {return atrs;} private final Keyval[] atrs;
public void To_html(Bry_bfr bfr) {
bfr.Add_byte(Byte_ascii.Angle_bgn);
bfr.Add(node);
To_html_atr(bfr, "data-source", "xowa");
int len = atrs.length;
for (int i = 0; i < len; ++i) {
Keyval atr = atrs[i];
To_html_atr(bfr, atr.Key(), atr.Val_to_str_or_empty());
}
bfr.Add_byte(Byte_ascii.Angle_end);
if (!Bry_.Eq(node, Gfh_tag_.Bry__link)) {
if (body != null) {
bfr.Add_byte_nl();
bfr.Add(body);
bfr.Add_byte_nl();
}
bfr.Add_byte(Byte_ascii.Angle_bgn).Add_byte(Byte_ascii.Slash);
bfr.Add(node);
bfr.Add_byte(Byte_ascii.Angle_end);
}
bfr.Add_byte_nl();
}
private static void To_html_atr(Bry_bfr bfr, String key, String val) {
bfr.Add_byte_space();
bfr.Add_str_a7(key);
bfr.Add_byte(Byte_ascii.Eq);
bfr.Add_byte(Byte_ascii.Quote);
bfr.Add_str_a7(val);
bfr.Add_byte(Byte_ascii.Quote);
}
public static final byte Tid__css_file = 0, Tid__css_code = 1, Tid__js_file = 2, Tid__js_code = 3, Tid__htm_frag = 4;
private static final Keyval
Tag__type_css = Keyval_.new_("type", "text/css"), Tag__type_js = Keyval_.new_("type", "text/javascript"), Tag__type_html = Keyval_.new_("type", "text/html")
, Tag__rel_stylesheet = Keyval_.new_("rel", "stylesheet");
public static Xopg_tag_itm New_css_file(Io_url href_url) {
byte[] href = href_url.To_http_file_bry();
return new Xopg_tag_itm(Tid__css_file, Gfh_tag_.Bry__link , href, null, Tag__type_css, Tag__rel_stylesheet, Keyval_.new_("href", String_.new_u8(href)));
}
public static Xopg_tag_itm New_css_code(byte[] code) {
return new Xopg_tag_itm(Tid__css_code, Gfh_tag_.Bry__style , null, code, Tag__type_css);
}
public static Xopg_tag_itm New_js_file(Io_url src_url) {
byte[] src = src_url.To_http_file_bry();
return new Xopg_tag_itm(Tid__js_file , Gfh_tag_.Bry__script, src , null, Tag__type_js, Keyval_.new_("src", String_.new_u8(src)));
}
public static Xopg_tag_itm New_js_code(String code) {return New_js_code(Bry_.new_u8(code));}
public static Xopg_tag_itm New_js_code(byte[] code) {
return new Xopg_tag_itm(Tid__js_code , Gfh_tag_.Bry__script, null, code, Tag__type_js);
}
public static Xopg_tag_itm New_htm_frag(Io_url url, String id) {
byte[] html = Io_mgr.Instance.LoadFilBry(url);
return new Xopg_tag_itm(Tid__htm_frag, Gfh_tag_.Bry__script, null, html, Tag__type_html, Keyval_.new_("id", id));
}
}

View File

@@ -15,9 +15,11 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.wikis.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
package gplx.xowa.wikis.pages.tags; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
public class Xopg_tag_mgr {
private final List_adp list = List_adp_.new_();
private final List_adp list = List_adp_.New();
public Xopg_tag_mgr(boolean pos_is_head) {this.pos_is_head = pos_is_head;}
public boolean Pos_is_head() {return pos_is_head;} private final boolean pos_is_head;
public int Len() {return list.Len();}
public Xopg_tag_itm Get_at(int i) {return (Xopg_tag_itm)list.Get_at(i);}
public void Add(Xopg_tag_itm... ary) {for (Xopg_tag_itm itm : ary) list.Add(itm);}
@@ -31,7 +33,6 @@ public class Xopg_tag_mgr {
for (int i = 0; i < len; ++i) {
Xopg_tag_itm tag = this.Get_at(i);
tag.To_html(bfr);
bfr.Add_byte_nl();
}
return bfr.To_bry_and_clear();
}
@@ -39,11 +40,10 @@ public class Xopg_tag_mgr {
int len = this.Len();
for (int i = 0; i < len; ++i) {
Xopg_tag_itm tag = this.Get_at(i);
if ( Bry_.Eq(tag.Name, gplx.langs.htmls.Gfh_tag_.Bry__style)
&& tag.Text != null
if ( Bry_.Eq(tag.Node(), gplx.langs.htmls.Gfh_tag_.Bry__style)
&& tag.Body() != null
) {
tag.To_html(bfr);
bfr.Add_byte_nl();
}
}
return bfr.To_bry_and_clear();

View File

@@ -0,0 +1,112 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.wikis.pages.tags; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
import gplx.langs.htmls.*;
public class Xopg_tag_wtr {
public static boolean Loader_as_script_static = true; // TEST
public static byte[] Write(Bry_bfr bfr, boolean write_loader_tag, Xopg_tag_wtr_cbk cbk, Xopg_tag_mgr tag_mgr) {
boolean loader_as_script = Loader_as_script_static; // allow disabling for dekstop later
boolean embed_loader = !gplx.core.envs.Op_sys.Cur().Tid_is_drd(); // PERF: drd will embed in bundle.js
// get files_count
int len = tag_mgr.Len();
int files_total = 0;
for (int i = 0; i < len; ++i) {
Xopg_tag_itm itm = tag_mgr.Get_at(i);
if (loader_as_script) {
switch (itm.Tid()) {
case Xopg_tag_itm.Tid__js_file:
++files_total;
break;
}
}
}
// bgn loader_as_script
if (loader_as_script) {
if (write_loader_tag) bfr.Add(Gfh_tag_.Script_lhs_w_type).Add_byte_nl();
if (embed_loader && tag_mgr.Pos_is_head())
Wtr.Add_loader_func(bfr);
if (files_total > 0) Wtr.Add_files_bgn(bfr);
}
// write tags
len = tag_mgr.Len();
int files_idx = 0;
for (int i = 0; i < len; ++i) {
Xopg_tag_itm itm = tag_mgr.Get_at(i);
if (loader_as_script) {
switch (itm.Tid()) {
case Xopg_tag_itm.Tid__js_file:
Wtr.Add_files_itm(bfr, itm, files_idx++);
break;
}
continue;
}
else
cbk.Write_tag(bfr, itm);
}
// end loader_as_script
if (loader_as_script) {
if (files_total > 0) Wtr.Add_files_end(bfr, files_total);
if (write_loader_tag) bfr.Add(Gfh_tag_.Script_rhs).Add_byte_nl();
for (int i = 0; i < len; ++i) {
Xopg_tag_itm itm = tag_mgr.Get_at(i);
switch (itm.Tid()) {
case Xopg_tag_itm.Tid__js_file: continue;
}
cbk.Write_tag(bfr, itm);
}
}
return bfr.To_bry_and_clear();
}
static class Wtr { //#*nested
public static void Add_loader_func(Bry_bfr bfr) {
bfr.Add_str_a7_w_nl(" function load_files_sequentially(files, idx, done_cbk) {");
bfr.Add_str_a7_w_nl(" if (files[idx]) { // idx is valid");
bfr.Add_str_a7_w_nl(" var script = document.createElement('script');");
bfr.Add_str_a7_w_nl(" script.setAttribute('type','text/javascript');");
bfr.Add_str_a7_w_nl(" script.setAttribute('src', files[idx]);");
bfr.Add_str_a7_w_nl(" script.onload = function(){");
bfr.Add_str_a7_w_nl(" load_files_sequentially(files, ++idx, done_cbk); // load next file");
bfr.Add_str_a7_w_nl(" };");
bfr.Add_str_a7_w_nl(" document.getElementsByTagName('head')[0].appendChild(script)");
bfr.Add_str_a7_w_nl(" }");
bfr.Add_str_a7_w_nl(" else { // idx is not valid; finished;");
bfr.Add_str_a7_w_nl(" done_cbk();");
bfr.Add_str_a7_w_nl(" }");
bfr.Add_str_a7_w_nl(" }");
}
public static void Add_files_bgn(Bry_bfr bfr) {
bfr.Add_str_a7_w_nl(" var files =");
}
public static void Add_files_itm(Bry_bfr bfr, Xopg_tag_itm itm, int idx) {
bfr.Add_str_a7(idx == 0 ? " [ '" : " , '");
bfr.Add(itm.Href());
bfr.Add_byte_apos().Add_byte_nl();
}
public static void Add_files_end(Bry_bfr bfr, int files_count) {
bfr.Add_str_a7_w_nl(" ];");
bfr.Add_str_a7_w_nl(" load_files_sequentially(files, 0, function() {");
bfr.Add_str_a7_w_nl(" console.log('javascript files loaded: count=" + files_count + "');");
bfr.Add_str_a7_w_nl(" });");
}
}
}

View File

@@ -0,0 +1,39 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.wikis.pages.tags; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
public class Xopg_tag_wtr_{
public static void Add__xocss(Xopg_tag_mgr head_tags, Io_url http_root) {
Io_url css_dir = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "src", "xowa", "xocss", "core");
head_tags.Add(Xopg_tag_itm.New_css_file(css_dir.GenSubFil_nest("xocss_core-0.0.1.css")));
head_tags.Add(Xopg_tag_itm.New_css_file(css_dir.GenSubFil_nest("xoimg_core-0.0.1.css")));
}
public static void Add__xohelp(Xopg_tag_mgr head_tags, Io_url http_root) {
Io_url css_dir = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "src", "xowa", "xocss", "help");
head_tags.Add(Xopg_tag_itm.New_css_file(css_dir.GenSubFil_nest("xohelp-0.0.1.css")));
head_tags.Add(Xopg_tag_itm.New_js_file(css_dir.GenSubFil_nest("xohelp-0.0.1.js")));
}
public static void Add__mustache(Xopg_tag_mgr head_tags, Io_url http_root) {
head_tags.Add(Xopg_tag_itm.New_js_file(http_root.GenSubFil_nest("bin", "any", "xowa", "html", "res", "lib", "mustache", "mustache-2.2.1.js")));
}
public static void Add__jquery(Xopg_tag_mgr head_tags, Io_url http_root) {
head_tags.Add(Xopg_tag_itm.New_js_file(http_root.GenSubFil_nest("bin", "any", "xowa", "html", "res", "lib", "jquery", "jquery-1.11.3.js")));
}
public static void Add__notifyjs(Xopg_tag_mgr head_tags, Io_url http_root) {
head_tags.Add(Xopg_tag_itm.New_js_file(http_root.GenSubFil_nest("bin", "any", "xowa", "html", "res", "lib", "notifyjs", "notifyjs-0.3.1.js")));
}
}

View File

@@ -0,0 +1,24 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.wikis.pages.tags; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
public interface Xopg_tag_wtr_cbk {
void Write_tag(Bry_bfr bfr, Xopg_tag_itm itm);
}
class Xopg_tag_wtr_cbk__basic implements Xopg_tag_wtr_cbk {
public void Write_tag(Bry_bfr bfr, Xopg_tag_itm itm) {itm.To_html(bfr);}
}

View File

@@ -0,0 +1,21 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.wikis.pages.tags; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
public class Xopg_tag_wtr_cbk_ {
public static final Xopg_tag_wtr_cbk Basic = new Xopg_tag_wtr_cbk__basic();
}