checklinks.js

来自「Hippo CMS是一个以信息为中心的开源内容管理系统。Hippo CMS目标是」· JavaScript 代码 · 共 50 行

JS
50
字号
/*
 * Copyright 2006 Hippo.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* $Id: checkLinks.js 9282 2007-12-13 13:54:13Z nvankampenhout $ */

importClass(Packages.nl.hippo.util.LinkChecker);

// Name of the placeholder file. Customize this as needed.
var placeHolderFileName = "brokenLinks.xml";

// Name of the broken links report file. Customize this as needed.
var reportFileName = "brokenLinks.xml";

// URL to redirect to after link checker thread has been spawned. Customize this as needed.
var redirectUrl = "links.txt";

function checkLinks() {
	var repository = cocoon.parameters.repository;
	var username = cocoon.parameters.username;
	var password = cocoon.parameters.password;
	var authenticated = do_login(username, password, cocoon.request.project, cocoon.request.locale);
	if (authenticated){
      var os = new java.io.ByteArrayOutputStream();
      cocoon.processPipelineTo("links.txt", {}, os);
      var r = {
      	data: os.toByteArray(), 
      	run: function() {
  		    var brokenLinks = LinkChecker.checkLinks(repository + "/" + placeHolderFileName, username, password, this.data);
  			LinkChecker.putResults(repository + "/" + reportFileName, username, password, brokenLinks);
  		}
  	};
  	var runnable = java.lang.Runnable(r);
  	var t = new java.lang.Thread(runnable);
  	t.start();
    }
	cocoon.redirectTo(redirectUrl);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?