mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Embeddable: Create core dbs in proper subdirectory
This commit is contained in:
@@ -13,3 +13,20 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.htmls.skins; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
public class Xoh_skin_itm implements Gfo_invk {
|
||||
private final Bry_fmtr fmtr = Bry_fmtr.new_();
|
||||
public Xoh_skin_itm(String key, String fmt) {this.key = key; fmtr.Fmt_(fmt);}
|
||||
public String Key() {return key;} private final String key;
|
||||
public void Fmt_(String v) {fmtr.Fmt_(v);}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_fmt)) return String_.new_u8(fmtr.Fmt());
|
||||
else if (ctx.Match(k, Invk_fmt_)) fmtr.Fmt_(m.ReadStr("v"));
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String
|
||||
Invk_fmt = "fmt", Invk_fmt_ = "fmt_"
|
||||
;
|
||||
}
|
||||
|
||||
@@ -13,3 +13,37 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.htmls.skins; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
public class Xoh_skin_mgr implements Gfo_invk {
|
||||
private final Xoh_skin_regy regy = new Xoh_skin_regy();
|
||||
public Xoh_skin_mgr() {
|
||||
read = make_and_add(regy, "read");
|
||||
edit = make_and_add(regy, "edit");
|
||||
html = make_and_add(regy, "html");
|
||||
}
|
||||
public Xoh_skin_itm Read() {return read;} private Xoh_skin_itm read;
|
||||
public Xoh_skin_itm Edit() {return edit;} private Xoh_skin_itm edit;
|
||||
public Xoh_skin_itm Html() {return html;} private Xoh_skin_itm html;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_read)) return read;
|
||||
else if (ctx.Match(k, Invk_read_)) read = regy.Get_by_key(m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Invk_edit)) return edit;
|
||||
else if (ctx.Match(k, Invk_edit_)) edit = regy.Get_by_key(m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Invk_html)) return html;
|
||||
else if (ctx.Match(k, Invk_html_)) html = regy.Get_by_key(m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Invk_set)) regy.Set(m.ReadStr("key"), m.ReadStr("fmt"));
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String
|
||||
Invk_read = "read", Invk_read_ = "read_"
|
||||
, Invk_edit = "edit", Invk_edit_ = "edit_"
|
||||
, Invk_html = "html", Invk_html_ = "html_"
|
||||
, Invk_set = "set"
|
||||
;
|
||||
private static Xoh_skin_itm make_and_add(Xoh_skin_regy regy, String key) {
|
||||
Xoh_skin_itm rv = new Xoh_skin_itm(key, key);
|
||||
regy.Add(rv);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,3 +13,20 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.htmls.skins; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
class Xoh_skin_regy {
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
public int Len() {return hash.Count();}
|
||||
public Xoh_skin_itm Get_at(int i) {return (Xoh_skin_itm)hash.Get_at(i);}
|
||||
public Xoh_skin_itm Get_by_key(String key) {return (Xoh_skin_itm)hash.Get_by(key);}
|
||||
public void Set(String key, String fmt) {
|
||||
Xoh_skin_itm itm = Get_by_key(key);
|
||||
if (itm == null) {
|
||||
itm = new Xoh_skin_itm(key, fmt);
|
||||
Add(itm);
|
||||
}
|
||||
else
|
||||
itm.Fmt_(fmt);
|
||||
}
|
||||
public void Add(Xoh_skin_itm itm) {hash.Add(itm.Key(), itm);}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user