Fix pager spaces
487578
def fill_pager(self, page):
        
        tty_size = os.popen("stty size", "r").read().split()
        rows = int(tty_size[0]) - 1
        lines = sum(1 for line in page.splitlines())
        diff = rows - lines
        fill = "\n" * diff
        if diff > 0:
            return fill
        else:
            return ""
1304157
private void doGetTLDs() throws PageException {
	lucee.runtime.type.Query qry = new QueryImpl(
		new String[] { "displayname", "namespace", "namespaceseparator", "shortname", "type", "description", "uri", "elclass", "elBundleName", "elBundleVersion",
			"source" },
		new String[] { "varchar", "varchar", "varchar", "varchar", "varchar", "varchar", "varchar", "varchar", "varchar", "varchar", "varchar" }, 0, "tlds");

	int dialect = "lucee".equalsIgnoreCase(getString("dialect", "cfml")) ? CFMLEngine.DIALECT_LUCEE : CFMLEngine.DIALECT_CFML;

	TagLib[] libs = config.getTLDs(dialect);
	for (int i = 0; i < libs.length; i++) {
	    qry.addRow();
	    qry.setAt("displayname", i + 1, libs[i].getDisplayName());
	    qry.setAt("namespace", i + 1, libs[i].getNameSpace());
	    qry.setAt("namespaceseparator", i + 1, libs[i].getNameSpaceSeparator());
	    qry.setAt("shortname", i + 1, libs[i].getShortName());
	    qry.setAt("type", i + 1, libs[i].getType());
	    qry.setAt("description", i + 1, libs[i].getDescription());
	    qry.setAt("uri", i + 1, Caster.toString(libs[i].getUri()));
	    qry.setAt("elclass", i + 1, libs[i].getELClassDefinition().getClassName());
	    qry.setAt("elBundleName", i + 1, libs[i].getELClassDefinition().getName());
	    qry.setAt("elBundleVersion", i + 1, libs[i].getELClassDefinition().getVersionAsString());
	    qry.setAt("source", i + 1, StringUtil.emptyIfNull(libs[i].getSource()));
	}
	pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
    }
