TODO: Use below for page_part_content_spec
322656
def get_seed_content(locale)
      locale_seed_file = Pwb::Engine.root.join('db', 'yml_seeds', 'content_translations', locale.to_s + '.yml')
      raise Exception, "Contents seed for #{locale} not found" unless File.exist? locale_seed_file
      yml = YAML.load_file(locale_seed_file)

      if yml[locale] && yml[locale][container_label] && yml[locale][container_label][page_part_key]
        seed_content = yml[locale][container_label][page_part_key]
        page_part_manager.seed_container_block_content locale, seed_content
        p "#{container_label} #{page_part_key} content set for #{locale}."
      end
    end
995303
private String transformContent(String content) {

        try {
            List<CmsJsonPart> parts = CmsJsonPart.parseJsonParts(content);
            JSONArray keys = new JSONArray();
            JSONObject output = new JSONObject();
            for (CmsJsonPart part : parts) {
                if (output.has(part.getKey())) {
                    LOG.warn("Duplicate key for JSON parts: " + part.getKey());
                }
                keys.put(part.getKey());
                output.put(part.getKey(), part.getValue());
            }
            output.put(KEY_PARTS, keys);
            return output.toString();
        } catch (Exception e) {
            LOG.error(e.getLocalizedMessage(), e);
            return content;

        }
    }
33023
function prepareDOM() {
        var i, pageNum,
            zoomLevel, maxZoom,
            ptWidth, ptHeight,
            pxWidth, pxHeight,
            pt2px = util.calculatePtSize(),
            dimensions = config.metadata.dimensions,
            skeleton = '';

        // adjust page scale if the pages are too small/big
        // it's adjusted so 100% == DOCUMENT_100_PERCENT_WIDTH px;
        config.pageScale = DOCUMENT_100_PERCENT_WIDTH / (dimensions.width * pt2px);

        // add zoom levels to accomodate the scale
        zoomLevel = config.zoomLevels[config.zoomLevels.length - 1];
        maxZoom = 3 / config.pageScale;
        while (zoomLevel < maxZoom) {
            zoomLevel += zoomLevel / 2;
            config.zoomLevels.push(zoomLevel);
        }

        dimensions.exceptions = dimensions.exceptions || {};

        // create skeleton
        for (i = config.pageStart - 1; i < config.pageEnd; i++) {
            pageNum = i + 1;
            if (pageNum in dimensions.exceptions) {
                ptWidth = dimensions.exceptions[pageNum].width;
                ptHeight = dimensions.exceptions[pageNum].height;
            } else {
                ptWidth = dimensions.width;
                ptHeight = dimensions.height;
            }
            pxWidth = ptWidth * pt2px;
            pxHeight = ptHeight * pt2px;
            pxWidth *= config.pageScale;
            pxHeight *= config.pageScale;
            skeleton += util.template(Crocodoc.pageTemplate, {
                w: pxWidth,
                h: pxHeight
            });
        }

        // insert skeleton and keep a reference to the jq object
        config.$pages = $(skeleton).appendTo(config.$doc);
    }
167891
function canPageForward () {
    var elements = getElements();
    var lastTab = elements.tabs[ elements.tabs.length - 1 ];

    if (isRtl()) {
      return ctrl.offsetLeft < elements.paging.offsetWidth - elements.canvas.offsetWidth;
    }

    return lastTab && lastTab.offsetLeft + lastTab.offsetWidth > elements.canvas.clientWidth +
        ctrl.offsetLeft;
  }
