#247 Make the news box optional
Merged 6 years ago by clime. Opened 6 years ago by frostyx.
copr/ frostyx/copr blog-url  into  master

@@ -115,3 +115,7 @@ 

  #   # Description sometimes put into template to make clear what we point to

  #   'user_desc': 'FAS account'

  # }

+ 

+ 

+ NEWS_URL = "https://fedora-copr.github.io/"

+ NEWS_FEED_URL = "https://fedora-copr.github.io/feed.xml"

@@ -67,6 +67,10 @@ 

          'user_desc': 'fas'

      }

  

+     # Optional, news box shows only when both variables are configured

+     NEWS_URL = "https://fedora-copr.github.io/"

+     NEWS_FEED_URL = "https://fedora-copr.github.io/feed.xml"

+ 

  

  class ProductionConfig(Config):

      DEBUG = False

@@ -1,7 +1,8 @@ 

  // https://stackoverflow.com/a/10943610/3285282

  

- $(document).ready(function(){

-     $.get("https://fedora-copr.github.io/feed.xml", function (data) {

+ function show_last_article(feed_url){

+ 

+     $.get(feed_url, function (data) {

  

          // https://stackoverflow.com/a/10996297/3285282

          Date.prototype.getMonthName = function() {
@@ -25,4 +26,4 @@ 

              return false

          });

      });

- });

+ };

@@ -336,9 +336,10 @@ 

  

  

  {% macro recent_blog_panel() %}

+   {% if config.NEWS_URL and config.NEWS_FEED_URL %}

    <div class="panel panel-default">

      <div class="panel-heading">

-       <h3 class="panel-title">News - <a href="https://fedora-copr.github.io/">Read All</a></h3>

+       <h3 class="panel-title">News - <a href="{{ config.NEWS_URL }}">Read All</a></h3>

      </div>

      <div class="list-group">

        <noscript>
@@ -362,6 +363,7 @@ 

        </a>

      </div>

    </div>

+   {% endif %}

  {% endmacro %}

  

  

@@ -153,7 +153,14 @@ 

    {% endif %}

  

    <!-- Last post from our blog -->

+   {% if config.NEWS_URL and config.NEWS_FEED_URL %}

    <script src="{{ url_for('static', filename='js/blog.js') }}"></script>

+   <script>

+     $(document).ready(function(){

+       show_last_article( "{{ config.NEWS_FEED_URL }}" )

+     });

+   </script>

+   {% endif %}

  

    {% block footer %}{% endblock %}

  </body>