title: $:/plugins/Gk0Wk/CPL-Repo/views/plugins/stats
created: 20260101000000000
modified: 20260101000000000
tags: $:/tags/ViewTemplate
type: text/vnd.tiddlywiki

\whitespace trim


<!-- Plugin Stats Display -->
<$list filter="[all[current]tag[$:/tags/PluginWiki]has[cpl.title]]" variable="pluginTiddler">

<$let serverType={{{ [[$:/temp/CPL-Repo/server-type]get[text]else[unknown]] }}} userStatus={{{ [[$:/temp/CPL-Server/user-status]get[text]else[anonymous]] }}} chinese={{{ [[$:/language]get[text]removeprefix[$:/languages/]else[en-GB]search[zh]then[yes]else[no]] }}} githubClientId={{{ [[$:/temp/CPL-Server/github-client-id]get[text]] }}} pluginTitle={{!!cpl.title}} allStatsTiddler="$:/temp/CPL-Server/all-plugin-stats" ratingPanelStateTitle={{{ [<currentTiddler>get[cpl.title]addprefix[$:/state/CPL-Repo/rating-widget/]] }}} changelogPanelStateTitle={{{ [<currentTiddler>get[cpl.title]addprefix[$:/state/CPL-Repo/changelog-panel/]] }}} compatibilityPanelStateTitle={{{ [<currentTiddler>get[cpl.title]addprefix[$:/state/CPL-Repo/compatibility-panel/]] }}} isAdmin={{{ [[$:/temp/CPL-Server/is-admin]get[text]else[no]] }}} changelogTiddler={{{ [<currentTiddler>get[cpl.title]addprefix[$:/temp/CPL-Server/plugin-changelog/]] }}} compatibilityTiddler={{{ [<currentTiddler>get[cpl.title]addprefix[$:/temp/CPL-Server/compatibility/]] }}}>

<$list filter="[<serverType>!match[server]]" variable="isUnavailableServer">
<div class="cpl-static-feature-notice" style="margin: 10px 0; gap: 10px;">
<span style="font-size: 1.5em;">⚠️</span>
<div>
<strong><$text text={{{ [<chinese>match[yes]then[CPL 服务器当前不可用]else[CPL Server Unavailable]] }}}/></strong>
<p style="margin: 4px 0 0 0;"><$text text={{{ [<chinese>match[yes]then[当前配置的 CPL 服务器暂时不可访问，因此评论、下载统计、评分、更新日志等联网功能当前不可用。你仍然可以浏览静态插件数据库。]else[The configured CPL server is currently unreachable, so comments, download stats, ratings, changelog, and other online features are unavailable right now. You can still browse the static plugin database.]] }}}/></p>
</div>
</div>
</$list>

<!-- Only show stats/rating/changelog for server mirrors -->
<$list filter="[<serverType>match[server]]" variable="isServerMirror">

