Refactor announcement feature
This commit is contained in:
		@@ -612,4 +612,31 @@ $(document).ready(function() {
 | 
			
		||||
    // Repo
 | 
			
		||||
    window.location = 'https://github.com/freecodecamp/freecodecamp/';
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  (function getFlyer() {
 | 
			
		||||
    const flyerKey = '__flyerId__';
 | 
			
		||||
    $.ajax({
 | 
			
		||||
      url: '/api/flyers/findOne',
 | 
			
		||||
      method: 'GET',
 | 
			
		||||
      dataType: 'JSON',
 | 
			
		||||
      data: { filter: { order: 'id DESC' } }
 | 
			
		||||
    })
 | 
			
		||||
    // log error
 | 
			
		||||
    .fail(err => console.error(err))
 | 
			
		||||
    .done(flyer => {
 | 
			
		||||
      const lastFlyerId = localStorage.getItem(flyerKey);
 | 
			
		||||
      if (
 | 
			
		||||
        !flyer ||
 | 
			
		||||
        !flyer.isActive ||
 | 
			
		||||
        lastFlyerId === flyer.id
 | 
			
		||||
      ) {
 | 
			
		||||
        return;
 | 
			
		||||
      }
 | 
			
		||||
      $('#dismiss-bill').on('click', () => {
 | 
			
		||||
        localStorage.setItem(flyerKey, flyer.id);
 | 
			
		||||
      });
 | 
			
		||||
      $('#bill-content').html(flyer.message);
 | 
			
		||||
      $('#bill-board').fadeIn();
 | 
			
		||||
    });
 | 
			
		||||
  }());
 | 
			
		||||
});
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										34
									
								
								common/models/flyer.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								common/models/flyer.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "flyer",
 | 
			
		||||
  "base": "PersistedModel",
 | 
			
		||||
  "idInjection": true,
 | 
			
		||||
  "trackChanges": false,
 | 
			
		||||
  "properties": {
 | 
			
		||||
    "message": {
 | 
			
		||||
      "type": "string"
 | 
			
		||||
    },
 | 
			
		||||
    "isActive": {
 | 
			
		||||
      "type": "boolean",
 | 
			
		||||
      "default": true
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "validations": [],
 | 
			
		||||
  "relations": {
 | 
			
		||||
 | 
			
		||||
  },
 | 
			
		||||
  "acls": [
 | 
			
		||||
    {
 | 
			
		||||
      "accessType": "*",
 | 
			
		||||
      "principalType": "ROLE",
 | 
			
		||||
      "principalId": "$everyone",
 | 
			
		||||
      "permission": "DENY"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "accessType": "READ",
 | 
			
		||||
      "principalType": "ROLE",
 | 
			
		||||
      "principalId": "$everyone",
 | 
			
		||||
      "permission": "ALLOW"
 | 
			
		||||
    }
 | 
			
		||||
  ],
 | 
			
		||||
  "methods": []
 | 
			
		||||
}
 | 
			
		||||
@@ -66,5 +66,9 @@
 | 
			
		||||
  "userIdentity": {
 | 
			
		||||
    "dataSource": "db",
 | 
			
		||||
    "public": true
 | 
			
		||||
  },
 | 
			
		||||
  "flyer": {
 | 
			
		||||
    "dataSource": "db",
 | 
			
		||||
    "public": true
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
extends ../layout
 | 
			
		||||
block content
 | 
			
		||||
    include ../partials/flyer
 | 
			
		||||
    script(src="/bower_components/cal-heatmap/cal-heatmap.min.js")
 | 
			
		||||
    script.
 | 
			
		||||
        var challengeName = 'Profile View';
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,7 @@ block content
 | 
			
		||||
    link(rel='stylesheet', href='/bower_components/CodeMirror/addon/lint/lint.css')
 | 
			
		||||
    link(rel='stylesheet', href='/bower_components/CodeMirror/theme/monokai.css')
 | 
			
		||||
    link(rel='stylesheet', href='/css/ubuntu.css')
 | 
			
		||||
    include ../partials/flyer
 | 
			
		||||
    .row
 | 
			
		||||
        .col-md-4.col-lg-3
 | 
			
		||||
            .scroll-locker(id = "scroll-locker")
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,7 @@ block content
 | 
			
		||||
    link(rel='stylesheet', href='/bower_components/CodeMirror/addon/lint/lint.css')
 | 
			
		||||
    link(rel='stylesheet', href='/bower_components/CodeMirror/theme/monokai.css')
 | 
			
		||||
    link(rel='stylesheet', href='/css/ubuntu.css')
 | 
			
		||||
    include ../partials/flyer
 | 
			
		||||
    .row
 | 
			
		||||
        .col-md-3.col-lg-3
 | 
			
		||||
            .scroll-locker(id = "scroll-locker")
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,7 @@ block content
 | 
			
		||||
    link(rel='stylesheet', href='/bower_components/CodeMirror/addon/lint/lint.css')
 | 
			
		||||
    link(rel='stylesheet', href='/bower_components/CodeMirror/theme/monokai.css')
 | 
			
		||||
    link(rel='stylesheet', href='/css/ubuntu.css')
 | 
			
		||||
    include ../partials/flyer
 | 
			
		||||
    .row
 | 
			
		||||
        .col-md-4.col-lg-3
 | 
			
		||||
            .scroll-locker(id = "scroll-locker")
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
extends ../layout-wide
 | 
			
		||||
block content
 | 
			
		||||
    include ../partials/flyer
 | 
			
		||||
    .row
 | 
			
		||||
        .col-md-8.col-md-offset-2
 | 
			
		||||
            for step, index in description
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
extends ../layout-wide
 | 
			
		||||
block content
 | 
			
		||||
    include ../partials/flyer
 | 
			
		||||
    .row
 | 
			
		||||
        .col-xs-12.col-sm-12.col-md-4
 | 
			
		||||
            h4.text-center.challenge-instructions-title= name
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
extends ../layout-wide
 | 
			
		||||
block content
 | 
			
		||||
    include ../partials/flyer
 | 
			
		||||
    .row
 | 
			
		||||
        .col-md-4
 | 
			
		||||
            h4.text-center.challenge-instructions-title= name
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,7 @@ html(lang='en')
 | 
			
		||||
  body.top-and-bottom-margins
 | 
			
		||||
    include partials/scripts
 | 
			
		||||
    include partials/navbar
 | 
			
		||||
    .container
 | 
			
		||||
    include partials/flash
 | 
			
		||||
    .container
 | 
			
		||||
      block content
 | 
			
		||||
    include partials/footer
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,5 @@
 | 
			
		||||
.row.flashMessage
 | 
			
		||||
.container
 | 
			
		||||
    .row.flashMessage.negative-30
 | 
			
		||||
        .col-xs-12
 | 
			
		||||
            if (messages.errors || messages.error)
 | 
			
		||||
              .alert.alert-danger.fade.in
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										8
									
								
								server/views/partials/flyer.jade
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								server/views/partials/flyer.jade
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
if (user && user.points > 5)
 | 
			
		||||
    .container
 | 
			
		||||
        .row.flashMessage.negative-30
 | 
			
		||||
            .col-xs-12
 | 
			
		||||
                #bill-board.alert.alert-info.fade.in(style='display: none;')
 | 
			
		||||
                    button.close(type='button', data-dismiss='alert')
 | 
			
		||||
                        span.ion-close-circled#dismiss-bill
 | 
			
		||||
                    #bill-content
 | 
			
		||||
		Reference in New Issue
	
	Block a user