跳转到内容

网站仍在测试中

沙盒:修订间差异

来自质量人百科
无编辑摘要
无编辑摘要
 
第1行: 第1行:
<noinclude>
<noinclude>
{{图书百科
{{图书百科
|描述=综合图书百科模板,包含详细图书信息
|描述=综合图书百科模板,包含详细信息和评分功能
|作者=示例作者
|作者=示例作者
|版本=3.0
|版本=3.0
第9行: 第9行:


<includeonly>
<includeonly>
<div class="book-infobox" style="border:1px solid #aaa; background:#f9f9f9; padding:15px; margin:10px 0; clear:both;">
<div class="book-infobox" style="border: 1px solid #{{#if:{{{边框颜色|}}}|{{{边框颜色|ddd}}}|ddd}}; background-color: #{{#if:{{{背景颜色|}}}|{{{背景颜色|f9f9f9}}}|f9f9f9}}; padding: 1em; margin: 0.5em 0;">


<!-- 图书基本信息部分 -->
<!-- 图书信息部分 -->
<div style="float:right; width:250px; margin-left:15px;">
<div class="book-info" style="display: flex; flex-wrap: wrap;">
{{#if:{{{封面|}}}|
  <!-- 封面和基本信息 -->
<div style="text-align:center;">
  <div style="flex: 0 0 200px; margin-right: 1em;">
[[文件:{{{封面}}}|200px|{{{标题|{{PAGENAME}}}}}封面]]
    {{#if:{{{封面|}}}|
{{#if:{{{封面说明|}}}|<br/><small>{{{封面说明}}}</small>}}
    <div style="text-align: center;">
      [[文件:{{{封面}}}|200px|center|{{{标题|{{PAGENAME}}}}}封面{{#if:{{{封面说明|}}}| - {{{封面说明|}}}}}]]
    </div>
    }}
   
    <div style="margin-top: 1em; text-align: center;">
      {{#if:{{{豆瓣评分|}}}|
      <div style="font-size: 120%; font-weight: bold;">豆瓣评分: {{{豆瓣评分}}}/10</div>
      <div style="height: 20px; background: #f5f5f5; border: 1px solid #ddd; margin: 0.3em 0;">
        <div style="width: {{#expr:{{{豆瓣评分}}}*10}}%; height: 100%; background: #{{#if:{{{评分颜色|}}}|{{{评分颜色|ff9900}}}|ff9900}};"></div>
      </div>
      }}
     
      {{#if:{{{允许评分|}}}|
      <div style="margin-top: 1em;">
        <span style="font-size: 90%;">您的评分:</span><br/>
        <span class="star-rating">
          {{#for:1|1|5|1|
            <a href="{{#if:{{{评分回调|}}}|{{{评分回调}}}/{{PAGENAME}}/{{{1}}}|#}}"
              style="text-decoration: none; color: {{#if:{{{评分|}}}|{{#ifexpr:{{{评分}}}>={{{1}}}|gold|#ccc}}|#ccc}};">★</a>
          }}
        </span>
        <input type="hidden" id="book-rating" value="{{{评分|}}}" />
      </div>
      }}
    </div>
  </div>
 
  <!-- 详细信息表格 -->
  <div style="flex: 1;">
    <h2 style="margin-top: 0; color: #{{#if:{{{标题颜色|}}}|{{{标题颜色|222}}}|222}};">{{{标题|{{PAGENAME}}}}}{{#if:{{{副标题|}}}|: {{{副标题|}}}|}}</h2>
   
    <table style="width: 100%;">
      {{#if:{{{作者|}}}|<tr><th style="width: 80px;">作者</th><td>{{{作者}}}</td></tr>}}
      {{#if:{{{译者|}}}|<tr><th>译者</th><td>{{{译者}}}</td></tr>}}
      {{#if:{{{出版社|}}}|<tr><th>出版社</th><td>{{{出版社}}}</td></tr>}}
      {{#if:{{{出版日期|}}}|<tr><th>出版日期</th><td>{{{出版日期}}}</td></tr>}}
      {{#if:{{{页数|}}}|<tr><th>页数</th><td>{{{页数}}}</td></tr>}}
      {{#if:{{{ISBN|}}}|<tr><th>ISBN</th><td>{{{ISBN}}}</td></tr>}}
      {{#if:{{{定价|}}}|<tr><th>定价</th><td>{{{定价}}}</td></tr>}}
    </table>
  </div>
</div>
</div>
}}
</div>
<h2 style="border-bottom:1px solid #ccc; padding-bottom:5px;">{{{标题|{{PAGENAME}}}}}{{#if:{{{副标题|}}}|: {{{副标题|}}}}}</h2>
<table style="width:100%; margin-bottom:15px;">
<tr>
<td style="width:30%; vertical-align:top;">
<strong>作者</strong>
</td>
<td style="width:70%; vertical-align:top;">
{{#if:{{{作者链接|}}}|[{{{作者链接|}}} {{{作者|}}}]}|{{{作者|}}}}}
</td>
</tr>
{{#if:{{{译者|}}}|
<tr>
<td style="vertical-align:top;"><strong>译者</strong></td>
<td style="vertical-align:top;">{{{译者}}}</td>
</tr>
}}
{{#if:{{{出版社|}}}|
<tr>
<td style="vertical-align:top;"><strong>出版社</strong></td>
<td style="vertical-align:top;">{{{出版社}}}</td>
</tr>
}}
{{#if:{{{出版日期|}}}|
<tr>
<td style="vertical-align:top;"><strong>出版日期</strong></td>
<td style="vertical-align:top;">{{{出版日期}}}</td>
</tr>
}}
{{#if:{{{页数|}}}|
<tr>
<td style="vertical-align:top;"><strong>页数</strong></td>
<td style="vertical-align:top;">{{{页数}}}</td>
</tr>
}}
{{#if:{{{ISBN|}}}|
<tr>
<td style="vertical-align:top;"><strong>ISBN</strong></td>
<td style="vertical-align:top;">{{{ISBN}}}</td>
</tr>
}}


{{#if:{{{豆瓣评分|}}}|
<!-- 内容简介 -->
<tr>
<td style="vertical-align:top;"><strong>豆瓣评分</strong></td>
<td style="vertical-align:top;">
<div style="color:#{{#if:{{{评分颜色|}}}|{{{评分颜色|e74c3c}}}|e74c3c}}; font-weight:bold; font-size:1.2em;">
{{#if:{{{评分人数|}}}|{{{豆瓣评分}}}/10 ({{{评分人数}}}+评价)|{{{豆瓣评分}}}/10}}
</div>
{{#if:{{{豆瓣链接|}}}|[{{{豆瓣链接|}}} 查看豆瓣页面]}}
</td>
</tr>
}}
</table>
 
<!-- 内容简介部分 -->
{{#if:{{{内容简介|}}}|
{{#if:{{{内容简介|}}}|
<div style="margin-top:20px; padding-top:10px; border-top:1px dashed #ccc;">
<div style="margin-top: 1.5em; padding-top: 1em; border-top: 1px dashed #ccc;">
<h3>内容简介</h3>
  <h3>内容简介</h3>
<div style="line-height:1.6;">{{{内容简介}}}</div>
  <div>{{{内容简介}}}</div>
</div>
</div>
}}
}}


<!-- 作者简介部分 -->
<!-- 作者简介 -->
{{#if:{{{作者简介|}}}|
{{#if:{{{作者简介|}}}|
<div style="margin-top:20px; padding-top:10px; border-top:1px dashed #ccc;">
<div style="margin-top: 1.5em; padding-top: 1em; border-top: 1px dashed #ccc;">
<h3>作者简介</h3>
  <h3>作者简介</h3>
<div style="line-height:1.6;">{{{作者简介}}}</div>
  <div>{{{作者简介}}}</div>
</div>
</div>
}}
}}


<!-- 图书目录部分 -->
<!-- 图书目录 -->
{{#if:{{{图书目录|}}}|
{{#if:{{{图书目录|}}}|
<div style="margin-top:20px; padding-top:10px; border-top:1px dashed #ccc;">
<div style="margin-top: 1.5em; padding-top: 1em; border-top: 1px dashed #ccc;">
<h3>图书目录</h3>
  <h3>图书目录</h3>
<div style="line-height:1.6; padding-left:20px;">{{{图书目录}}}</div>
  <div>{{{图书目录}}}</div>
</div>
</div>
}}
}}


<!-- 精彩文摘部分 -->
<!-- 精彩文摘 -->
{{#if:{{{精彩文摘|}}}|
{{#if:{{{精彩文摘|}}}|
<div style="margin-top:20px; padding-top:10px; border-top:1px dashed #ccc;">
<div style="margin-top: 1.5em; padding-top: 1em; border-top: 1px dashed #ccc;">
<h3>精彩文摘</h3>
  <h3>精彩文摘</h3>
<blockquote style="font-style:italic; margin:10px 0; padding-left:15px; border-left:3px solid #ccc;">
  <blockquote style="font-style: italic; margin-left: 1em; padding-left: 1em; border-left: 3px solid #ccc;">
{{{精彩文摘}}}
    {{{精彩文摘}}}
</blockquote>
  </blockquote>
</div>
</div>
}}
}}


<!-- 读者评分部分 -->
<!-- 评分系统JavaScript (需要启用$wgAllowExternalImages和$wgRawHtml) -->
{{#if:{{{允许评分|}}}|
{{#if:{{{允许评分|}}}|
<div style="margin-top:20px; padding-top:10px; border-top:1px dashed #ccc;">
<script>
<h3>读者评分</h3>
document.addEventListener('DOMContentLoaded', function() {
<div style="line-height:1.6;">
  const stars = document.querySelectorAll('.star-rating a');
{{#if:{{{评分说明|}}}|{{{评分说明}}}|请为本书评分:}}
  const ratingInput = document.getElementById('book-rating');
<span style="font-size:1.2em;">
 
{{#if:{{{1|}}}|
  stars.forEach(star => {
{{#forloop:1|10|i|
    star.addEventListener('click', function(e) {
{{#ifexpr: {{{i}}} <= {{{1}}}|★|☆}}
      e.preventDefault();
      const rating = this.textContent === '★' ? this.textContent.charCodeAt(0) - 9722 : parseInt(this.textContent);
      ratingInput.value = rating;
     
      // 更新星星显示
      stars.forEach((s, i) => {
        s.style.color = i < rating ? 'gold' : '#ccc';
      });
     
      // 这里可以添加AJAX调用以保存评分
      // 例如: fetch('{{{评分回调}}}', { method: 'POST', body: JSON.stringify({rating: rating}) });
    });
  });
});
</script>
}}
}}
|
[{{fullurl:{{FULLPAGENAME}}|action=edit}} 添加您的评分]
}}
</span>
</div>
</div>
}}
</div>
</div>
</includeonly>
</includeonly>

2025年6月19日 (四) 22:18的最新版本


沙盒
作者 示例作者
出版社
出版日期
ISBN ISBN缺失
豆瓣评分 暂无评分
               {{#if:|(脚本错误:没有“Formatnum”这个模块。
用户评分
0/10
<div class="rating-bar" style="width:表达式错误:无法识别标点符号“{”。%; background:#ffcc00;">
内容简介
作者简介
图书目录

(暂无目录信息)

精彩文摘

(暂无文摘)