<div class="cpl-plugin-stats">
  <$let statsPluginTitle=<<pluginTitle>>>
  <$tiddler tiddler=<<allStatsTiddler>>>
  <!-- Download Count -->
  <div class="cpl-stat-item">
    <span style="font-size: 1.2em;">⬇️</span>
      <$list filter="[<currentTiddler>is[tiddler]]" variable="hasStats">
        <$text text={{{ [<currentTiddler>get[text]jsonget[plugins],<statsPluginTitle>,[downloadCount]else[0]] }}} />
      </$list>
      <$list filter="[<currentTiddler>!is[tiddler]]" variable="noStats">
        <span class="cpl-status-muted">-</span>
      </$list>
    <span class="cpl-stat-label cpl-status-muted"><$text text={{{ [<chinese>match[yes]then[下载]else[downloads]] }}}/></span>
  </div>

  <!-- Rating Summary Toggle -->
  <$button class="tc-btn-invisible cpl-stat-item cpl-rating-toggle-button" tooltip={{{ [<chinese>match[yes]then[为此插件评分]else[Rate this plugin]] }}} aria-expanded={{{ [<ratingPanelStateTitle>get[text]match[open]then[true]else[false]] }}}>
    <$action-setfield $tiddler=<<ratingPanelStateTitle>> text={{{ [<ratingPanelStateTitle>get[text]match[open]then[closed]else[open]] }}} />
    <span class="cpl-rating-toggle-icon" style="font-size: 1.2em;">⭐</span>
      <$list filter="[<currentTiddler>is[tiddler]]" variable="hasStats">
        <$let avgRating={{{ [<currentTiddler>get[text]jsonget[plugins],<statsPluginTitle>,[averageRating]else[0]] }}} totalRatings={{{ [<currentTiddler>get[text]jsonget[plugins],<statsPluginTitle>,[totalRatings]else[0]] }}}>
          <$list filter="[<totalRatings>compare:integer:gt[0]]" variable="hasRatings">
            <span><$text text=<<avgRating>> />/5</span>
            <span class="cpl-stat-label cpl-status-muted">(<$text text=<<totalRatings>> /> <$text text={{{ [<chinese>match[yes]then[评分]else[ratings]] }}}/>)</span>
          </$list>
          <$list filter="[<totalRatings>compare:integer:eq[0]]" variable="noRatings">
            <span class="cpl-status-muted"><$text text={{{ [<chinese>match[yes]then[暂无评分]else[No ratings yet]] }}}/></span>
          </$list>
        </$let>
      </$list>
      <$list filter="[<currentTiddler>!is[tiddler]]" variable="noStats">
        <span class="cpl-status-muted">-</span>
      </$list>
  </$button>
  </$tiddler>
  </$let>

  <!-- Changelog Toggle (inline in stats row) -->
    <$button class="tc-btn-invisible cpl-stat-item cpl-rating-toggle-button" tooltip={{{ [<chinese>match[yes]then[点击查看更新日志]else[Click to view changelog]] }}}>
      <$action-setfield $tiddler=<<changelogPanelStateTitle>> text={{{ [<changelogPanelStateTitle>get[text]match[open]then[closed]else[open]] }}} />
      <span style="font-size: 1.2em;">📋</span>
      <$list filter="[<changelogPanelStateTitle>get[text]else[closed]!match[open]]" variable="collapsed">
        <$list filter="[<changelogTiddler>is[tiddler]]" variable="hasChangelog">
          <$let hasChangelogField={{{ [<changelogTiddler>get[text]jsonget[hasChangelog]else[false]] }}}>
            <$list filter="[<hasChangelogField>match[true]]" variable="hasContent">
              <span class="cpl-stat-label"><$text text={{{ [<chinese>match[yes]then[更新日志]else[Changelog]] }}}/></span>
            </$list>
            <$list filter="[<hasChangelogField>!match[true]]" variable="noContent">
              <span class="cpl-stat-label cpl-status-muted"><$text text={{{ [<chinese>match[yes]then[暂无更新日志]else[No changelog]] }}}/></span>
            </$list>
          </$let>
        </$list>
      </$list>
      <$list filter="[<changelogPanelStateTitle>get[text]match[open]]" variable="expanded">
        <span class="cpl-stat-label"><$text text={{{ [<chinese>match[yes]then[更新日志 ▾]else[Changelog ▾]] }}}/></span>
      </$list>
    </$button>

  <!-- Compatibility Toggle (inline in stats row) -->
    <$button class="tc-btn-invisible cpl-stat-item cpl-rating-toggle-button" tooltip={{{ [<chinese>match[yes]then[点击查看兼容性报告]else[Click to view compatibility reports]] }}}>
      <$action-setfield $tiddler=<<compatibilityPanelStateTitle>> text={{{ [<compatibilityPanelStateTitle>get[text]match[open]then[closed]else[open]] }}} />
      <span style="font-size: 1.2em;">⚠️</span>
      <$list filter="[<compatibilityPanelStateTitle>get[text]else[closed]!match[open]]" variable="collapsed">
        <$list filter="[<compatibilityTiddler>is[tiddler]]" variable="hasCompatibility">
          <$let reportCount={{{ [<compatibilityTiddler>get[text]jsonindexes[reports]count[]else[0]] }}}>
            <$list filter="[<reportCount>compare:integer:gt[0]]" variable="hasReports">
              <span class="cpl-stat-label"><$text text={{{ [<chinese>match[yes]then[兼容性报告]else[Compatibility]] }}}/> (<$text text=<<reportCount>>/>)</span>
            </$list>
            <$list filter="[<reportCount>compare:integer:eq[0]]" variable="noReports">
              <span class="cpl-stat-label cpl-status-muted"><$text text={{{ [<chinese>match[yes]then[暂无兼容性报告]else[No reports]] }}}/></span>
            </$list>
          </$let>
        </$list>
      </$list>
      <$list filter="[<compatibilityPanelStateTitle>get[text]match[open]]" variable="expanded">
        <span class="cpl-stat-label"><$text text={{{ [<chinese>match[yes]then[兼容性报告 ▾]else[Compatibility ▾]] }}}/></span>
      </$list>
    </$button>