450955
function(page) {
			var regixAll = /([^\S]```.*)(:(.+))[\s\S]+?```/g;
			var regix = /([^\S]```.*)(:(.+))[\s\S]+?```/;
			var matchAll = page.content.match(regixAll);

			for(var i = 0; matchAll && i < matchAll.length; i++){
				var match = matchAll[i].match(regix);
				var input = match.input.replace(match[2], "");
				var replace = input.replace(match[1], "\n\n!FILENAME " + match[3] + match[1]);
				page.content = page.content.replace(match.input, replace);
			}

			return page;
		}
431547
function PageRenderer(req, res) {
    var page = req.attrs.page;
    Object.defineProperties(this, {
        req: {
            value: req
        },
        res: {
            value: res
        },
        page: {
            value: _.clone(page)
        },
        themeDBAction: {
            value: DBActions.getInstance(req, THEME_SCHEMA)
        },
        layoutDBAction: {
            value: DBActions.getInstance(req, LAYOUT_SCHEMA)
        },
        pageInstanceDBAction: {
            value: DBActions.getAuthInstance(req, PAGE_SCHEMA, PAGE_PERMISSION_SCHEMA)
        },
        pluginInstanceDBAction: {
            value: DBActions.getInstance(req, PLUGIN_INSTANCE_SCHEMA)
        },
        pagePermissionValidator: {
            value: new PermissionValidator(req, PAGE_PERMISSION_SCHEMA, PAGE_SCHEMA)
        },
        pluginPermissionValidator: {
            value: new PermissionValidator(req, PLUGIN_PERMISSION_SCHEMA, PLUGIN_INSTANCE_SCHEMA)
        },
        isExclusive: {
            value: req.query && req.query.mode === "exclusive"
        }
    });
}
1259994
public Specification getSpecification(Page page) throws GreenPepperServerException {
        return getSpecification(page.getSpaceKey(), page.getTitle());
    }
423380
public String getPageContent(Page page) {
        try {
            return getPageContent(page, false);
        } catch (GreenPepperServerException e) {
            return e.getMessage();
        }
    }
579030
function join() {
    var pagelet = this
      , result = this._queue.map(function flatten(fragment) {
          if (!fragment.name || !fragment.view) return '';
          return fragment.view;
        });

    try {
      result = this._contentType === contentTypes.json
        ? JSON.stringify(result.shift())
        : result.join('');
    } catch (error) {
      this.emit('done', error);
      return this.debug('Captured error while stringifying JSON data %s', error);
    }

    this._queue.length = 0;
    return result;
  }
1261005
@Override
    public void visit(Page page, CrawlDatums next) {

        if(page.matchType("taglist")){
            //如果是列表页，抽取内容页链接
            //将内容页链接的type设置为content，并添加到后续任务中
             next.add(page.links("table.tagCol td>a"),"booklist");
        }else if(page.matchType("booklist")){
            next.add(page.links("div.info>h2>a"),"content");
        }else if(page.matchType("content")){
            //处理内容页，抽取书名和豆瓣评分
            String title=page.select("h1>span").first().text();
            String score=page.select("strong.ll.rating_num").first().text();
            System.out.println("title:"+title+"\tscore:"+score);
        }
 
    }
65463
function(apiKey, templateId, pieceTitle,
        category, fromAddress, toAddress, ccAddress, bccAddresses, subject,
        textBody, htmlBody, contentType, mergeContext) {}
571453
function (value, strategy, e) {
      var pre = this.getTextFromHeadToCaret();
      // use ownerDocument instead of window to support iframes
      var sel = this.el.ownerDocument.getSelection();
      
      var range = sel.getRangeAt(0);
      var selection = range.cloneRange();
      selection.selectNodeContents(range.startContainer);
      var content = selection.toString();
      var post = content.substring(range.startOffset);
      var newSubstr = strategy.replace(value, e);
      var regExp;
      if (typeof newSubstr !== 'undefined') {
        if ($.isArray(newSubstr)) {
          post = newSubstr[1] + post;
          newSubstr = newSubstr[0];
        }
        regExp = $.isFunction(strategy.match) ? strategy.match(pre) : strategy.match;
        pre = pre.replace(regExp, newSubstr)
            .replace(/ $/, "&nbsp"); // &nbsp necessary at least for CKeditor to not eat spaces
        range.selectNodeContents(range.startContainer);
        range.deleteContents();
        
        // create temporary elements
        var preWrapper = this.el.ownerDocument.createElement("div");
        preWrapper.innerHTML = pre;
        var postWrapper = this.el.ownerDocument.createElement("div");
        postWrapper.innerHTML = post;
        
        // create the fragment thats inserted
        var fragment = this.el.ownerDocument.createDocumentFragment();
        var childNode;
        var lastOfPre;
        while (childNode = preWrapper.firstChild) {
        	lastOfPre = fragment.appendChild(childNode);
        }
        while (childNode = postWrapper.firstChild) {
        	fragment.appendChild(childNode);
        }
        
        // insert the fragment & jump behind the last node in "pre"
        range.insertNode(fragment);
        range.setStartAfter(lastOfPre);
        
        range.collapse(true);
        sel.removeAllRanges();
        sel.addRange(range);
      }
    }
878245
function(tag, start_line, start_column) {
  return { t: tag,
           open: true,
           last_line_blank: false,
           start_line: start_line,
           start_column: start_column,
           end_line: start_line,
           children: [],
           parent: null,
           // string_content is formed by concatenating strings, in finalize:
           string_content: "",
           strings: [],
           inline_content: []
        };
}
750493
function getPageMeta() {
        var data = detectFeatures();

        data.title = document.title;
        data.url = window.location.href;
        data.path = document.location.pathname;
        data.referrer = document.referrer;
        data.url_section = window.location.pathname.split('/').filter(function(part){
            return part.length !== 0;
        }).map(function(part){
            return part.replace(/\.[^/.]+$/, "");
        });
        data.hash = window.location.hash;
        data.query_string = window.location.search;

        return data;
    }
829128
def content_for route
      parts = route.split("/").delete_if &:empty?
      content = parts.inject(self) do |page, part|
        page.children[part.to_sym] if page
      end
      content
    end
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);
    }
432591
def get_page_tpl_ctx(page, request):
    
    text = Template(page.text).render(Context())
    meta = MetaSeo(page)
    comments = get_object_comments(PageComment, page.id)
    comments_form = PageCommentForm(initial=get_comment_init(request, page))
    if page.slug == Page.MAIN_SLUG:
        crumbs = None
    else:
        crumbs = page.get_breadcrumbs()
    return {'page': page, 'comments': comments, 'comments_form': comments_form, 'text': text, 'meta': meta, 'crumbs': crumbs}