<commit_before># coding=utf-8
from __future__ import absolute_import

__author__ = "<NAME> <<EMAIL>>"
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
__copyright__ = "Copyright (C) 2016 The OctoPrint Project - Released under terms of the AGPLv3 License"


import octoprint.plugin

import calendar
import codecs
import os
import re
import time
import threading

import feedparser
import flask

from octoprint.server import admin_permission
from octoprint.server.util.flask import restricted_access
from flask.ext.babel import gettext

class AnnouncementPlugin(octoprint.plugin.AssetPlugin,
                         octoprint.plugin.SettingsPlugin,
                         octoprint.plugin.BlueprintPlugin,
                         octoprint.plugin.StartupPlugin,
                         octoprint.plugin.TemplatePlugin):

	def __init__(self):
		self._cached_channel_configs = None
		self._cached_channel_configs_mutex = threading.RLock()

		from slugify import Slugify
		self._slugify = Slugify()
		self._slugify.safe_chars = "-_."

	# StartupPlugin

	def on_after_startup(self):
		self._fetch_all_channels()

	# SettingsPlugin

	def get_settings_defaults(self):
		return dict(channels=dict(_important=dict(name="Important OctoPrint Announcements",
		                                          priority=1,
		                                          type="rss",
		                                          url="http://octoprint.org/feeds/important.xml",
		                                          read_until=1449446400),
		                          _releases=dict(name="OctoPrint Release Announcements",
		                                         priority=2,
		                                         type="rss",
		                                         url="http://octoprint.org/feeds/releases.xml"),
		                          _spotlight=dict(name="OctoPrint Community Spotlights",
		                                          priority=2,
		                                          type="rss",
		                                          url="http://octoprint.org/feeds/spotlight.xml"),
		                          _octopi=dict(name="OctoPi Announcements",
		                                       priority=2,
		                                       type="rss",
		                                       url="http://octoprint.org/feeds/octopi.xml"),
		                          _plugins=dict(name="New Plugins in the Repository",
		                                        priority=2,
		                                        type="rss",
		                                        url="http://plugins.octoprint.org/feed.xml")),
		            enabled_channels=[],
		            #forced_channels=["_important"],
					forced_channels=[], #tan
		            ttl=6*60,
					#display_limit=3,
		            display_limit=0, #tan
		            summary_limit=300)

	# AssetPlugin

	def get_assets(self):
		return dict(js=["js/announcements.js"],
		            less=["less/announcements.less"],
		            css=["css/announcements.css"])

	# Template Plugin

	def get_template_configs(self):
		return [
			dict(type="settings", name=gettext("Announcements"), template="announcements_settings.jinja2", custom_bindings=True),
			dict(type="navbar", template="announcements_navbar.jinja2", styles=["display: none"], data_bind="visible: loginState.isAdmin")
		]

	# Blueprint Plugin

	@octoprint.plugin.BlueprintPlugin.route("/channels", methods=["GET"])
	@restricted_access<commit_msg>change defaults in setting.py -disable plugins announcements<commit_after># coding=utf-8
from __future__ import absolute_import

__author__ = "<NAME> <<EMAIL>>"
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
__copyright__ = "Copyright (C) 2016 The OctoPrint Project - Released under terms of the AGPLv3 License"


import octoprint.plugin

import calendar
import codecs
import os
import re
import time
import threading

import feedparser
import flask

from octoprint.server import admin_permission
from octoprint.server.util.flask import restricted_access
from flask.ext.babel import gettext

class AnnouncementPlugin(octoprint.plugin.AssetPlugin,
                         octoprint.plugin.SettingsPlugin,
                         octoprint.plugin.BlueprintPlugin,
                         octoprint.plugin.StartupPlugin,
                         octoprint.plugin.TemplatePlugin):

	def __init__(self):
		self._cached_channel_configs = None
		self._cached_channel_configs_mutex = threading.RLock()

		from slugify import Slugify
		self._slugify = Slugify()
		self._slugify.safe_chars = "-_."

	# StartupPlugin

	def on_after_startup(self):
		self._fetch_all_channels()

	# SettingsPlugin

	def get_settings_defaults(self):
		'''
		return dict(channels=dict(_important=dict(name="Important OctoPrint Announcements",
		                                          priority=1,
		                                          type="rss",
		                                          url="http://octoprint.org/feeds/important.xml",
		                                          read_until=1449446400),
		                          _releases=dict(name="OctoPrint Release Announcements",
		                                         priority=2,
		                                         type="rss",
		                                         url="http://octoprint.org/feeds/releases.xml"),
		                          _spotlight=dict(name="OctoPrint Community Spotlights",
		                                          priority=2,
		                                          type="rss",
		                                          url="http://octoprint.org/feeds/spotlight.xml"),
		                          _octopi=dict(name="OctoPi Announcements",
		                                       priority=2,
		                                       type="rss",
		                                       url="http://octoprint.org/feeds/octopi.xml"),
		                          _plugins=dict(name="New Plugins in the Repository",
		                                        priority=2,
		                                        type="rss",
		                                        url="http://plugins.octoprint.org/feed.xml")),
		            enabled_channels=[],
		            #forced_channels=["_important"],
					forced_channels=[], #tan
		            ttl=6*60,
					#display_limit=3,
		            display_limit=0, #tan
		            summary_limit=300)
		'''

	# AssetPlugin

	def get_assets(self):
		return dict(js=["js/announcements.js"],
		            less=["less/announcements.less"],
		            css=["css/announcements.css"])

	# Template Plugin

	def get_template_configs(self):
		return [
			dict(type="settings", name=gettext("Announcements"), template="announcements_settings.jinja2", custom_bindings=True),
			dict(type="navbar", template="announcements_navbar.jinja2", styles=["display: none"], data_bind="visible: loginState.isAdmin")
		]

	# Blueprint Plugin

	@octoprint.plugin.BlueprintPlugin.route("/channels", methods=["GET"])
	@restricted_access
{'fraction_non_alphanumeric': 0.09547950992817913, 'fraction_numerical': 0.008731164624700746, 'mean_word_length': 1.6932119833143724, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 10}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 52, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3099764', 'n_tokens_mistral': 2013, 'n_tokens_neox': 1759, 'n_words': 315}