Ver código fonte

added "TMPLT" label

sou 7 anos atrás
pai
commit
bd925a1e3a

+ 12 - 0
lib/models/page.js

@@ -28,6 +28,14 @@ module.exports = function(crowi) {
     return false;
     return false;
   }
   }
 
 
+  function isTemplatePath(path) {
+    if (path.match(/.*\/_{1,2}template$/)) {
+      return true;
+    }
+
+    return false;
+  }
+
   pageSchema = new mongoose.Schema({
   pageSchema = new mongoose.Schema({
     path: { type: String, required: true, index: true, unique: true },
     path: { type: String, required: true, index: true, unique: true },
     revision: { type: ObjectId, ref: 'Revision' },
     revision: { type: ObjectId, ref: 'Revision' },
@@ -96,6 +104,10 @@ module.exports = function(crowi) {
     return isPortalPath(this.path);
     return isPortalPath(this.path);
   };
   };
 
 
+  pageSchema.methods.isTemplate = function() {
+    return isTemplatePath(this.path);
+  };
+
   pageSchema.methods.isCreator = function(userData) {
   pageSchema.methods.isCreator = function(userData) {
     // ゲスト閲覧の場合は userData に false が入る
     // ゲスト閲覧の場合は userData に false が入る
     if (!userData) {
     if (!userData) {

+ 4 - 0
lib/views/widget/page_list.html

@@ -19,6 +19,10 @@
       <span class="label label-info">PORTAL</span>
       <span class="label label-info">PORTAL</span>
     {% endif  %}
     {% endif  %}
 
 
+    {% if page.isTemplate() %}
+      <span class="label label-info">TMPLT</span>
+    {% endif  %}
+
     {% if page.commentCount > 0 %}
     {% if page.commentCount > 0 %}
     <span>
     <span>
       <i class="icon-bubble"></i>{{ page.commentCount }}
       <i class="icon-bubble"></i>{{ page.commentCount }}

+ 15 - 0
resource/js/components/PageList/PageListMeta.js

@@ -11,6 +11,14 @@ export default class PageListMeta extends React.Component {
     return false;
     return false;
   }
   }
 
 
+  isTemplatePath(path) {
+    if (path.match(/.*\/_{1,2}template$/)) {
+      return true;
+    }
+
+    return false;
+  }
+
   render() {
   render() {
     // TODO isPortal()
     // TODO isPortal()
     const page = this.props.page;
     const page = this.props.page;
@@ -21,6 +29,12 @@ export default class PageListMeta extends React.Component {
       PortalLabel = <span className="label label-info">PORTAL</span>;
       PortalLabel = <span className="label label-info">PORTAL</span>;
     }
     }
 
 
+    // template check
+    let TemplateLabel;
+    if (this.isPortalPath(page.path)) {
+      TemplateLabel = <span className="label label-info">TMPLT</span>;
+    }
+
     let CommentCount;
     let CommentCount;
     if (page.commentCount > 0) {
     if (page.commentCount > 0) {
       CommentCount = <span><i className="icon-bubble" />{page.commentCount}</span>;
       CommentCount = <span><i className="icon-bubble" />{page.commentCount}</span>;
@@ -35,6 +49,7 @@ export default class PageListMeta extends React.Component {
     return (
     return (
       <span className="page-list-meta">
       <span className="page-list-meta">
         {PortalLabel}
         {PortalLabel}
+        {TemplateLabel}
         {CommentCount}
         {CommentCount}
         {LikerCount}
         {LikerCount}
       </span>
       </span>