瀏覽代碼

Abandoned flag

Added abandoned and replacementPackage properties to package
Added visual queue to abandoned packages in view and list.
Rafael Dohms 10 年之前
父節點
當前提交
b180d7e48c

+ 44 - 0
src/Packagist/WebBundle/Entity/Package.php

@@ -111,6 +111,18 @@ class Package
      */
     private $autoUpdated = false;
 
+    /**
+     * @var bool
+     * @ORM\Column(type="boolean")
+     */
+    private $abandoned = false;
+
+    /**
+     * @var string
+     * @ORM\Column(type="string", length=255, nullable=true)
+     */
+    private $replacementPackage;
+
     /**
      * @ORM\Column(type="boolean", options={"default"=false})
      */
@@ -549,4 +561,36 @@ class Package
     {
         return $this->updateFailureNotified;
     }
+
+    /**
+     * @return boolean
+     */
+    public function isAbandoned()
+    {
+        return $this->abandoned;
+    }
+
+    /**
+     * @param boolean $abandoned
+     */
+    public function setAbandoned($abandoned)
+    {
+        $this->abandoned = $abandoned;
+    }
+
+    /**
+     * @return string
+     */
+    public function getReplacementPackage()
+    {
+        return $this->replacementPackage;
+    }
+
+    /**
+     * @param string $replacementPackage
+     */
+    public function setReplacementPackage($replacementPackage)
+    {
+        $this->replacementPackage = $replacementPackage;
+    }
 }

+ 7 - 0
src/Packagist/WebBundle/Resources/public/css/main.css

@@ -333,6 +333,13 @@ ul.packages h1 .metadata {
   margin-right: 10px;
 }
 
+ul.packages .abandoned {
+  float: right;
+  color: #800;
+  font-size: 12px;
+  margin-right: 10px;
+}
+
 ul.packages li {
     background: none repeat scroll 0 0 #EEEEEE;
     border: 1px solid #BBBBBB;

+ 10 - 0
src/Packagist/WebBundle/Resources/views/Web/viewPackage.html.twig

@@ -56,6 +56,16 @@
                 <p class="warning">This package is not auto-updated. Go and set up the <a href="{{ path('fos_user_profile_show') }}">GitHub Service Hook</a> for Packagist so that it gets updated whenever you push!</p>
             {% endif %}
 
+            {% if package.abandoned %}
+                <p class="warning">
+                    This package is <strong>abandoned</strong> and no longer maintained.
+                    {% if package.replacementPackage is not empty %}
+                        The author suggests using the <a href="{{ path('view_package', {name: package.replacementPackage}) }}">{{ package.replacementPackage }}</a> package instead.
+                    {% else %}
+                        No replacement package was suggested.
+                    {% endif %}
+                </p>
+            {% endif %}
             {% if package.updateFailureNotified
                 and app.user and (package.maintainers.contains(app.user) or is_granted('ROLE_UPDATE_PACKAGES'))
             %}

+ 6 - 0
src/Packagist/WebBundle/Resources/views/macros.html.twig

@@ -14,9 +14,15 @@
                         </span>
                     {% endif %}
                 </h1>
+                {% if package.abandoned %}
+                <span class="abandoned">
+                    <i class="icon-warning-sign"></i> Abandoned! {% if package.replacementPackage is not empty %}Use: <a href="{{ path('view_package', {name: package.replacementPackage}) }}">{{ package.replacementPackage }}</a>{% endif %}
+                </span>
+                {% endif %}
                 {% if package.description is defined and package.description %}
                     <p class="package-description">{{ package.description }}</p>
                 {% endif %}
+
             </li>
         {% endfor %}