提交 cba4c509 编写于 作者: Y yadong.zhang

集成YUI compressor实现js、css文件的自动压缩

上级 136ec907
......@@ -11,7 +11,6 @@
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear
*.zip
......
......@@ -81,7 +81,7 @@ ps: 虽然我知道,大部分人都是来了**直接下载源代码**后就潇
1. 数据库链接属性(在`resources/application-{env}.yml`配置文件中搜索`datasource`或定位到L.7)
2. redis配置(在`resources/application.yml`配置文件中搜索`redis`或定位到L.65)
3. mail配置(在`resources/application-{env}.yml`配置文件中搜索`mail`或定位到L.14)
4.[七牛云](http://qiniu.com)】配置(见sys_config表中qiniu_*开头的字段)
4.[七牛云](https://portal.qiniu.com/signup?code=3l8yx2v0f21ci)】配置(见sys_config表中qiniu_*开头的字段)
注:因为系统存在redis缓存,如果是第一次使用,可以直接修改sys_config表内容,如果不是第一次用,建议使用admin项目中的`系统配置`页面修改相关配置内容
5. 运行项目(三种方式)
1. 项目根目录下执行`mvn -X clean package -Dmaven.test.skip=true -Ptest`编译打包(注:-Ptest中的test为环境标识),然后cd到blog-web目录下执行`java -jar target/blog-web.jar`
......
......@@ -41,6 +41,46 @@
<useDefaultDelimiters>false</useDefaultDelimiters>
</configuration>
</plugin>-->
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compress</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- 读取js,css文件采用UTF-8编码 -->
<encoding>UTF-8</encoding>
<!-- 不显示js可能的错误 -->
<jswarn>false</jswarn>
<!-- 若存在已压缩的文件,会先对比源文件是否有改动 有改动便压缩,无改动就不压缩 -->
<force>false</force>
<!-- 在指定的列号后插入新行 -->
<linebreakpos>-1</linebreakpos>
<!-- 压缩之前先执行聚合文件操作 -->
<preProcessAggregates>true</preProcessAggregates>
<!-- 压缩后保存的文件后缀:true=无后缀 ,false=有后缀-min -->
<nosuffix>true</nosuffix>
<!-- 源目录,即需压缩的根目录 -->
<sourceDirectory>src/main/resources/static/assets</sourceDirectory>
<!-- 目标输出目录 -->
<outputDirectory>target/classes/static/assets</outputDirectory>
<!-- 压缩js和css文件 -->
<includes>
<include>**/*.js</include>
<include>**/*.css</include>
</includes>
<!-- 以下目录和文件不会被压缩 -->
<excludes>
<exclude>**/*.min.js</exclude>
<exclude>**/*.min.css</exclude>
<exclude>**/jquery-form.js</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
......@@ -52,6 +92,23 @@
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
<includes>
<include>static/assets/images/**</include>
<!--<include>%regex[static/assets/js/(jquery-form|wangEditor\.min)\.js]</include>-->
<include>static/assets/js/jquery-form.js</include>
<include>static/assets/js/wangEditor.min.js</include>
<include>static/assets/css/jquery-confirm.min.css</include>
<include>templates/**</include>
<include>*.yml</include>
<include>*.txt</include>
<include>*.xml</include>
</includes>
</resource>
</resources>
</build>
......
......@@ -227,7 +227,7 @@ public class ShiroConfig {
// 这个参数是cookie的名称,对应前端的checkbox的name = rememberMe
SimpleCookie simpleCookie = new SimpleCookie("rememberMe");
// 记住我cookie生效时间30天 ,单位秒。 注释掉,默认永久不过期 2018-07-15
// simpleCookie.setMaxAge(redisProperties.getExpire());
simpleCookie.setMaxAge(redisProperties.getExpire());
return simpleCookie;
}
......
......@@ -92,17 +92,18 @@ if(articleId){
if(info['coverImage']){
$(".coverImage").attr('src', appConfig.qiniuPath + info['coverImage']);
}
if(info['contentMd']){
$("#contentMd").val(info['contentMd']);
var contentMd = info['contentMd'];
if(contentMd){
$("#contentMd").val(contentMd);
if(simplemde){
simplemde.value(info['contentMd']);
simplemde.value(contentMd);
}
}
if(info['content']){
$("#content").val(info['content']);
var contentHtml = info['content'];
if(contentHtml){
$("#content").val(contentHtml);
if(editor){
editor.txt.html(info['content']);
editor.txt.html(contentHtml);
}
}
$publishForm.find("input[type!=checkbox], select, textarea").each(function () {
......
......@@ -39,6 +39,45 @@
<useDefaultDelimiters>false</useDefaultDelimiters>
</configuration>
</plugin>-->
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compress</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- 读取js,css文件采用UTF-8编码 -->
<encoding>UTF-8</encoding>
<!-- 不显示js可能的错误 -->
<jswarn>false</jswarn>
<!-- 若存在已压缩的文件,会先对比源文件是否有改动 有改动便压缩,无改动就不压缩 -->
<force>false</force>
<!-- 在指定的列号后插入新行 -->
<linebreakpos>-1</linebreakpos>
<!-- 压缩之前先执行聚合文件操作 -->
<preProcessAggregates>true</preProcessAggregates>
<!-- 压缩后保存的文件后缀:true=无后缀 ,false=有后缀-min -->
<nosuffix>true</nosuffix>
<!-- 源目录,即需压缩的根目录 -->
<sourceDirectory>src/main/resources/static</sourceDirectory>
<!-- 目标输出目录 -->
<outputDirectory>target/classes/static</outputDirectory>
<!-- 压缩js和css文件 -->
<includes>
<include>**/*.js</include>
<include>**/*.css</include>
</includes>
<!-- 以下目录和文件不会被压缩 -->
<excludes>
<exclude>**/*.min.js</exclude>
<exclude>**/*.min.css</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
......@@ -50,6 +89,20 @@
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
<!-- includes和excludes冲突时,以excludes为准 -->
<includes>
<include>templates/**</include>
<include>static/img/**</include>
<include>*.yml</include>
<include>*.txt</include>
<include>*.xml</include>
</includes>
</resource>
</resources>
</build>
......
......@@ -142,7 +142,7 @@
</div>
<footer class="footer">
<div class="clear">
<p>托管于<a href="https://promotion.aliyun.com/ntms/act/ambassador/sharetouser.html?userCode=wylo59db" target="_blank" title="阿里云-为了无法计算的价值" data-toggle="tooltip" data-placement="bottom" rel="external nofollow">阿里云</a> & <a href="https://www.qiniu.com/" target="_blank" title="七牛云-国内领先的企业级云服务商" data-toggle="tooltip" data-placement="bottom" rel="external nofollow">七牛云</a> · <a href="http://www.miitbeian.gov.cn/publish/query/indexFirst.action" target="_blank" title="查看备案信息" data-toggle="tooltip" data-placement="bottom" rel="external nofollow">鲁ICP备17054970号-1</a></p>
<p>托管于<a href="https://promotion.aliyun.com/ntms/act/ambassador/sharetouser.html?userCode=wylo59db" target="_blank" title="阿里云-为了无法计算的价值" data-toggle="tooltip" data-placement="bottom" rel="external nofollow">阿里云</a> & <a href="https://portal.qiniu.com/signup?code=3l8yx2v0f21ci" target="_blank" title="七牛云-国内领先的企业级云服务商" data-toggle="tooltip" data-placement="bottom" rel="external nofollow">七牛云</a> · <a href="http://www.miitbeian.gov.cn/publish/query/indexFirst.action" target="_blank" title="查看备案信息" data-toggle="tooltip" data-placement="bottom" rel="external nofollow">鲁ICP备17054970号-1</a></p>
<p>Copyright&copy;2016-${.now?string("yyyy")} ${config.siteName} · Powered by <a href="https://gitee.com/yadong.zhang/DBlog" title="DBlog是一款简洁美观、自适应的Java博客系统..." data-toggle="tooltip" data-placement="right" target="_blank"><strong>DBlog</strong></a> · <a href="http://tongji.baidu.com/web/welcome/ico?s=590226d2f4ffbf051442eb75f37333c9" target="_blank" title="点击查看${config.siteName}网站统计详情" data-toggle="tooltip" data-placement="right" rel="external nofollow"><i class="fa fa-bar-chart-o fa-fw fa-spin"></i>网站统计</a></p>
</div>
</footer>
......@@ -166,7 +166,6 @@
zfbPraiseCode: '${config.zfbPraiseCode}'
}
</script>
<script type="text/javascript" src="${config.staticWebSite}/js/wangEditor.min.js"></script>
<script type="text/javascript" src="${config.staticWebSite}/js/zhyd.core.js"></script>
<script type="text/javascript" src="${config.staticWebSite}/js/zhyd.js"></script>
<script type="text/javascript" src="${config.staticWebSite}/js/zhyd.comment.js"></script>
\ No newline at end of file
# http://yui.github.io/yuicompressor/
#
# java -jar yuicompressor-x.y.z.jar
# Usage: java -jar yuicompressor-x.y.z.jar [options] [input file]
#
# Global Options
# -h, --help Displays this information
# --type <js|css> Specifies the type of the input file
# --charset <charset> Read the input file using <charset>
# --line-break <column> Insert a line break after the specified column number
# -v, --verbose Display informational messages and warnings
# -o <file> Place the output into <file> or a file pattern.
# Defaults to stdout.
#
# JavaScript Options
# --nomunge Minify only, do not obfuscate
# --preserve-semi Preserve all semicolons
# --disable-optimizations Disable all micro optimizations
#
# GLOBAL OPTIONS
#
# -h, --help
# Prints help on how to use the YUI Compressor
#
# --line-break
# Some source control tools don't like files containing lines longer than,
# say 8000 characters. The linebreak option is used in that case to split
# long lines after a specific column. It can also be used to make the code
# more readable, easier to debug (especially with the MS Script Debugger)
# Specify 0 to get a line break after each semi-colon in JavaScript, and
# after each rule in CSS.
#
# --type js|css
# The type of compressor (JavaScript or CSS) is chosen based on the
# extension of the input file name (.js or .css) This option is required
# if no input file has been specified. Otherwise, this option is only
# required if the input file extension is neither 'js' nor 'css'.
#
# --charset character-set
# If a supported character set is specified, the YUI Compressor will use it
# to read the input file. Otherwise, it will assume that the platform's
# default character set is being used. The output file is encoded using
# the same character set.
#
# -o outfile
#
# Place output in file outfile. If not specified, the YUI Compressor will
# default to the standard output, which you can redirect to a file.
# Supports a filter syntax for expressing the output pattern when there are
# multiple input files. ex:
# java -jar yuicompressor.jar -o '.css$:-min.css' *.css
# ... will minify all .css files and save them as -min.css
#
# -v, --verbose
# Display informational messages and warnings.
#
# JAVASCRIPT ONLY OPTIONS
#
# --nomunge
# Minify only. Do not obfuscate local symbols.
#
# --preserve-semi
# Preserve unnecessary semicolons (such as right before a '}') This option
# is useful when compressed code has to be run through JSLint (which is the
# case of YUI for example)
#
# --disable-optimizations
# Disable all the built-in micro optimizations.
#
# -------------- start package javascript --------------
## cat a > b - 将a文件内容合并到b文件中
## cat a >> b - 将a文件内容追加到b文件中
cat ../../blog-web/src/main/resources/static/js/zhyd.core.js > zhyd.all.js
cat ../../blog-web/src/main/resources/static/js/zhyd.js >> zhyd.all.js
cat ../../blog-web/src/main/resources/static/js/zhyd.comment.js >> zhyd.all.js
java -jar yuicompressor-2.4.8.jar zhyd.all.js -o ../../blog-web/src/main/resources/static/js/zhyd.min.js --charset utf-8 --type js
rm -f zhyd.all.js
# -------------- start package css --------------
cat ../../blog-web/src/main/resources/static/css/zhyd.core.css > zhyd.all.css
cat ../../blog-web/src/main/resources/static/css/zhyd.comment.css >> zhyd.all.css
java -jar yuicompressor-2.4.8.jar zhyd.all.css -o ../../blog-web/src/main/resources/static/css/zhyd.min.css --charset utf-8 --type css
rm -f zhyd.all.css
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册