820976
function AddSpaces (spaces) {

		async function MrkSpace(spaces) {
			let util = require('util'),
				rdfl = util.promisify(fs.readFile),
				fldr = Publics.Folder.index;
			// ------------------------------------------
			try { 
				if (!!!spaces) throw new Error('No Spaces');
				return await rdfl(fldr, 'utf8'); 
			} catch (err) {
				LG.Error(err, 'EXTERNAL', 'Markup');
				return null;
			}
		}

		function LogSpace (nme, dsc = '', kind = 'normal') {
			let msf = 'An Application for %s', nmf = '%15-s',
				name = nmf.format(nme), opts = [];
			switch (kind) {
				case 'global': opts = ['^^^^^', 'blue']; break;;
				case 'render': opts = ['Rendered', 'magenta']; break;;
				case 'normal': opts = [msf.format(dsc), 'gray']; break;;
			};
			LG.Server(name, 'NameSpace', ...opts);
		};

		function AddSpace (name, accessor) {
			accessor = !!accessor;
			/////////////////////////////////////////////////////////////////////////////
			let url   = `/${name}`,
				space = IO.of(url),
				globl = name.match(/^gbl-/),
				epnts = [],
				hndls = Socks.filter(v => {
							var key = TLS.Path([v[0], v[2]]),
								mch = !!key.match(/^\/auth\//),
								res = (mch == accessor);
							!!res && epnts.push(key); return res;
						})
						.map(v => { let a = v.slice();
							// Remove checks/limits for System API, if needed
							globl && (a[3] = [],a[4] = null);
							// Create Routers for Socket User
							return ReqSocket(...a);
						});

			/////////////////////////////////////////////////////////////////////////////
			space.on("connection", socket => {

				/////////////////////////////////////////////////////////////////////
				// VAR / FUNCTIONS //////////////////////////////////////////////////

					let Req, token, MID = '', SID = '', NID = '', RID, Checker = ReqHandle.Check(),
						LGMSG 	= 	(kind,err,msg)=>[kind,msg||(err||{}).message].filter(v=>!!v).join(' - '),
						LGERR	= 	(kind,err,clr='red')=>LG.Error(MID,'Session',LGMSG(kind,err),clr),
						LGSRV	= 	(kind,clr='yellow')=>LG.Server(MID,'Session',kind,clr),
						Init 	= 	() => {
							// Get Session Data
							Req = socket.request; token = '';
							SID = Req.sessionID; RID = socket.id;
							MID = SID+RID; NID = url+'#'+SID;
							// For General Messages
							LG.Server(SID,'Session','Detaching', 'magenta');
							// Setup the Ednpoints
							hndls.map(v => v(socket));
							// For Auth Messages
							/* !globl &&  */accessor && socket.join(SID);
						},
						Check 	= 	() => {
							if (!globl && accessor) {
								LGSRV('Checking', 'blue');
								let Res = new SocketRes(socket);
								Checker(Req,Res,(err,ret)=>{
									if (!!!(err||ret)) return;
									let { status, payload } = (err||ret);
									delete payload.options.body.reqid;
									Res.status(status).send(payload);
								});
							}
						},
						Sessers = 	(sync = 1, key, post = (()=>true)) => {
							socket.on(key, (!!!sync ?
								async (data = {}) => { try { 
									await ReqSession[key](Req, data); LGSRV(key); post(); }
									catch(err) { LGERR(key, err); } 
								} :   (data = {}) => { 
									try { ReqSession[key](Req, data); LGSRV(key); post(); }
									catch(err) { LGERR(key, err); } 
								}));
						};

				/////////////////////////////////////////////////////////////////////
				// HANDLERS /////////////////////////////////////////////////////////

					// Remove Stale Listeners
						socket.removeAllListeners('Save');
						socket.removeAllListeners('Renew');
						socket.removeAllListeners('Reload');
						socket.removeAllListeners('Regenerate');
						socket.removeAllListeners('Destroy');
						socket.removeAllListeners('reconnect_attempt');
						socket.removeAllListeners('error');
						socket.removeAllListeners('disconnect');

					// Determine Socket's Intention
						if (!globl) {
							if (accessor) {
								// For Session Renewing
								Sessers( true, 'Save');
								// For Session Renewing
								Sessers( true, 'Renew');
								// For Session Reloading
								Sessers( true, 'Reload');
								// For Session Regeneration
								Sessers(false, 'Regenerate', Init);
								// For Session Destroying
								Sessers( true, 'Destroy');
							} else {
								// For Broadcasting End-Points to Client
								let sobj = Pages[name], dobj = Pages['default'],
									head = socket.handshake.headers, 
									host = head.host, refr = head.referer,
									regx = `^https?:\/{2}${host}(\/.+)$`,
									path = refr.replace(new RegExp(regx),"$1"),
									LKID = ReqIOID(socket.request),
									LOKR = Session.Stores.Lockers;
								// -------------------------------------------------------
								if (!!!sobj) sobj = dobj;
								sobj.Data  = (sobj.Data ||dobj.Data );
								sobj.Build = (sobj.Build||dobj.Build);

								var send = res => socket.compress(true).emit(
										'build', (JSON.parse(res)||[{}])[0]
									);

								// -------------------------------------------------------
								function Builder() {
									LOKR.get(LKID,(err,res)=>send(res||"[{}]"));
								}
								// -------------------------------------------------------
								socket.on('setup', Builder);
							}
						} else {
							socket.emit('points', epnts);
						}

					// General Handles
						socket.on('reconnect_attempt', num => {
							LGERR('Reconnecting', {message:'%d Attempt%s'.format(num,(num>1?'s':''))});
						});
						socket.on('error', err => LGERR('Error', err));
						socket.on('disconnect', () => LGERR('Disconnected'));

				/////////////////////////////////////////////////////////////////////
				// SETUP ////////////////////////////////////////////////////////////

					// Log the Connection
					Init(); LGSRV('Connected');
					// Check if Authorized
					!globl && Check();

			}); return space;
		}

		function AddSite  (space, markup) {
			let refl =  'route.js | AddSpaces.AddSites |',
				cnfg = 	Assign({}, space.config),
				regx = 	{
					spce: 	/((?:<\w+\b|[\w=]+=(["']).+?\2(?=\s|)) )[\s\n]+/g,
					nwln:	/\n+\t*/g,
					scss: 	/^.+<!-{2}[{]{2}CSS[}]{2}-{2}>.+$/gm,
					vars: 	/<!-{2}[{]{2}([A-Z]+)[}]{2}-{2}>/g,
					objs: 	/\{\/\*!- CONFIG -\*\/\}/g,
					lckr: 	/\/\*!- LOCKER -\*\//g,
					styl: 	/\/\*!- STYLES -\*\//g,
					html: 	/<!-{2}CONTENT-{2}>/g,
					clsr:	/\/>/g,
					quot:	/&#x27;/g,
					plce: 	/-{2}[{]{2}([A-Z.]+)[}]{2}-{2}/g,
				},
				repl = 	(rnd, lid, cfg) => ({
					spce:	'$1',
					nwln:	'',
					scss:   ($0 => cfg.page.CSS.map(C =>
								$0.replace(/<!-{2}[{]{2}CSS[}]{2}-{2}>/g, C)
							).join('\n')),
					vars: 	($0, $key) => (cfg[$key.toLowerCase()]||''),
					objs: 	($0 => JSON.stringify(cfg||{})),
					lckr: 	($0 => lid),
					styl: 	($0 => cfg.page.styles?(rnd.Styles||''):''),
					html: 	($0 => rnd.HTML||''),
					clsr:	'>',
					quot:	"'",
					plce: 	(usr => ($0, $key) => { try { 
								let key = $key.toTitleCase(),
									val = `usr.Profile.${key}`;
								return eval(val); 
							} catch (e) { return ''; }; }),
				}),
				sani = 	(mark, data) => mark
							.replace(regx.spce,data.spce)
							.replace(regx.nwln,data.nwln)
							.replace(regx.scss,data.scss)
							.replace(regx.vars,data.vars)
							.replace(regx.objs,data.objs)
							.replace(regx.lckr,data.lckr)
							.replace(regx.styl,data.styl)
							.replace(regx.html,data.html)
							.replace(regx.clsr,data.clsr)
							.replace(regx.quot,data.quot),
				mkup =  markup,
				head = 	{
					'Content-Type':  'text/html',
					'Cache-Control': 'no-cache', // `public, max-age=${Publics.Age}`
				},
				LOKR =  Session.Stores.Lockers,
				ICO   = (head, url) => (
					head.referer == url && 
					!!head.accept.match(
						/image\/(?!webp|apng)/g
				)	);
			// -----------
			return function AddingSite(req, res) {
				let path  = req.originalUrl,
					host  = req.headers.host,
					ptcl  = req.protocol,
					hdrs  = req.headers,
					url   = `${ptcl}://${host}${path}`,
					EIF   = (cnfg.errorIF||(()=>false)),
					RDR   = (rnd, res, lid) => (
								rnd.Clear(lid),
								res.redirect(307, '404')
							),
					HTM   = async (usr,cfg,lid,rnd,res,ret=null) => {
								let cont, stat, rep, ctn, pay, eif = false;
								// -----------------------------------------------
									cfg.title = cfg.page.title(path,usr,pay);
									rnd.Auth(cfg.title);
								// -----------------------------------------------
									if (!!ret) pay = ret.payload.result;
								// -----------------------------------------------
									eif  = cfg.errorIF(ret); 
									if (eif) RDR(rnd, res, lid);
								// -----------------------------------------------
									try { 
										rnd.HTML = rnd.Render(pay); 
									} catch (e) { 
										console.log('RNDR ERR:', e); 
										RDR(rnd, res, lid);
									};
								// -----------------------------------------------
									rep  = repl(rnd, lid, cfg);
									ctn  = sani(mkup, rep);
								// -----------------------------------------------
									res.status(200).send(ctn);
								// -----------------------------------------------
									cont = JSON.stringify([rnd.Build(pay)]);
									stat = await LOKR.set(lid,cont,'EX',300);
									LG.NOW(`${refl} CALL CACHED: <%s>`, stat);
									rnd.Clear(lid);
							};
				// ------
				if (ICO(hdrs,url)) {
					// console.log({
						// headers:        req.headers,
						// method:         req.method,
						// params:         req.params,
						// url:            url,
						// statusCode:     req.statusCode,
						// statusMessage:  req.statusMessage,
						// upgrade:        req.upgrade,
					// });
					res.end();
				} else {
					// ------
					cnfg.host = `${ptcl}://${host}`;
					cnfg.errorIF = (...args) => {
						try { return EIF(...args); }
						catch (e) { return true; }
					};
					// ------
					LG.Timed(async () => {
						let rnd, call, ret,
							lid = ReqIOID(req),
							usr = req.profile, 
							cfg = Imm.fromJS(cnfg).toJS();
						// ------
						rnd = Renders(global,cfg,REST,usr,path,lid);
						res.header(head);
						// ------
						try {
							if (!!rnd.Call) {
								let { params, query, body, files } = req;
								// ------
								call = rnd.Call(path,params,query,body,files,usr);
								// ------
								ret  = await REST.Remote[call.method](
									call.path, 
									call.params,
									call.query||call.body, 
									call.files
								);
							};
							HTM(usr,cfg,lid,rnd,res,ret);
						} catch (err) { 
							let obj = { message: err.message, stack: err.stack },
								msg = JSON.stringify(obj, null, '    ');
							console.log(`${refl} CALL CACHE ERROR:`, msg, '\n');
							!!rnd.Redirect && res.redirect(301,rnd.Redirect);
						};
					},	req.sessionID, 'EXTERNAL', req.originalUrl, 'magenta');
				};
			};
		}

		// Configure External/Socket Routes
		// Initialize the Custom Namespaces, if available
		MrkSpace(spaces).then(mark => {
			let GBL = spaces.Global, EXPOSES = GBL.expose;
			// ----------------------------------------------------------------
			Imm	.OrderedMap(spaces)
				.filter((v,k)=>k!='Global'&&v.config.name!='global')
				.map((v,k) => {
					let c = v.config,
						nme = c.name,
						dsc = c.description,
						acc = c.accessor,
						stc = c.restrict,
						sch = c.scheme,
						url = `/${nme}`,
						gbl = EXPOSES.has(nme);
					// Create Socket Space
					Spaces[k] = AddSpace(nme, acc); LogSpace(nme, dsc);
					// Handle Globals, Accessors, Sites
					switch (true) {
						// Setup any Global Namespaces
						case gbl: 	let gme = `gbl-${nme}`; 
									Spaces[k] = AddSpace(gme, acc);
									LogSpace(gme, '', 'global');;
						// This sets any Accessors
						case acc: 	Session.Accessor = Spaces[k]; break;;
						// This handles the NameSpace Sites
						default: 	let rou = Express.Router(), ste, 
										chk = ReqHandle.Check(stc);
									Sites[k] = ste = AddSite(v, mark);
									rou .get('/', chk, ste); 
									rou.post('/', chk, ste);
									API.use(!!sch?sch:url, rou); 
									LogSpace(nme, '', 'render');
					}
			});
		}).catch(err => {
			// Otherwise, add placeholder NameSpace
			Spaces.Index = AddSpace('/');
		});
	}
618189
def fixtags(self, text):
		""""""
		# french spaces, last one Guillemet-left
		# only if there is something before the space
		text = _guillemetLeftPat.sub(ur'\1&nbsp;\2', text)
		# french spaces, Guillemet-right
		text = _guillemetRightPat.sub(ur'\1&nbsp;', text)
		return text
936982
function (e) {
        var p       = this.paginator,
            sel     = this.select,
            options = p.get('rowsPerPageOptions'),
            opt,cfg,val,i,len;

        this.all = null;

        for (i = 0, len = options.length; i < len; ++i) {
            cfg = options[i];
            opt = sel.options[i] ||
                  sel.appendChild(document.createElement('option'));
            val = l.isValue(cfg.value) ? cfg.value : cfg;
            opt.innerHTML = l.isValue(cfg.text) ? cfg.text : cfg;

            if (l.isString(val) && val.toLowerCase() === 'all') {
                this.all  = opt;
                opt.value = p.get('totalRecords');
            } else{
                opt.value = val;
            }

        }

        while (sel.options.length > options.length) {
            sel.removeChild(sel.firstChild);
        }

        this.update();
    }
632231
def delete_horizontal_space(event):
    "  "
    buff = event.current_buffer
    text_before_cursor = buff.document.text_before_cursor
    text_after_cursor = buff.document.text_after_cursor

    delete_before = len(text_before_cursor) - len(text_before_cursor.rstrip('\t '))
    delete_after = len(text_after_cursor) - len(text_after_cursor.lstrip('\t '))

    buff.delete_before_cursor(count=delete_before)
    buff.delete(count=delete_after)
967068
function syncPagesbar() {
            if ($pages[0] && last.page !== rel.activePage) {
                last.page = rel.activePage;
                $pages.removeClass(o.activeClass).eq(rel.activePage).addClass(o.activeClass);
            }
        }
970159
void setPageSizeAsString(String pageSize) {

        if (CmsStringUtil.isEmpty(pageSize)) {
            return;
        }

        try {
            m_pageSize = Integer.parseInt(pageSize);
        } catch (NumberFormatException e) {
            // intentionally left blank
        }
    }
1296650
def match_pagination(ref_line):
    """"""
    pattern = ur'\(?\[?(\d{1,4})\]?\)?\.?\s*$'
    re_footer = re.compile(pattern, re.UNICODE)
    match = re_footer.match(ref_line)
    if match:
        return int(match.group(1))
    return None
770228
function(paginator) {
    var template = '';
    template += '.pages\n';
    template += '  - if (paginator.previousPage)\n';
    template += '    span.prev_next\n';
    template += '      - if (paginator.previousPage === 1)\n';
    template += '        span &larr;\n';
    template += '        a.previous(href="/") Previous\n';
    template += '      - else\n';
    template += '        span &larr;\n';
    template += '        a.previous(href="/page" + paginator.previousPage + "/") Previous\n';
    template += '  - if (paginator.pages > 1)\n';
    template += '    span.prev_next\n';
    template += '      - for (var i = 1; i <= paginator.pages; i++)\n';
    template += '        - if (i === paginator.page)\n';
    template += '          strong.page #{i}\n';
    template += '        - else if (i !== 1)\n';
    template += '          a.page(href="/page" + i + "/") #{i}\n';
    template += '        - else\n';
    template += '          a.page(href="/") 1\n';
    template += '      - if (paginator.nextPage <= paginator.pages)\n';
    template += '        a.next(href="/page" + paginator.nextPage + "/") Next\n';
    template += '        span &rarr;\n';
    return helpers.render(template, { locals: { paginator: paginator } });
  }
527585
def clean_pages_from_space(confluence, space_key, limit=500):
    
    flag = True
    while flag:
        values = confluence.get_all_pages_from_space_trash(space=space_key, start=0, limit=limit)
        if len(values) == 0:
            flag = False
            print("For space {} trash is empty".format(space_key))
        else:
            print("Found in space {} pages as trashed {}".format(space_key, len(values)))
            for value in values:
                print("Removing page with title: " + value['title'])
                confluence.remove_page_from_trash(value['id'])
1277498
protected void addSpacing(float extraspace, float oldleading, Font f) {
    	if (extraspace == 0) return;
    	if (pageEmpty) return;
    	if (currentHeight + line.height() + leading > indentTop() - indentBottom()) return;
        leading = extraspace;
        carriageReturn();
        if (f.isUnderlined() || f.isStrikethru()) {
            f = new Font(f);
            int style = f.getStyle();
            style &= ~Font.UNDERLINE;
            style &= ~Font.STRIKETHRU;
            f.setStyle(style);
        }
        Chunk space = new Chunk(" ", f);
        space.process(this);
        carriageReturn();
        leading = oldleading;
    }
1024558
def _parse_pages(self, unicode=False):
    """"""
    if self.pageRange:
        pages = 'pp. {}'.format(self.pageRange)
    elif self.startingPage:
        pages = 'pp. {}-{}'.format(self.startingPage, self.endingPage)
    else:
        pages = '(no pages found)'
    if unicode:
        pages = u'{}'.format(pages)
    return pages
746361
function insertSpaces(line, pos, count)
        {
            return line.substr(0, pos)
                + spaces.substr(0, count)
                + line.substr(pos + 1, line.length) // pos + 1 will get rid of the tab
                ;
        }
1131158
function pad(str, width) {
  var len = Math.max(0, width - str.length);
  return str + Array(len + 1).join(' ');
}
73142
def expand_pagination(pages):
    """"""
    # If there is no hyphen, it's a single page, and we're good to go
    parts = pages.split('-')
    if len(parts) == 1: # No hyphen, so no split
        return pages
    elif len(parts) == 2:
        start = parts[0]
        end = parts[1]
        # If the end is the same number of digits as the start, then we
        # don't change anything!
        if len(start) == len(end):
            return pages
        # Otherwise, replace the last digits of start with the digits of end
        num_end_digits = len(end)
        new_end = start[:-num_end_digits] + end
        return '%s-%s' % (start, new_end)
    else: # More than one hyphen, something weird happened
        logger.warning("Multiple hyphens in page number: %s" % pages)
        return pages
679496
function getPageDimensions() {
      var bttmRight = document.createElement("div");
      bttmRight.setAttribute("style" , "visibility:hidden;position:fixed;bottom:0px;right:0px;");
      document.getElementsByTagName("body")[0].appendChild(bttmRight);
      var pageWidth = bttmRight.offsetLeft;
      var pageHeight = bttmRight.offsetTop;
      bttmRight.parentNode.removeChild(bttmRight);
      return { width:pageWidth, height:pageHeight };
    }