package ru.olimpiks
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
import javax.naming.directory.BasicAttribute;
import javax.naming.directory.DirContext;
import javax.naming.directory.ModificationItem;
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
import javax.naming.ldap.InitialLdapContext;
public class Ldap {
public static void main(String[] args) {
String usernameDN = "CN=vasya,DC=acme,DC=com";
String password = "secret";
String url = "ldap://acme.com:389";
// connection properties
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, usernameDN);
env.put(Context.SECURITY_CREDENTIALS, password);
env.put(Context.PROVIDER_URL, url);
// search params
String groupDN = "CN=jabber,OU=Groups,DC=acme,DC=com";
String usersSearchFilter = "(objectclass=user)";
String usersSearchBaseDN = "DC=acme,DC=com";
String dnKey = "distinguishedName";
String returnedAtts[] = { dnKey, "cn", "givenName", "mail" };
DirContext lc = null;
try {
// get context
lc = new InitialLdapContext(env, null);
// search users
SearchControls search = new SearchControls();
search.setReturningAttributes(returnedAtts);
search.setSearchScope(SearchControls.SUBTREE_SCOPE);
NamingEnumeration res = lc.search(usersSearchBaseDN,
usersSearchFilter, search);
while (res.hasMoreElements()) {
SearchResult sr = (SearchResult) res.next();
System.out.println(sr.getName());
Attributes attrs = sr.getAttributes();
// if (attrs != null) {
// for (String a : returnedAtts) {
// System.out.println(attrs.get(a));
// }
// }
// add the user to a group
ModificationItem item = new ModificationItem(
DirContext.ADD_ATTRIBUTE, new BasicAttribute("member",
attrs.get(dnKey).get()));
ModificationItem[] items = new ModificationItem[] { item };
lc.modifyAttributes(groupDN, items);
}
} catch (NamingException e) {
e.printStackTrace();
} finally {
if (lc != null) {
try {
lc.close();
} catch (NamingException e) {
e.printStackTrace();
}
}
}
}
}
20 апреля, 2011
find users in the ldap and add them to a group using java
02 марта, 2011
redmine mysql/postgresql converter
Start point: redmine + mysql
End point: redmine + postgresql_9.0
1.create mysql dump
mysqldump -u root -p --compatible=postgresql --skip-add-drop-table --skip-add-locks --skip-create-options --skip-extended-insert --default-character-set=utf8 -n -t -r redmine_mysql.sql redmine
2.escape strings for postgres (,' -> ,E')
sed "s/,'/,E'/g" redmine_mysql.sql >> redmine_postgres.sql
3.create empty postgresql db
rake db:migrate RAILS_ENV=production
4.truncate tables
DO language plpgsql $$
DECLARE
vr record;
i integer;
BEGIN
for vr in (select table_name from information_schema.tables where table_schema='public' and table_type='BASE TABLE')
loop
execute 'TRUNCATE TABLE ' || vr.table_name;
end loop;
END
$$;
5.convert boolean column into character varying(111)
DO language plpgsql $$
DECLARE
vr record;
BEGIN
for vr in (select table_name, column_name from information_schema.columns where table_schema='public' and data_type = 'boolean')
loop
execute 'ALTER TABLE ' || vr.table_name || ' ALTER ' || vr.column_name || ' TYPE character varying(111)';
end loop;
END
$$;
6.import dump
psql -q -U postgres -h localhost -d redmine -f redmine_postgres.sql
7.convert character varying(111) into boolean
DO language plpgsql $$
DECLARE
vr record;
BEGIN
for vr in (select table_name, column_name from information_schema.columns where table_schema='public' and data_type = 'character varying' and character_maximum_length=111)
loop
execute 'ALTER TABLE ' || vr.table_name || ' ALTER ' || vr.column_name || ' TYPE bool using ' || vr.column_name || '::bool';
end loop;
END
$$;
8.actualize sequences
DO language plpgsql $$
DECLARE
vr record;
i integer;
BEGIN
for vr in (select sequence_name, substr(sequence_name,1,length(sequence_name)-7) table_name from information_schema.sequences)
loop
execute 'select coalesce(max(id),1)+1 from ' || vr.table_name into i;
execute 'ALTER SEQUENCE ' || vr.sequence_name || ' RESTART with ' || i;
end loop;
END
$$;
tags:
converter,
mysql,
postgresql,
redmine
08 марта, 2010
richfaces modal panel for ajax request
layout.xhtml
spiner.xhtml
it may fix following for Jboss Seam:
HTTP Status 503 – Concurrent call to conversation !!!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<f:view locale="#{localeSelector.localeString}" contentType="text/html"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a="http://richfaces.org/a4j"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:rich="http://richfaces.org/rich" >
<html>
<head>
<!--...-->
</head>
<body>
<ui:include src="spiner.xhtml" />
<!--...-->
</body>
</html>
</f:view>
spiner.xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:a="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<rich:modalPanel id="spiner" resizeable="false" autosized="false"
moveable="false" width="200" height="65" shadowOpacity="0">
<f:facet name="header">One moment please..</f:facet>
<h:outputText value="Your request is being processed." />
<h:graphicImage value="/img/spinner.gif"
style="vertical-align: middle;" />
</rich:modalPanel>
<a:status onstart="Richfaces.showModalPanel('spiner')"
onstop="Richfaces.hideModalPanel('spiner')" />
</ui:composition>
it may fix following for Jboss Seam:
HTTP Status 503 – Concurrent call to conversation !!!
java zip utils
public static void main(String... strings) throws Exception {
File[] sourceFiles = { new File("D:\\download\\dbf\\BMP\\KEY.BMP"),//
new File("D:\\download\\favicon.ico"), //
new File("D:\\download\\SDelete.zip"), //
new File("D:\\download\\iepngfix\\") //
};
File rootDir = new File("D:\\download\\");
File zipFile = new File(rootDir, "download.zip");
ZipUtils.zip(rootDir, sourceFiles, zipFile, Deflater.DEFAULT_COMPRESSION);
for (String s : ZipUtils.unzip(zipFile)) {
System.out.println(s);
}
}
output
dbf/BMP/KEY.BMP
favicon.ico
SDelete.zip
iepngfix/.htaccess
iepngfix/blank.gif
iepngfix/checkerboard.gif
iepngfix/helix.gif
iepngfix/iepngfix.htc
iepngfix/iepngfix.html
iepngfix/iepngfix.php
iepngfix/iepngfix_tilebg.js
iepngfix/opacity.png
iepngfix/opacity2.png
iepngfix/shadow.png
ru.olimpiks.common.utils.ZipUtils.java
package ru.olimpiks.common.utils;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.Closeable;
import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.Deflater;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
public class ZipUtils {
private static final int BATCH_SIZE = 4096;
private static long copyLarge(InputStream input, OutputStream output)
throws IOException {
byte buffer[] = new byte[BATCH_SIZE];
long count = 0L;
for (int n = 0; -1 != (n = input.read(buffer));) {
output.write(buffer, 0, n);
count += n;
}
return count;
}
private static final void closeQuietly(Closeable zos) {
try {
if (zos != null) {
zos.close();
}
} catch (Exception e) {
}
}
private static String normalizeEntryName(String entryName) {
return entryName.replace(File.separatorChar, '/');
}
private static String getEntryName(File rootDir, File zippedFile) {
if (rootDir != null && zippedFile.getPath().startsWith(rootDir.getPath())) {
return zippedFile.getPath().substring(rootDir.getPath().length() + 1);
} else {
return zippedFile.getPath();
}
}
private static void zipFile(File zippedFile, String entryName,
ZipOutputStream zos) throws FileNotFoundException, IOException {
FileInputStream fis = new FileInputStream(zippedFile);
ZipEntry anEntry = new ZipEntry(normalizeEntryName(entryName));
zos.putNextEntry(anEntry);
copyLarge(fis, zos);
fis.close();
zos.flush();
}
private static void zipDir(File zippedDir, String entryName,
ZipOutputStream zos) throws FileNotFoundException, IOException {
File[] dirList = zippedDir.listFiles();
for (File f : dirList) {
if (f.isDirectory()) {
zipDir(f, entryName + "/" + f.getName(), zos);
continue;
}
zipFile(f, entryName + "/" + f.getName(), zos);
}
}
public static final void zipFile(File rootDir, File zippedFile, File zipFile,
int level) throws FileNotFoundException, IOException {
ZipOutputStream zos = null;
try {
zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(
zipFile)));
zos.setLevel(level);
zipFile(zippedFile, getEntryName(rootDir, zippedFile), zos);
} finally {
closeQuietly(zos);
}
}
public static final void zipDir(File rootDir, File zippedDir, File zipFile,
int level) throws FileNotFoundException, IOException {
ZipOutputStream zos = null;
try {
zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(
zipFile)));
zos.setLevel(level);
zipDir(zippedDir, getEntryName(rootDir, zippedDir), zos);
} finally {
closeQuietly(zos);
}
}
public static final void zip(File rootDir, File[] zipped, File zipFile,
int level) throws FileNotFoundException, IOException {
ZipOutputStream zos = null;
try {
zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(
zipFile)));
zos.setLevel(level);
for (File f : zipped) {
if (f.isDirectory()) {
zipDir(f, getEntryName(rootDir, f), zos);
} else {
zipFile(f, getEntryName(rootDir, f), zos);
}
}
} finally {
closeQuietly(zos);
}
}
public static final void unzip(File zipFile, File outDir)
throws FileNotFoundException, IOException {
ZipInputStream in = null;
try {
in = new ZipInputStream(new BufferedInputStream(new FileInputStream(
zipFile)));
ZipEntry entry;
while ((entry = in.getNextEntry()) != null) {
File file = new File(outDir, entry.getName());
System.out.println(file);
if (!file.exists()) {
if (!file.getParentFile().exists() && !file.getParentFile().mkdirs()) {
throw new IOException("Could not create directory : "
+ file.getParentFile());
}
if (!file.createNewFile()) {
throw new IOException("Could not create file : "
+ file.getParentFile());
}
}
BufferedOutputStream out = new BufferedOutputStream(
new FileOutputStream(file));
copyLarge(in, out);
out.flush();
out.close();
}
} finally {
closeQuietly(in);
}
}
public static final String[] unzip(File zipFile)
throws FileNotFoundException, IOException {
List<String> list = new ArrayList<String>(0);
ZipInputStream in = null;
try {
in = new ZipInputStream(new BufferedInputStream(new FileInputStream(
zipFile)));
ZipEntry entry;
while ((entry = in.getNextEntry()) != null) {
list.add(entry.getName());
}
return list.toArray(new String[0]);
} finally {
closeQuietly(in);
}
}
}
05 января, 2010
tomcat datasource native connection
Sometimes need use native db connection.
For example, to correct the following exception:
java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.PoolingDataSource cannot be cast to oracle.jdbc.OracleConnection
For example context.xml below:
For example, to correct the following exception:
java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.PoolingDataSource cannot be cast to oracle.jdbc.OracleConnection
private String datasource = "java:comp/env/jdbc/mydb";
private DataSource getDataSource() {
InitialContext ctx;
try {
ctx = new InitialContext();
BasicDataSource ds = (BasicDataSource) ctx.lookup(datasource);
ds.setAccessToUnderlyingConnectionAllowed(true);
return ds;
} catch (NamingException e) {
throw new RuntimeException(e);
}
}
private Connection getNativeConnection(Connection connection) {
return ((DelegatingConnection) connection).getInnermostDelegate();
}
public void doIt() {
Connection connection = null;
try {
connection = getDataSource().getConnection();
Connection nativeConnection = getNativeConnection(connection);
doSomethingWithNativeConnection(nativeConnection);
} catch (SQLException e) {
throw new RuntimeException(e);
} finally {
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
private void doSomethingWithNativeConnection(Connection connection) {
System.out.println(connection.getClass());
/*- for oracle will be print:
class oracle.jdbc.driver.T4CConnection
*/
// ...
}
For example context.xml below:
<Resource name="jdbc/mydb" auth="Container" type="javax.sql.DataSource"
maxActive="10" maxIdle="10" maxWait="10000" username="user" password="password"
driverClassName="oracle.jdbc.OracleDriver" url="jdbc:oracle:thin:@localhost:1521:orasid"
validationQuery="select 1 from dual" />
tags:
connection,
datasource,
native,
tomcat
hibernate sequence generator
ru.olimpiks.MySequenceGenerator.java
hbm.xml
ru.olimpiks.MyEntity.java
public class MySequenceGenerator implements IdentifierGenerator {
public static final String QUERY_NAME = "MySequence.newId";
public Serializable generate(SessionImplementor session, Object object)
throws HibernateException {
Long id = null;
Connection connection = session.connection();
try {
PreparedStatement preparedStatement = connection.prepareStatement(session
.getNamedQuery(QUERY_NAME).getQueryString());
ResultSet resultSet = preparedStatement.executeQuery();
if (resultSet.next()) {
id = resultSet.getLong(1);
}
} catch (SQLException e) {
e.printStackTrace();
}
return id;
}
}
hbm.xml
...
<sql-query name="MySequence.newId">
<return-scalar column="id" type="long" />
<![CDATA[
select
seq_my.NEXTVAL id
from
dual
]]>
</sql-query>
...
ru.olimpiks.MyEntity.java
@Entity
@Table(name = "MY_TABLE")
public class MyEntity implements java.io.Serializable {
private Long id;
@Id
@Column(name = "ID")
@GeneratedValue(generator = "my_id")
@GenericGenerator(name = "my_id", strategy = "ru.olimpiks.MySequenceGenerator")
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
// ...
}
02 января, 2010
oracle type to java beans with jaxb
1. create oracle types
CREATE OR REPLACE TYPE qwerty_element_t AS OBJECT
(str VARCHAR2(10)
,num number
,str_big clob
,dt date
);
/
CREATE OR REPLACE TYPE qwerty_tt AS TABLE OF qwerty_element_t;
/
CREATE OR REPLACE TYPE qwerty_t AS OBJECT
(id VARCHAR2(1000)
,element qwerty_element_t
,elements qwerty_tt
);
/
create or replace
function getQwertyAsXml(p_id varchar2) return clob as
v_qwerty qwerty_t;
v_xml XMLTYPE;
begin
-- init object instance
v_qwerty := ...;
--convert object to xml
v_xml := XMLTYPE (v_qwerty);
-- xml to clob
return v_xml.getClobVal();
end;
/
2. oracle type to xsd
OracleType2XSD.groovy
class OracleType2XSD {
static String clob2String(java.sql.Clob clob) {/*...*/}
static Sql getSql() {/*...*/}
static String oracleType2XSD(Sql sql, String oracleType, String rootTag) {
String res
sql.call("""{ ${Sql.CLOB} = call dbms_xmlschema.generateSchema(
user,
${Sql.VARCHAR(oracleType)},
${Sql.VARCHAR(rootTag)},
TRUE,FALSE,TRUE
).getClobVal() }""") { xsd ->
res = clob2String(xsd)
}
res
}
static void main(args) {
new File('qwerty.xsd').withWriter {
it << oracleType2XSD(getSql(), 'QWERTY_T', 'qwerty')
}
}
}
execute
set CLASSPATH=...
java -cp %CLASSPATH% groovy.lang.GroovyShell OracleType2XSD.groovy
product qwerty.xsd
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xdb="http://xmlns.oracle.com/xdb"
xsi:schemaLocation="http://xmlns.oracle.com/xdb http://xmlns.oracle.com/xdb/XDBSchema.xsd">
<xsd:element name="qwerty" type="QWERTY_TType" />
<xsd:complexType name="QWERTY_TType">
<xsd:sequence>
<xsd:element name="ID">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="1000" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="INNER" type="QWERTY_INNER_TType" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="QWERTY_INNER_TType">
<xsd:sequence>
<xsd:element name="STR">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="10" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="NUM" type="xsd:double" />
<xsd:element name="STR_BIG" type="xsd:string" />
<xsd:element name="DT" type="xsd:date" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
3. xsd to java beans
execute
%JAVA_HOME%/bin/xjc qwerty.xsd -p ru.olimpiks.oracle.model
product java beans:
ru.olimpiks.oracle.model.QWERTYELEMENTTType.java
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "QWERTY_ELEMENT_TType", propOrder = {
"str",
"num",
"strbig",
"dt"
})
public class QWERTYELEMENTTType {
@XmlElement(name = "STR", required = true)
protected String str;
@XmlElement(name = "NUM")
protected double num;
@XmlElement(name = "STR_BIG", required = true)
protected String strbig;
@XmlElement(name = "DT", required = true)
@XmlSchemaType(name = "date")
protected XMLGregorianCalendar dt;
//...setters and getters
}
ru.olimpiks.oracle.model.QWERTYTType.java
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "QWERTY_TType", propOrder = {
"id",
"element",
"elements"
})
@XmlRootElement(name="qwerty")//!!!to further correct unmarshall object, you must add this line
public class QWERTYTType {
@XmlElement(name = "ID", required = true)
protected String id;
@XmlElement(name = "ELEMENT", required = true)
protected QWERTYELEMENTTType element;
@XmlElement(name = "ELEMENTS")
protected List<QWERTYELEMENTTType> elements;
//...setters and getters
}
4. oracle type to java object with jaxb (groovy example)
static QWERTYTType getQwerty(Sql sql, String id) {
String res
sql.call("""{ ${Sql.CLOB} = call getQwertyAsXml(${Sql.VARCHAR(id)}) }""") { p_res ->
res = clob2String(p_res)
}
JAXBContext context = JAXBContext.newInstance(QWERTYTType.class);
Unmarshaller u = context.createUnmarshaller();
return (QWERTYTType)u.unmarshal(new java.io.StringReader(res));
}
Can't register Tomcat as Windows service on some computers, under Java6
source...
jdk1.6.0_12
apache-tomcat-6.0.20
Windows Server 2003 R2
For fix it:
jdk1.6.0_12
apache-tomcat-6.0.20
Windows Server 2003 R2
...
[2009-12-15 19:05:16] [info] Procrun (2.0.4.0) started
[2009-12-15 19:05:16] [info] Running Service...
[2009-12-15 19:05:16] [info] Starting service...
[2009-12-15 19:05:16] [174 javajni.c] [error] The specified module could not be found.
[2009-12-15 19:05:16] [994 prunsrv.c] [error] Failed creating java d:\dev\jdk1.6.0_12\jre\bin\server\jvm.dll
[2009-12-15 19:05:16] [1269 prunsrv.c] [error] ServiceStart returned 1
[2009-12-15 19:05:16] [info] Run service finished.
[2009-12-15 19:05:16] [info] Procrun finished.
...
For fix it:
copy %JAVA_HOME%/bin/msvcr71.dll %CATALINA_HOME%/bin
22 ноября, 2009
syntax highlighter
Источник.
Для подсветки синтаксиса можно использовать SyntaxHighlighter, который поддерживает различные языки и темы.
Добавим в <head> тег нашего html шаблона следующее:
Использовать данную библиотеку можно следующим образом.
Используя специальный тег <script> с окаймлением CDATA:
или при помощи тега <pre> с символами экранированными для html:
Для подсветки синтаксиса можно использовать SyntaxHighlighter, который поддерживает различные языки и темы.
Добавим в <head> тег нашего html шаблона следующее:
<!-- Add-in CSS for syntax highlighting -->
<link href='http://alexgorbatchev.com/pub/sh/2.1.364/styles/shCore.css' rel='stylesheet' type='text/css'/>
<link href='http://alexgorbatchev.com/pub/sh/2.1.364/styles/shThemeRDark.css' rel='stylesheet' type='text/css'/>
<!-- Add-in Script for syntax highlighting -->
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shCore.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushAS3.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushBash.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushCSharp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushColdFusion.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushCpp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushCss.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushDiff.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushErlang.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushGroovy.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushJScript.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushJava.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushJavaFX.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushPerl.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushPhp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushPlain.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushPowerShell.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushPython.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushRuby.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushScala.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushSql.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushVb.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushXml.js' type='text/javascript'/>
<script language='javascript'>
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/2.1.364/scripts/clipboard.swf';
SyntaxHighlighter.all();
</script>
<!-- End code hilight -->
Использовать данную библиотеку можно следующим образом.
Используя специальный тег <script> с окаймлением CDATA:
<script type="syntaxhighlighter" class="brush: html"><![CDATA[
<html>
<head>
<title>Carter Tomorrow Fund Donations</title>
<meta name="title" content="Help Give to the Carter Tomorrow Fund" />
<meta name="description" content="Show your support and help out with a small gift"
]]></script>
или при помощи тега <pre> с символами экранированными для html:
<pre class="brush: html">
<html>
<head>
<title>Carter Tomorrow Fund Donations</title>
<meta name="title" content="Help Give to the Carter Tomorrow Fund" />
<meta name="description" content="Show your support and help out with a small gift"
</pre>
tags:
highlighter,
html,
syntax
17 ноября, 2009
Подписаться на:
Сообщения (Atom)
