Skip to content

We have collected data from RSS feeds of different News Websites and have made a news website for displaying the news of all channels and websites.

Notifications You must be signed in to change notification settings

subirghosh77/newspring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

NewSpring

Duration

8 months

Technologies / Tools Used

JAVA, MySQL, Spring MVC, J2EE, HTML, CSS, JavaScript, AJAX, NetBeans, Apache Tomcat.

Description

i. Main purpose of the project is making of a News Portal.

ii. We have collected data from RSS feeds of different News Website and have made a news website for displaying the news of all channels and websites.

iii. We have got the URL from different news from RSS feeds and displayed the news of the particular URL in front end.

Images

Images of the projects are shown below.

Index page

index page

Detailed news page

detailed news

Available news paper page

available news paper

News paper page

news paper

About Us page

about paper

Contact Us page

contact us paper

404 page

404 paper

Code

1. HTML Code

By using this svg code we show 404 page.

<svg width="100%" height="380px" viewBox="0 0 636 324" fill="none">
   <g id="OBJECTS">
      <g id="Group">
         <path id="Vector" d="M101.3 255.2C101.3 255.2 111.1 272.6 181.8 280.5C252.5 288.4 288.2 314.9 333.1 322.8C378 330.7 433.6 278.5 481.8 286.5C530 294.4 588.2 264.2 592.8             255.2H101.3Z" fill="#2F1829"/>
      </g>
   </g>
</svg>

2. Java Script Code

We have dispay the news in froentd by using ajax function.

function triggerAjaxCall() {
   $.ajax({
      method: "POST",
      url: "ajaxcall-index",
      async: true,
      dataType: "json",
      beforeSend: function () {
      ...                    
      }
   }).done(function (items) {
      var text = "<div class='main_contener_div'style='height:fit-content;'>";
      $.each(items, function (index, item) {
         if(item.img === "null"){
            text=text+ "<div class='news_summary_div space_news_summary_div'><div class='news_div'><div class='news_first_part'><span class='decripition-type-div-mobile'>"+item.channelsDes+"</span>...</div>...</div>...";                
         }else{
            text=text+ "<div class='news_summary_div space_news_summary_div'><div class='news_div'><div class='news_first_part'><span class='decripition-type-div-mobile'>"+item.channelsDes+"</span>...</div>...</div>...";                
         }
   });
      text = text + "</div>";
      $(".second_div.showNews").append(text);
   }).fail(function () {
      alert("Error In append text");
   });
}

3. Spring IOC

By using the code we get data from data base.

List l=null;
List list=null;
int newItemCount;
if(session!=null && session.getAttribute("newsItemList")==null){
   l=fetchResourcesServiceImpl.getNewsItemDataFromDBService();
   System.out.println("List Size ->"+l.size());
   session.setAttribute("newsItemList", l);
   session.setAttribute("newsItemCount", 0);
}
list=(List)session.getAttribute("newsItemList");
newItemCount=(Integer)session.getAttribute("newsItemCount");
session.setAttribute("newsItemCount", newItemCount+10);
if(list.size()<=newItemCount + 10){
   return list.subList(newItemCount, list.size());
}else{
   return list.subList(newItemCount, newItemCount + 10);
} 

4. News Updater

Using this code we get data from RSS feed, and update databse daily.

for (int m = 0; m < cNodesLvl1.getLength(); m++) {
   leafP = cNodesLvl1.item(m);
   if (!channelsDes.equals("all")) {
      item.setChannelsDes(channelsDes);
   }
   if (leafP.hasChildNodes()) {
      switch (leafP.getNodeName().toUpperCase()) {
         case "TITLE":
            item.setTitle(leafP.getChildNodes().item(0).getNodeValue());
         break;
      case "DESCRIPTION":
         if (leafP.getChildNodes().item(0).getNodeValue().contains("<img")) {
            splitFirst = leafP.getChildNodes().item(0).getNodeValue().split("</a>");
            if (splitFirst.length > 1) {
               item.setDescription(splitFirst[1]);
            } else {
               item.setDescription("No Description found.");
            }
            splitFinal = splitFirst[0].split("src=", splitFirst[0].length());       
            splitFinal = splitFinal[1].split(Character.toString((char) 34));
            item.setImg(splitFinal[1].substring(0, splitFinal[1].length()));
         } else {
            item.setDescription(leafP.getChildNodes().item(0).getNodeValue());
         }
        break;
        ...
        case "AUTHOR":
           item.setAuthor(leafP.getChildNodes().item(0).getNodeValue());
        break;
      }
   }
}
items.add(item);

5. Mysql Connection

Create Connection

final String JDBC_DRIVER = "com.mysql.cj.jdbc.Driver";
final String DB_URL = "jdbc:mysql://localhost:3306/dailynews";
final String USER = "root";
final String PASS = "admin";
try {
   Class.forName(JDBC_DRIVER);
   System.out.println("Connecting to database...");
   conn = DriverManager.getConnection(DB_URL, USER, PASS);
} catch (Exception ex) {
   ex.printStackTrace();
}
return conn;

Close Connection

conn = getConnection();
stmt = conn.createStatement();
if (stmt != null) {
   stmt.close();
}
if (conn != null) {
   conn.close();
}
return null;

6. Detabase Schema

ERR diagram

Features

Search by news,Login portal.

Future Work

i. We have a plan to implement a feature where a user can post news by him in our news portal.

ii. We have a plan to implement of Spring JDBC and comment section.

Team Members

https://github.com/subirghosh77 , https://github.com/sneha2245/

About

We have collected data from RSS feeds of different News Websites and have made a news website for displaying the news of all channels and websites.

Topics

Resources

Stars

Watchers

Forks