</div>

<!-- Rating Widget -->
<$list filter="[<ratingPanelStateTitle>get[text]match[open]]" variable="isRatingPanelOpen">
  <$list filter="[<userStatus>match[authenticated]]" variable="isLoggedInForRating">
    <div class="cpl-rating-widget">
      <h4 class="cpl-card-heading">⭐ <$text text={{{ [<chinese>match[yes]then[为此插件评分]else[Rate this plugin]] }}}/></h4>
      <div class="cpl-rating-stars">
        <$let
          pluginTitle={{!!cpl.title}}
          statusTiddler={{{ [<currentTiddler>get[cpl.title]addprefix[$:/temp/CPL-Server/rating-status/]] }}}
        >
        <$button class="tc-btn-invisible cpl-rating-star-button" tooltip="1">
          <$action-setfield $tiddler=<<statusTiddler>> text="submitting" plugin-title=<<pluginTitle>>/>
          <$action-sendmessage $message="tm-http-request"
            url={{{ [[$:/temp/CPL-Server/api-base]get[text]addsuffix[/cpl/rate/]] [<pluginTitle>encodeuricomponent[]] +[join[]] }}}
            method="POST" header-Content-Type="application/json"
            body='{"rating":1}'
            var-pluginTitle=<<pluginTitle>>
            var-statusTiddler=<<statusTiddler>>
            oncompletion="""
              <$list filter='[<status>compare:number:gteq[200]compare:number:lt[300]]'>
              <$action-setfield $tiddler=<<statusTiddler>> text='success' plugin-title=<<pluginTitle>> average-rating={{{ [<data>jsonget[averageRating]else[0]] }}} total-ratings={{{ [<data>jsonget[totalRatings]else[0]] }}}/>
              <$action-sendmessage $message='tm-http-request'
                url={{{ [[$:/temp/CPL-Server/api-base]get[text]addsuffix[/cpl/stats/]] [<pluginTitle>encodeuricomponent[]] +[join[]] }}}
                method='GET'
                var-refreshPluginTitle=<<pluginTitle>>
                oncompletion='<$action-setfield $tiddler="$:/temp/CPL-Server/all-plugin-stats" text={{{ [[$:/temp/CPL-Server/all-plugin-stats]get[text]else[{"plugins":{}}]jsonset:json[plugins],<refreshPluginTitle>,<data>] }}} type="application/json"/>'/>
              </$list>
              <$list filter='[<status>compare:number:lt[200]] [<status>compare:number:gteq[300]] +[limit[1]]'>
              <$action-setfield $tiddler=<<statusTiddler>> text={{{ [<data>jsonget[error]!is[blank]] [<error>!is[blank]] [<statusText>!is[blank]] +[limit[1]addprefix[error: ]] }}} plugin-title=<<pluginTitle>>/>
              </$list>
              """/>
          <span class="cpl-rating-star">★</span>
        </$button>
        <$button class="tc-btn-invisible cpl-rating-star-button" tooltip="2">
          <$action-setfield $tiddler=<<statusTiddler>> text="submitting" plugin-title=<<pluginTitle>>/>
          <$action-sendmessage $message="tm-http-request"
            url={{{ [[$:/temp/CPL-Server/api-base]get[text]addsuffix[/cpl/rate/]] [<pluginTitle>encodeuricomponent[]] +[join[]] }}}
            method="POST" header-Content-Type="application/json"
            body='{"rating":2}'
            var-pluginTitle=<<pluginTitle>>
            var-statusTiddler=<<statusTiddler>>
            oncompletion="""
              <$list filter='[<status>compare:number:gteq[200]compare:number:lt[300]]'>
              <$action-setfield $tiddler=<<statusTiddler>> text='success' plugin-title=<<pluginTitle>> average-rating={{{ [<data>jsonget[averageRating]else[0]] }}} total-ratings={{{ [<data>jsonget[totalRatings]else[0]] }}}/>
              <$action-sendmessage $message='tm-http-request'
                url={{{ [[$:/temp/CPL-Server/api-base]get[text]addsuffix[/cpl/stats/]] [<pluginTitle>encodeuricomponent[]] +[join[]] }}}
                method='GET'
                var-refreshPluginTitle=<<pluginTitle>>
                oncompletion='<$action-setfield $tiddler="$:/temp/CPL-Server/all-plugin-stats" text={{{ [[$:/temp/CPL-Server/all-plugin-stats]get[text]else[{"plugins":{}}]jsonset:json[plugins],<refreshPluginTitle>,<data>] }}} type="application/json"/>'/>
              </$list>
              <$list filter='[<status>compare:number:lt[200]] [<status>compare:number:gteq[300]] +[limit[1]]'>
              <$action-setfield $tiddler=<<statusTiddler>> text={{{ [<data>jsonget[error]!is[blank]] [<error>!is[blank]] [<statusText>!is[blank]] +[limit[1]addprefix[error: ]] }}} plugin-title=<<pluginTitle>>/>
              </$list>
              """/>
          <span class="cpl-rating-star">★</span>
        </$button>
        <$button class="tc-btn-invisible cpl-rating-star-button" tooltip="3">
          <$action-setfield $tiddler=<<statusTiddler>> text="submitting" plugin-title=<<pluginTitle>>/>
          <$action-sendmessage $message="tm-http-request"
            url={{{ [[$:/temp/CPL-Server/api-base]get[text]addsuffix[/cpl/rate/]] [<pluginTitle>encodeuricomponent[]] +[join[]] }}}
            method="POST" header-Content-Type="application/json"
            body='{"rating":3}'
            var-pluginTitle=<<pluginTitle>>
            var-statusTiddler=<<statusTiddler>>
            oncompletion="""
              <$list filter='[<status>compare:number:gteq[200]compare:number:lt[300]]'>
              <$action-setfield $tiddler=<<statusTiddler>> text='success' plugin-title=<<pluginTitle>> average-rating={{{ [<data>jsonget[averageRating]else[0]] }}} total-ratings={{{ [<data>jsonget[totalRatings]else[0]] }}}/>
              <$action-sendmessage $message='tm-http-request'
                url={{{ [[$:/temp/CPL-Server/api-base]get[text]addsuffix[/cpl/stats/]] [<pluginTitle>encodeuricomponent[]] +[join[]] }}}
                method='GET'
                var-refreshPluginTitle=<<pluginTitle>>
                oncompletion='<$action-setfield $tiddler="$:/temp/CPL-Server/all-plugin-stats" text={{{ [[$:/temp/CPL-Server/all-plugin-stats]get[text]else[{"plugins":{}}]jsonset:json[plugins],<refreshPluginTitle>,<data>] }}} type="application/json"/>'/>
              </$list>
              <$list filter='[<status>compare:number:lt[200]] [<status>compare:number:gteq[300]] +[limit[1]]'>
              <$action-setfield $tiddler=<<statusTiddler>> text={{{ [<data>jsonget[error]!is[blank]] [<error>!is[blank]] [<statusText>!is[blank]] +[limit[1]addprefix[error: ]] }}} plugin-title=<<pluginTitle>>/>
              </$list>
              """/>
          <span class="cpl-rating-star">★</span>
        </$button>
        <$button class="tc-btn-invisible cpl-rating-star-button" tooltip="4">
          <$action-setfield $tiddler=<<statusTiddler>> text="submitting" plugin-title=<<pluginTitle>>/>
          <$action-sendmessage $message="tm-http-request"
            url={{{ [[$:/temp/CPL-Server/api-base]get[text]addsuffix[/cpl/rate/]] [<pluginTitle>encodeuricomponent[]] +[join[]] }}}
            method="POST" header-Content-Type="application/json"
            body='{"rating":4}'
            var-pluginTitle=<<pluginTitle>>
            var-statusTiddler=<<statusTiddler>>
            oncompletion="""
              <$list filter='[<status>compare:number:gteq[200]compare:number:lt[300]]'>
              <$action-setfield $tiddler=<<statusTiddler>> text='success' plugin-title=<<pluginTitle>> average-rating={{{ [<data>jsonget[averageRating]else[0]] }}} total-ratings={{{ [<data>jsonget[totalRatings]else[0]] }}}/>
              <$action-sendmessage $message='tm-http-request'
                url={{{ [[$:/temp/CPL-Server/api-base]get[text]addsuffix[/cpl/stats/]] [<pluginTitle>encodeuricomponent[]] +[join[]] }}}
                method='GET'
                var-refreshPluginTitle=<<pluginTitle>>
                oncompletion='<$action-setfield $tiddler="$:/temp/CPL-Server/all-plugin-stats" text={{{ [[$:/temp/CPL-Server/all-plugin-stats]get[text]else[{"plugins":{}}]jsonset:json[plugins],<refreshPluginTitle>,<data>] }}} type="application/json"/>'/>
              </$list>
              <$list filter='[<status>compare:number:lt[200]] [<status>compare:number:gteq[300]] +[limit[1]]'>
              <$action-setfield $tiddler=<<statusTiddler>> text={{{ [<data>jsonget[error]!is[blank]] [<error>!is[blank]] [<statusText>!is[blank]] +[limit[1]addprefix[error: ]] }}} plugin-title=<<pluginTitle>>/>
              </$list>
              """/>
          <span class="cpl-rating-star">★</span>
        </$button>
        <$button class="tc-btn-invisible cpl-rating-star-button" tooltip="5">
          <$action-setfield $tiddler=<<statusTiddler>> text="submitting" plugin-title=<<pluginTitle>>/>
          <$action-sendmessage $message="tm-http-request"
            url={{{ [[$:/temp/CPL-Server/api-base]get[text]addsuffix[/cpl/rate/]] [<pluginTitle>encodeuricomponent[]] +[join[]] }}}
            method="POST" header-Content-Type="application/json"
            body='{"rating":5}'
            var-pluginTitle=<<pluginTitle>>
            var-statusTiddler=<<statusTiddler>>
            oncompletion="""
              <$list filter='[<status>compare:number:gteq[200]compare:number:lt[300]]'>
              <$action-setfield $tiddler=<<statusTiddler>> text='success' plugin-title=<<pluginTitle>> average-rating={{{ [<data>jsonget[averageRating]else[0]] }}} total-ratings={{{ [<data>jsonget[totalRatings]else[0]] }}}/>
              <$action-sendmessage $message='tm-http-request'
                url={{{ [[$:/temp/CPL-Server/api-base]get[text]addsuffix[/cpl/stats/]] [<pluginTitle>encodeuricomponent[]] +[join[]] }}}
                method='GET'
                var-refreshPluginTitle=<<pluginTitle>>
                oncompletion='<$action-setfield $tiddler="$:/temp/CPL-Server/all-plugin-stats" text={{{ [[$:/temp/CPL-Server/all-plugin-stats]get[text]else[{"plugins":{}}]jsonset:json[plugins],<refreshPluginTitle>,<data>] }}} type="application/json"/>'/>
              </$list>
              <$list filter='[<status>compare:number:lt[200]] [<status>compare:number:gteq[300]] +[limit[1]]'>
              <$action-setfield $tiddler=<<statusTiddler>> text={{{ [<data>jsonget[error]!is[blank]] [<error>!is[blank]] [<statusText>!is[blank]] +[limit[1]addprefix[error: ]] }}} plugin-title=<<pluginTitle>>/>
              </$list>
              """/>
          <span class="cpl-rating-star">★</span>
        </$button>
        </$let>
      </div>
      <$let ratingStatusTiddler={{{ [<currentTiddler>get[cpl.title]addprefix[$:/temp/CPL-Server/rating-status/]] }}}>
        <$list filter="[<ratingStatusTiddler>is[tiddler]]" variable="hasStatus">
          <div class="cpl-status-line">
            <$list filter="[<ratingStatusTiddler>get[text]match[submitting]]">
              <span class="cpl-status-muted"><$text text={{{ [<chinese>match[yes]then[提交中...]else[Submitting...]] }}}/></span>
            </$list>
            <$list filter="[<ratingStatusTiddler>get[text]prefix[error:]]">
              <span class="cpl-status-error">✗ <$text text={{{ [<ratingStatusTiddler>get[text]removeprefix[error: ]] }}}/></span>
            </$list>
            <$list filter="[<ratingStatusTiddler>get[text]match[success]]">
              <span class="cpl-status-success">✓ <$text text={{{ [<chinese>match[yes]then[评分已提交！平均分：]else[Rating submitted! Average: ]] }}}/><$text text={{{ [<ratingStatusTiddler>get[average-rating]] }}}/>/5 (<$text text={{{ [<ratingStatusTiddler>get[total-ratings]] }}}/> <$text text={{{ [<chinese>match[yes]then[评分]else[ratings]] }}}/>)</span>
            </$list>
          </div>
        </$list>
      </$let>
    </div>
  </$list>
  <$list filter="[<userStatus>!match[authenticated]]" variable="isAnonymousForRating">
    <div class="cpl-rating-widget cpl-auth-required">
      <p class="cpl-status-muted"><$text text={{{ [<chinese>match[yes]then[登录后即可为插件评分。]else[Login to rate this plugin.]] }}}/></p>
      <$list filter="[<githubClientId>!is[blank]]" variable="hasGithubOAuth">
        <$button class="tc-btn-primary cpl-comment-login-button">
          <$action-sendmessage $message="cpl-github-login"/>
          <$text text={{{ [<chinese>match[yes]then[使用 GitHub 登录]else[Login with GitHub]] }}}/>
        </$button>
      </$list>
      <$list filter="[<githubClientId>is[blank]]" variable="missingGithubOAuth">
        <p class="cpl-status-muted"><$text text={{{ [<chinese>match[yes]then[GitHub 登录暂未配置。]else[GitHub login is not configured.]] }}}/></p>
      </$list>
    </div>
  </$list>
