Jelajahi Sumber

sources+categories

David 10 tahun lalu
induk
melakukan
18e943a354
4 mengubah file dengan 31 tambahan dan 6 penghapusan
  1. 11 3
      front/js/app.js
  2. 8 0
      front/main.html
  3. 11 2
      front/sources.html
  4. 1 1
      front/style.css

+ 11 - 3
front/js/app.js

@@ -21,19 +21,25 @@ app.config(function($routeProvider, $locationProvider) {
 app.controller('sources', function($scope,$http) {
 	$scope.sources=[];
 	$scope.parsed_articles=[];
+	$scope.sourceCategory=1;
+	var categories = ["PR","News"];
 	$http.get("/pymnts/sources").then(
 		function(data){
-			$scope.sources=data.data.sources;
+			$scope.sources=data.data.sources.map(
+				function(e){
+					e.category=categories[e.category];
+					return e;
+				});
 		},
 		function(data){
 		}
 	);
-	$scope.parseSource = function(source,name,sel,rss,add) {
+	$scope.parseSource = function(source,name,sel,rss,category, add) {
 		url="/pymnts/source/test/";
 		if(add==1)
 			url="/pymnts/source/add/";
 
-		$http.post(url, { "source": source, "selector":sel, "rss":rss, "name":name }).then(
+		$http.post(url, { "source": source, "selector":sel, "rss":rss, "name":name, "category": category }).then(
 			function(data) {
 				if(!add)
 					$scope.parsed_articles=data.data.links;
@@ -45,6 +51,7 @@ app.controller('sources', function($scope,$http) {
 	
 });
 app.controller('main', function($scope,$http,$sce) {
+	$scope.category="-1";
 	$scope.news=[];
 	$scope.newsArticle="";
 	$scope.curPage=1;
@@ -88,6 +95,7 @@ app.controller('main', function($scope,$http,$sce) {
 										"keyword":kw,
 										"minweight":$scope.minweight,
 										"title":$scope.title,
+										"category":$scope.category,
 										"page":page}).then(
 			function(data) {
 				if(page==undefined)

+ 8 - 0
front/main.html

@@ -15,6 +15,14 @@
 						<label for="title">Article Title</label>
 						<input ng-model="title" type="text">
 					</li>
+					<li>
+						<label for="category">Category</label>
+						<select ng-model="category" value="-1">
+							<option value="-1">--</option>
+							<option value="0">Press Releases</option>
+							<option value="1">News</option>
+						</select>
+					</li>
 					<li>
 						<label for="site">Site</label>
 						<input ng-model="site" type="text">

+ 11 - 2
front/sources.html

@@ -1,5 +1,6 @@
 	<div ng-controller="main" class="wrapper">
 		<aside class="sidebar">
+		<!--
 				<form class="filter">
 				<ul>
 					<li>
@@ -13,6 +14,13 @@
 					<label for="title">Name</label>
 					<input type="text" ng-model="sourceName" class="form-control" placeholder="name">
 				</li>
+				<li>
+					<label for="title">Category</label>
+					<select ng-model="sourceCategory" value="-1">
+						<option value=0 selected>Press Releases</option>
+						<option value=1>News</option>
+					</select>
+				</li>
 				<li>
 					<label for="title">RSS</label>
 					<input type="number" ng-model="sourceRSS" class="form-control" value="0" ng-min="0" ng-max="1">
@@ -21,9 +29,10 @@
 					<label for="title">Selector</label>
 					<input type="text" ng-model="sourceSelector" class="form-control" placeholder="selector">
 				</li>
-				<button class="btn btn-default" ng-click="parseSource(source,sourceName,sourceSelector,sourceRSS,0)">Test</button>
-				<button class="btn btn-default" ng-click="parseSource(source,sourceName,sourceSelector,sourceRSS,1)">Add</button>
+				<button class="btn btn-default" ng-click="parseSource(source,sourceName,sourceSelector,sourceRSS,sourceCategory,0)">Test</button>
+				<button class="btn btn-default" ng-click="parseSource(source,sourceName,sourceSelector,sourceRSS,sourceCategory,1)">Add</button>
 
+		-->
 		</aside>
 		<div class="content-wrapper">
 			<div class="news-wrapper">

+ 1 - 1
front/style.css

@@ -100,7 +100,7 @@ body {
 	margin-top: 5px;
 	margin-bottom: 2px;
 }
-.filter input[type="text"] {
+.filter input[type="text"], .filter select {
 	width: 100%;
 	display: block;
 	outline: none;