提交 57ef29e2 编写于 作者: 智布道's avatar 智布道 👁

首页友情链接优化、BaseTag缓存class

上级 62597ec2
......@@ -10,12 +10,14 @@ import freemarker.template.TemplateDirectiveModel;
import freemarker.template.TemplateException;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* 所有自定义标签的父类,负责调用具体的子类方法
......@@ -26,12 +28,22 @@ import java.util.Map;
* @date 2018/9/18 16:19
* @since 1.8
*/
@Slf4j
public abstract class BaseTag implements TemplateDirectiveModel {
private static final ConcurrentHashMap<String, Class> classBucket = new ConcurrentHashMap<>();
private String clazzPath = null;
public BaseTag(String targetClassPath) {
clazzPath = targetClassPath;
if (classBucket.get(clazzPath) == null) {
try {
Class clazz = Class.forName(clazzPath);
classBucket.put(clazzPath, clazz);
} catch (ClassNotFoundException e) {
log.error("无法从[{}]获取对应的class", clazzPath, e);
}
}
}
private String getMethod(Map params) {
......@@ -67,22 +79,20 @@ public abstract class BaseTag implements TemplateDirectiveModel {
return this.getBuilder().wrap(o);
}
@Override
public void execute(Environment environment, Map map, TemplateModel[] templateModels, TemplateDirectiveBody templateDirectiveBody) throws TemplateException, IOException {
this.verifyParameters(map);
String funName = getMethod(map);
Method method = null;
Class clazz = classBucket.get(clazzPath);
try {
Class clazz = Class.forName(clazzPath);
method = clazz.getDeclaredMethod(funName, Map.class);
if (method != null) {
if (clazz != null && (method = clazz.getDeclaredMethod(funName, Map.class)) != null) {
// 核心处理,调用子类的具体方法,获取返回值
Object res = method.invoke(this, map);
environment.setVariable(funName, getModel(res));
}
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
log.error("无法获取[{}]的方法,或者调用[{}]方法发生异常", clazzPath, method, e);
}
templateDirectiveBody.render(environment.getOut());
}
......
......@@ -675,6 +675,11 @@ span.separation:AFTER {
background-color: #eeeeee;
}
.footer .external-links a{
font-size: 12px;
color: #919191 !important;;
}
.footer a {
color: #555;
}
......@@ -2872,4 +2877,17 @@ nav a:first-child .meta-nav {
filter: alpha(opacity=70);
opacity: .7;
}
/* 轮播图 */
\ No newline at end of file
/* 轮播图 */
.img-widget {
display: inline-block;
position: relative;
}
.img-widget .widget-header img{
width: 100px;
}
.img-widget .widget-footer{
text-align: center;
padding: 5px;
font-size: 12px;
}
\ No newline at end of file
......@@ -138,26 +138,6 @@
<#include "layout/sidebar.ftl"/>
</div>
</div>
<section class="links index-links">
<ul class="list-unstyled list-inline">
<#if indexLinkList?exists && (indexLinkList?size > 0)>
<#list indexLinkList as item>
<li>
<a href="${item.url}" target="_blank" title="${item.description?if_exists}" data-toggle="tooltip" data-placement="bottom">
<img src="${item.favicon}" alt="${item.name?if_exists}" onerror="this.src='${config.staticWebSite}/img/user.png'">${item.name?if_exists}
</a>
</li>
</#list>
<li>
<a href="${config.siteUrl}/links" title="更多链接" data-toggle="tooltip" data-placement="bottom"><i class="fa fa-plus"></i>更多链接</a>
</li>
<#else>
<li>
<a href="${config.siteUrl}/links" title="申请友链" data-toggle="tooltip" data-placement="bottom">申请友链</a>
</li>
</#if>
</ul>
</section>
<@footer></@footer>
</@compress>
\ No newline at end of file
......@@ -109,7 +109,7 @@
<ul class="list-unstyled list-inline">
<li><a href="http://shang.qq.com/wpa/qunwpa?idkey=9f986e9b33b1de953e1ef9a96cdeec990affd0ac7855e00ff103514de2027b60" target="_blank" title="加入我的QQ交流群:190886500" data-toggle="tooltip" data-placement="bottom" rel="external nofollow"><i class="fa fa-qq"></i>QQ交流群</a></li>
<li><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"><i class="fa fa-fire fa-fw"></i>阿里云券</a></li>
<li><a href="https://mi.aliyun.com/shop/19462" target="_blank" title="闲置域名出售" data-toggle="tooltip" data-placement="bottom" rel="external nofollow"><i class="fa fa-globe fa-fw fa-spin red"></i>域名出售</a></li>
<li><a href="https://mi.aliyun.com/shop/19462" target="_blank" title="闲置域名出售" data-toggle="tooltip" data-placement="bottom" rel="external nofollow"><i class="fa fa-globe fa-fw fa-spin"></i>域名出售</a></li>
<li><a href="${config.siteUrl}/sitemap.html" target="_blank" title="网站地图" data-toggle="tooltip" data-placement="bottom"><i class="fa fa-map-o fa-fw"></i>网站地图</a></li>
<li><a href="${config.siteUrl}/recommended" title="站长推荐" data-toggle="tooltip" data-placement="bottom"><i class="fa fa-thumbs-o-up fa-fw"></i>站长推荐</a></li>
<li><a href="${config.siteUrl}/updateLog" title="更新记录" data-toggle="tooltip" data-placement="bottom"><i class="fa fa-file-o fa-fw"></i>更新记录</a></li>
......@@ -127,17 +127,38 @@
</div>
<div class="col-xs-12 col-sm-4 col-md-4 text-left fade-in">
<h4>问题交流</h4>
<div class="row" style="padding: 4px;padding-left: 10px;">
<div class="row" style="padding: 4px;padding-left: 0;">
<div class="col-xs-12 col-sm-12 col-md-12">
<a href="${config.staticWebSite}/img/wechat_account.jpg" target="_blank" class="showImage" title="[码一码]公众号" rel="external nofollow">
<img data-original="${config.staticWebSite}/img/wechat_account.jpg" alt="[码一码]公众号" class="img-responsive img-rounded auto-shake lazy-img" style="width: 100px;display: inline-block">
</a>
<a href="${config.staticWebSite}/img/mayima.jpg" target="_blank" class="showImage" title="[码一码]小程序" rel="external nofollow">
<img data-original="${config.staticWebSite}/img/mayima.jpg" alt="[码一码]小程序" class="img-responsive img-rounded auto-shake lazy-img" style="width: 100px;display: inline-block">
</a>
<a href="${config.staticWebSite}/img/qq_group.png" class="showImage" title="QQ群(190886500)二维码" rel="external nofollow">
<img data-original="${config.staticWebSite}/img/qq_group.png" alt="QQ群(190886500)二维码" class="img-responsive img-rounded auto-shake lazy-img" style="width: 100px;display: inline-block">
</a>
<div class="img-widget">
<div class="widget-header">
<a href="${config.wxCode}" target="_blank" class="showImage" title="[码一码]公众号" rel="external nofollow">
<img data-original="${config.wxCode}" alt="[码一码]公众号" class="img-responsive img-rounded auto-shake lazy-img">
</a>
</div>
<div class="widget-footer">
<span>公众号</span>
</div>
</div>
<div class="img-widget">
<div class="widget-header">
<a href="https://gitee.com/yadong.zhang/static/raw/master/wx/wx.png" target="_blank" class="showImage" title="添加微信(备注:加群)" rel="external nofollow">
<img data-original="https://gitee.com/yadong.zhang/static/raw/master/wx/wx.png" alt="添加微信(备注:加群)" class="img-responsive img-rounded auto-shake lazy-img" >
</a>
</div>
<div class="widget-footer">
<span>微信(备注:加群)</span>
</div>
</div>
<div class="img-widget">
<div class="widget-header">
<a href="${config.staticWebSite}/img/qq_group.png" class="showImage" title="QQ群(190886500)二维码" rel="external nofollow">
<img data-original="${config.staticWebSite}/img/qq_group.png" alt="QQ群(190886500)二维码" class="img-responsive img-rounded auto-shake lazy-img" >
</a>
</div>
<div class="widget-footer">
<span>QQ群</span>
</div>
</div>
</div>
</div>
</div>
......@@ -146,7 +167,22 @@
<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://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>
<p>Copyright&copy;2016-${.now?string("yyyy")} ${config.siteName} · Powered by <a href="https://gitee.com/yadong.zhang/DBlog" title="OneBlog是一款简洁美观、自适应的Java博客系统..." data-toggle="tooltip" data-placement="right" target="_blank"><strong>OneBlog</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"></i>网站统计</a></p>
<#if url?exists && (url == "index")>
<div class="inline external-links">
<a>友情链接:</a>
<#if indexLinkList?exists && (indexLinkList?size > 0)>
<#list indexLinkList as item>
<a href="${item.url}" target="_blank" title="${item.description?if_exists}" data-toggle="tooltip" data-placement="right">
${item.name?if_exists}
</a>
</#list>
<a href="${config.siteUrl}/links" title="更多链接" data-toggle="tooltip" data-placement="right"><i class="fa fa-plus"></i>更多链接</a>
<#else>
<a href="${config.siteUrl}/links" title="申请友链" data-toggle="tooltip" data-placement="right">申请友链</a>
</#if>
</div>
</#if>
</div>
</footer>
<a class="to-top" title="点击返回顶部" data-toggle="tooltip" data-placement="bottom"></a>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册