</$list>

<!-- Changelog Expandable Content -->
<$list filter="[<changelogPanelStateTitle>get[text]match[open]]" variable="showChangelogContent">
  <$list filter="[<changelogTiddler>is[tiddler]]" variable="hasChangelog">
    <$let hasChangelogField={{{ [<changelogTiddler>get[text]jsonget[hasChangelog]else[false]] }}} changelogContent={{{ [<changelogTiddler>get[text]jsonget[changelog]] }}}>
      <$list filter="[<hasChangelogField>match[true]]" variable="hasContent">
        <div class="cpl-code-panel">
          <$text text=<<changelogContent>> />
        </div>
      </$list>
    </$let>
  </$list>
</$list>

<!-- Compatibility Expandable Content -->
<$list filter="[<compatibilityPanelStateTitle>get[text]match[open]]" variable="showCompatibilityContent">
  <$tiddler tiddler=<<compatibilityTiddler>> >
  <$list filter="[<currentTiddler>is[tiddler]]" variable="hasCompatibility">
    <$let reportCount={{{ [<currentTiddler>get[text]jsonindexes[reports]count[]else[0]] }}}>
          <$list filter="[<reportCount>compare:integer:gt[0]]" variable="hasReports">
            <div class="cpl-compatibility-list">
              <$list filter="[<currentTiddler>get[text]jsonindexes[reports]]" variable="reportIndex">
                <$let report={{{ [<currentTiddler>get[text]jsonextract[reports],<reportIndex>] }}}>
                <div class="cpl-compatibility-item">
                  <div class="cpl-compatibility-header">
                    <span style="font-weight: 600; font-size: 0.9em;"><$text text={{{ [<chinese>match[yes]then[报告人：]else[Reported by ]] }}}/><$text text={{{ [<report>jsonget[reporterUsername]else[Anonymous]] }}} /></span>
                    <span class="cpl-compatibility-date cpl-status-muted"><$text text={{{ [<report>jsonget[createdAt]else[Unknown]] }}} /></span>
                  </div>
                  <$list filter="[<report>jsonget[twVersionMin]!is[blank]] [<report>jsonget[twVersionMax]!is[blank]] +[unique[]limit[1]]" variable="hasVersionRange">
                    <div class="cpl-compatibility-meta">
                      <strong><$text text={{{ [<chinese>match[yes]then[TW 版本：]else[TW Version:]] }}}/></strong> <$text text={{{ [<report>jsonget[twVersionMin]else[Any]] }}} /> - <$text text={{{ [<report>jsonget[twVersionMax]else[Any]] }}} />
                    </div>
                  </$list>
                  <$list filter="[<report>jsonget[conflictingPlugins]count[]compare:integer:gt[0]]" variable="hasConflicts">
                    <div class="cpl-compatibility-meta">
                      <strong><$text text={{{ [<chinese>match[yes]then[冲突插件：]else[Conflicts with:]] }}}/></strong>
                      <$list filter="[<report>jsonindexes[conflictingPlugins]]" variable="conflictIndex">
                        <$let conflict={{{ [<report>jsonextract[conflictingPlugins],<conflictIndex>] }}}>
                        <span class="cpl-compatibility-pill">
                          <$text text={{{ [<conflict>jsonget[pluginTitle]else[Unknown]] }}} />
                        </span>
                        </$let>
                      </$list>
                    </div>
                  </$list>
                  <div class="cpl-compatibility-description">
                    <$text text={{{ [<report>jsonget[description]] }}} />
                  </div>
                </div>
                </$let>
              </$list>
            </div>
          </$list>
        </$let>
      </$list>
      </$tiddler>

      <$list filter="[<userStatus>match[authenticated]]" variable="isLoggedInForCompatibility">
        <!-- Submit Compatibility Report Form -->
        <div class="cpl-form-section">
          <h5 style="margin-top: 0;"><$text text={{{ [<chinese>match[yes]then[提交兼容性报告]else[Submit a Compatibility Report]] }}}/></h5>
          <$let
            pluginTitle={{!!cpl.title}}
            draftTiddler={{{ [<currentTiddler>get[cpl.title]addprefix[$:/temp/CPL-Server/compatibility-draft/]] }}}
            statusTiddler={{{ [<currentTiddler>get[cpl.title]addprefix[$:/temp/CPL-Server/compatibility-status/]] }}}
          >
            <!-- Initialize draft tiddler if not exists -->
            <$list filter="[<draftTiddler>!is[tiddler]]">
              <$action-setfield $tiddler=<<draftTiddler>> text="" />
            </$list>

            <div style="display: flex; flex-direction: column; gap: 8px;">
              <div class="cpl-form-row">
                <div class="cpl-form-field">
                  <label class="cpl-form-label cpl-status-muted"><$text text={{{ [<chinese>match[yes]then[TW 最低版本]else[TW Min Version]] }}}/></label>
                  <$edit-text tiddler=<<draftTiddler>> field="tw-version-min" default="" placeholder="e.g. 5.2.0" class="cpl-form-input" />
                </div>
                <div class="cpl-form-field">
                  <label class="cpl-form-label cpl-status-muted"><$text text={{{ [<chinese>match[yes]then[TW 最高版本]else[TW Max Version]] }}}/></label>
                  <$edit-text tiddler=<<draftTiddler>> field="tw-version-max" default="" placeholder="e.g. 5.3.0" class="cpl-form-input" />
                </div>
              </div>

              <div>
                <label class="cpl-form-label cpl-status-muted"><$text text={{{ [<chinese>match[yes]then[冲突插件标题]else[Conflicting Plugin Title]] }}}/></label>
                <$edit-text tiddler=<<draftTiddler>> field="conflict-plugin" default="" placeholder="e.g. $:/plugins/tiddlywiki/highlight" class="cpl-form-input" />
              </div>

              <div>
                <label class="cpl-form-label cpl-status-muted"><$text text={{{ [<chinese>match[yes]then[冲突说明]else[Conflict Description]] }}}/></label>
                <$edit-text tiddler=<<draftTiddler>> field="conflict-description" default="" placeholder={{{ [<chinese>match[yes]then[描述这个冲突...]else[Describe the conflict...]] }}} class="cpl-form-input" />
              </div>

              <div>
                <label class="cpl-form-label cpl-status-muted"><$text text={{{ [<chinese>match[yes]then[详细说明 *]else[Detailed Description *]] }}}/></label>
                <$edit-text tiddler=<<draftTiddler>> field="description" default="" placeholder={{{ [<chinese>match[yes]then[详细描述兼容性问题...]else[Describe the compatibility issue in detail...]] }}} class="cpl-form-input cpl-form-textarea" />
              </div>

              <$let
                twVersionMin={{{ [<draftTiddler>get[tw-version-min]] }}}
                twVersionMax={{{ [<draftTiddler>get[tw-version-max]] }}}
                conflictPlugin={{{ [<draftTiddler>get[conflict-plugin]] }}}
                conflictDescription={{{ [<draftTiddler>get[conflict-description]] }}}
                description={{{ [<draftTiddler>get[description]] }}}
              >
              <$let requestBody={{{ [[{}]jsonset[description],<description>] }}}>
              <$let requestBody={{{ [<twVersionMin>!is[blank]then<requestBody>jsonset[twVersionMin],<twVersionMin>] [<twVersionMin>is[blank]then<requestBody>] +[first[]] }}}>
              <$let requestBody={{{ [<twVersionMax>!is[blank]then<requestBody>jsonset[twVersionMax],<twVersionMax>] [<twVersionMax>is[blank]then<requestBody>] +[first[]] }}}>
              <$let conflictJson={{{ [[{}]jsonset[pluginTitle],<conflictPlugin>jsonset[description],<conflictDescription>] }}}>
              <$let requestBody={{{ [<conflictPlugin>!is[blank]then<requestBody>jsonset:array[conflictingPlugins]jsonset:json[conflictingPlugins],[0],<conflictJson>] [<conflictPlugin>is[blank]then<requestBody>] +[first[]] }}}>
              <$button class="tc-btn-primary cpl-submit-button-sm">
                <$action-setfield $tiddler=<<statusTiddler>> text="submitting" />
                <$action-sendmessage $message="tm-http-request"
                  url={{{ [[$:/temp/CPL-Server/api-base]get[text]addsuffix[/cpl/compatibility/]] [<pluginTitle>encodeuricomponent[]] +[join[]] }}}
                  method="POST" header-Content-Type="application/json"
                  body=<<requestBody>>
                  var-pluginTitle=<<pluginTitle>>
                  var-statusTiddler=<<statusTiddler>>
                  var-draftTiddler=<<draftTiddler>>
                  oncompletion="""
                    <$list filter='[<status>compare:number:gteq[200]compare:number:lt[300]]'>
                    <$action-setfield $tiddler=<<statusTiddler>> text='success'/>
                    <$action-deletetiddler $tiddler=<<draftTiddler>>/>
                    <$action-sendmessage $message='tm-http-request'
                      url={{{ [[$:/temp/CPL-Server/api-base]get[text]addsuffix[/cpl/compatibility/]] [<pluginTitle>encodeuricomponent[]] +[join[]] }}}
                      method='GET'
                      var-refreshTiddler={{{ [<pluginTitle>addprefix[$:/temp/CPL-Server/compatibility/]] }}}
                      var-refreshPluginTitle=<<pluginTitle>>
                      oncompletion='<$action-setfield $tiddler=<<refreshTiddler>> text=<<data>> type="application/json" plugin-title=<<refreshPluginTitle>>/>'/>
                    </$list>
                    <$list filter='[<status>compare:number:lt[200]] [<status>compare:number:gteq[300]] +[limit[1]]'>
                    <$action-setfield $tiddler=<<statusTiddler>> text={{{ [<data>jsonget[error]!is[blank]] [<error>!is[blank]] [<statusText>!is[blank]] +[limit[1]addprefix[error: ]] }}}/>
                    </$list>
                    """/>
                <$text text={{{ [<chinese>match[yes]then[提交报告]else[Submit Report]] }}}/>
              </$button>
              </$let>
              </$let>
              </$let>
              </$let>
              </$let>
              </$let>
            </div>

            <!-- Status messages -->
            <$list filter="[<statusTiddler>is[tiddler]]" variable="hasStatus">
              <div class="cpl-status-line">
                <$list filter="[<statusTiddler>get[text]match[submitting]]">
                  <span class="cpl-status-muted"><$text text={{{ [<chinese>match[yes]then[提交中...]else[Submitting...]] }}}/></span>
                </$list>
                <$list filter="[<statusTiddler>get[text]prefix[error:]]">
                  <span class="cpl-status-error">✗ <$text text={{{ [<statusTiddler>get[text]removeprefix[error: ]] }}}/></span>
                </$list>
                <$list filter="[<statusTiddler>get[text]match[success]]">
                  <span class="cpl-status-success">✓ <$text text={{{ [<chinese>match[yes]then[报告已提交！]else[Report submitted!]] }}}/></span>
                </$list>
              </div>
            </$list>
          </$let>
        </div>
      </$list>
      <$list filter="[<userStatus>!match[authenticated]]" variable="isAnonymousForCompatibility">
        <div class="cpl-form-section cpl-auth-required">
          <p class="cpl-status-muted"><$text text={{{ [<chinese>match[yes]then[登录后即可提交兼容性报告。]else[Login to submit a compatibility report.]] }}}/></p>
          <$list filter="[<githubClientId>!is[blank]]" variable="hasGithubOAuth">
            <$button class="tc-btn-primary cpl-comment-login-button">
              <$action-sendmessage $message="cpl-github-login"/>
              <$text text={{{ [<chinese>match[yes]then[使用 GitHub 登录]else[Login with GitHub]] }}}/>
            </$button>
          </$list>
          <$list filter="[<githubClientId>is[blank]]" variable="missingGithubOAuth">
            <p class="cpl-status-muted"><$text text={{{ [<chinese>match[yes]then[GitHub 登录暂未配置。]else[GitHub login is not configured.]] }}}/></p>
          </$list>
        </div>
      </$list>
    </$list>
  </$list>
<!-- End server mirror check -->

</$let>
</$list>
