diff --git a/CNAME b/CNAME deleted file mode 100644 index df1c048..0000000 --- a/CNAME +++ /dev/null @@ -1 +0,0 @@ -uniblog.click \ No newline at end of file diff --git a/asset-manifest.json b/asset-manifest.json index 4f3031c..47ad9bc 100644 --- a/asset-manifest.json +++ b/asset-manifest.json @@ -1,8 +1,8 @@ { "files": { "main.css": "/static/css/main.016ac928.chunk.css", - "main.js": "/static/js/main.11adc92d.chunk.js", - "main.js.map": "/static/js/main.11adc92d.chunk.js.map", + "main.js": "/static/js/main.3ce1b258.chunk.js", + "main.js.map": "/static/js/main.3ce1b258.chunk.js.map", "runtime-main.js": "/static/js/runtime-main.3922f912.js", "runtime-main.js.map": "/static/js/runtime-main.3922f912.js.map", "static/js/2.e72c465a.chunk.js": "/static/js/2.e72c465a.chunk.js", @@ -15,6 +15,6 @@ "static/js/runtime-main.3922f912.js", "static/js/2.e72c465a.chunk.js", "static/css/main.016ac928.chunk.css", - "static/js/main.11adc92d.chunk.js" + "static/js/main.3ce1b258.chunk.js" ] } \ No newline at end of file diff --git a/index.html b/index.html index 7612a2c..40b3cc6 100644 --- a/index.html +++ b/index.html @@ -1 +1 @@ -UniBlog One Place Learning
\ No newline at end of file +UniBlog One Place Learning
\ No newline at end of file diff --git a/static/js/main.11adc92d.chunk.js b/static/js/main.11adc92d.chunk.js deleted file mode 100644 index ce7171c..0000000 --- a/static/js/main.11adc92d.chunk.js +++ /dev/null @@ -1,2 +0,0 @@ -(this.webpackJsonpreact=this.webpackJsonpreact||[]).push([[0],{123:function(e,t,a){},130:function(e,t,a){},132:function(e,t,a){"use strict";a.r(t);var o=a(0),i=a.n(o),r=a(29),l=a.n(r),c=a(199),s=a(200),n=a(204),d=a(210),h=a(209),m=a(205),g=a(207),j=a(208),b=a(96),p=a.n(b),u=a(2);var x=function(e){let{isLoading:t,error:a,articles:o}=e;return Object(u.jsx)("main",{children:t?Object(u.jsx)("p",{children:"Loading..."}):a?Object(u.jsx)("div",{className:"error-message",children:Object(u.jsx)("p",{children:a})}):Object(u.jsx)("div",{className:"cards-container container flex",children:Array.isArray(o)&&o.length>0?o.map(((e,t)=>Object(u.jsxs)("div",{className:"card",onClick:()=>window.open(e.page_url,"_blank"),children:[Object(u.jsx)("div",{className:"card-header",children:Object(u.jsx)("img",{src:e.image_url||"https://via.placeholder.com/400x200",alt:"news"})}),Object(u.jsxs)("div",{className:"card-content",children:[Object(u.jsxs)("div",{className:"blog-meta",children:[e.author&&""!==e.author.trim()&&Object(u.jsx)("p",{className:"blog-author",children:e.author}),e.blog_date&&""!==e.blog_date.trim()&&Object(u.jsx)("p",{className:"blog-date",children:e.blog_date}),e.blog_date&&""!==e.blog_date.trim()&&Object(u.jsx)("p",{className:"blog-read-time",children:e.blog_date})]}),Object(u.jsx)("h3",{children:e.short_title}),Object(u.jsx)("p",{className:"news-desc",children:e.long_title&&e.long_title.length>100?"".concat(e.long_title.substring(0,100),"... read more"):e.long_title||null})]})]},t))):Object(u.jsx)("p",{children:"No articles available"})})})};a(123);const O=[{image_url:"https://via.placeholder.com/400x200",author:"John Doe",blog_date:"2024-07-21",blog_read_time:"5 min read",short_title:"Dummy Title 1",long_title:"This is a longer description for the dummy article 1. It provides additional context and details.",page_url:"#"},{image_url:"https://via.placeholder.com/400x200",author:"Jane Smith",blog_date:"2024-07-20",blog_read_time:"4 min read",short_title:"Dummy Title 2",long_title:"This is a longer description for the dummy article 2. It provides additional context and details.",page_url:"#"},{image_url:"https://via.placeholder.com/400x200",author:"Alice Johnson",blog_date:"2024-07-19",blog_read_time:"6 min read",short_title:"Dummy Title 3",long_title:"This is a longer description for the dummy article 3. It provides additional context and details.",page_url:"#"},{image_url:"https://via.placeholder.com/400x200",author:"Bob Brown",blog_date:"2024-07-18",blog_read_time:"3 min read",short_title:"Dummy Title 4",long_title:"This is a longer description for the dummy article 4. It provides additional context and details.",page_url:"#"},{image_url:"https://via.placeholder.com/400x200",author:"Charlie Davis",blog_date:"2024-07-17",blog_read_time:"7 min read",short_title:"Dummy Title 5",long_title:"This is a longer description for the dummy article 5. It provides additional context and details.",page_url:"#"},{image_url:"https://via.placeholder.com/400x200",author:"Dana Evans",blog_date:"2024-07-16",blog_read_time:"5 min read",short_title:"Dummy Title 6",long_title:"This is a longer description for the dummy article 6. It provides additional context and details.",page_url:"#"}];var _=function(){const[e,t]=Object(o.useState)([]),[a,i]=Object(o.useState)(1),[r,l]=Object(o.useState)("zomato"),[b,_]=Object(o.useState)(""),[y,v]=Object(o.useState)([]),[w,N]=Object(o.useState)(!0),[S,k]=Object(o.useState)(null),[C,I]=Object(o.useState)(!1),T=[{name:"zomato"},{name:"paytm"},{name:"phonepe"}];Object(o.useEffect)((()=>{localStorage.getItem("articles"),localStorage.getItem("currentCategory");D(r)}),[r]),Object(o.useEffect)((()=>{E()}),[]),Object(o.useEffect)((()=>{const e=()=>{window.innerHeight+window.scrollY>=document.body.offsetHeight&&i((e=>e+1))};return window.addEventListener("scroll",e),()=>{window.removeEventListener("scroll",e)}}),[]);const E=async()=>{try{const e=await fetch("https://uniblog.click/api/companies",{credentials:"include"});if(!e.ok)throw new Error("Network response was not ok");const t=await e.json();v(t.companies||[])}catch(S){console.error("Error fetching companies:",S),v(T)}},D=async e=>{const a="".concat("https://uniblog.click/api/articles","?company=").concat(e||r);console.log(a);try{const e=await fetch(a,{credentials:"include"});if(!e.ok)throw new Error("Network response was not ok");const o=await e.json();Array.isArray(o.articles)?0===o.articles.length?(t(O),localStorage.setItem("articles",JSON.stringify(O))):(t(o.articles),localStorage.setItem("articles",JSON.stringify(o.articles))):(t(O),localStorage.setItem("articles",JSON.stringify(O))),localStorage.setItem("currentCategory",r)}catch(S){console.error("Error fetching news:",S),t(O),localStorage.setItem("articles",JSON.stringify(O))}finally{N(!1)}},J=()=>{I(!1)};return Object(u.jsxs)("div",{className:"App",children:[Object(u.jsx)("nav",{children:Object(u.jsxs)("div",{className:"main-nav container flex",children:[Object(u.jsx)("a",{href:"#",onClick:f,className:"company-logo",children:Object(u.jsx)("img",{src:"assets/uniBlog_logo.png",alt:"company logo"})}),Object(u.jsx)("div",{className:"search-bar flex",children:Object(u.jsx)(n.a,{className:"company-search",variant:"contained",color:"primary",onClick:()=>{I(!0)},children:"Search Company"})})]})}),Object(u.jsx)(x,{isLoading:w,error:S,articles:e}),Object(u.jsx)("footer",{className:"footer",children:Object(u.jsx)("div",{className:"container footer-text",children:Object(u.jsx)("p",{children:"\xa9 2024 UniBlog. All rights reserved."})})}),Object(u.jsxs)("button",{className:"back-to-top-floating",onClick:()=>{window.scrollTo({top:0,behavior:"smooth"})},children:[Object(u.jsx)("i",{className:"fas fa-arrow-up"})," "]}),Object(u.jsxs)(g.a,{open:C,onClose:J,fullWidth:!0,maxWidth:"sm",children:[Object(u.jsxs)(m.a,{children:["Search Company",Object(u.jsx)(j.a,{edge:"end",color:"inherit",onClick:J,"aria-label":"close",style:{position:"absolute",right:16,top:8},children:Object(u.jsx)(p.a,{})})]}),Object(u.jsx)(h.a,{children:Object(u.jsx)(c.a,{options:y,getOptionLabel:e=>e.name,onChange:(e,t)=>_((null===t||void 0===t?void 0:t.name)||""),renderInput:e=>Object(u.jsx)(s.a,{...e,id:"search-text",type:"text",placeholder:"Search companies",fullWidth:!0,autoFocus:!0})})}),Object(u.jsxs)(d.a,{children:[Object(u.jsx)(n.a,{onClick:J,color:"primary",children:"Cancel"}),Object(u.jsx)(n.a,{onClick:()=>{var e;_(e=b),D(e),l(null),J()},color:"primary",children:"Search"})]})]})]})};function f(){window.location.reload()}a(130);l.a.render(Object(u.jsx)(i.a.StrictMode,{children:Object(u.jsx)(_,{})}),document.getElementById("root"))}},[[132,1,2]]]); -//# sourceMappingURL=main.11adc92d.chunk.js.map \ No newline at end of file diff --git a/static/js/main.11adc92d.chunk.js.map b/static/js/main.11adc92d.chunk.js.map deleted file mode 100644 index 977794b..0000000 --- a/static/js/main.11adc92d.chunk.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["components/CardTamplate.js","App.js","index.js"],"names":["CardTamplate","_ref","isLoading","error","articles","_jsx","children","className","Array","isArray","length","map","article","index","_jsxs","onClick","window","open","page_url","src","image_url","alt","author","trim","blog_date","short_title","long_title","concat","substring","dummyArticles","blog_read_time","App","setArticles","useState","currentPage","setCurrentPage","currentCategory","setCurrentCategory","searchQuery","setSearchQuery","companyList","setCompanyList","setIsLoading","setError","setOpen","companyListDummy","name","useEffect","localStorage","getItem","fetchNews","fetchCompanies","handleScroll","innerHeight","scrollY","document","body","offsetHeight","prevPage","addEventListener","removeEventListener","async","res","fetch","credentials","ok","Error","data","json","companies","console","newsUrl","query","log","setItem","JSON","stringify","handleClose","href","reload","Button","variant","color","handleClickOpen","scrollToTop","scrollTo","top","behavior","Dialog","onClose","fullWidth","maxWidth","DialogTitle","IconButton","edge","style","position","right","CloseIcon","DialogContent","Autocomplete","options","getOptionLabel","option","onChange","event","value","renderInput","params","TextField","id","type","placeholder","autoFocus","DialogActions","handleSearchSubmit","selectedCompany","location","ReactDOM","render","React","StrictMode","getElementById"],"mappings":"wRAgDeA,MAhDf,SAAqBC,GAA6B,IAA5B,UAACC,EAAS,MAACC,EAAK,SAACC,GAASH,EAE5C,OACII,cAAA,QAAAC,SACCJ,EACCG,cAAA,KAAAC,SAAG,eACDH,EACFE,cAAA,OAAKE,UAAU,gBAAeD,SAC5BD,cAAA,KAAAC,SAAIH,MAGNE,cAAA,OAAKE,UAAU,iCAAgCD,SAC5CE,MAAMC,QAAQL,IAAaA,EAASM,OAAS,EAC5CN,EAASO,KAAI,CAACC,EAASC,IACrBC,eAAA,OAAKP,UAAU,OAAmBQ,QAASA,IAAMC,OAAOC,KAAKL,EAAQM,SAAU,UAAUZ,SAAA,CACvFD,cAAA,OAAKE,UAAU,cAAaD,SAC1BD,cAAA,OAAKc,IAAKP,EAAQQ,WAAa,sCAAuCC,IAAI,WAE5EP,eAAA,OAAKP,UAAU,eAAcD,SAAA,CAC3BQ,eAAA,OAAKP,UAAU,YAAWD,SAAA,CACzBM,EAAQU,QAAoC,KAA1BV,E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U,WAAYC,MAAO,GAAIX,IAAK,GAAIhF,SAEnDD,cAAC6F,IAAS,SAGd7F,cAAC8F,IAAa,CAAA7F,SACZD,cAAC+F,IAAY,CACXC,QAAS7D,EACT8D,eAAiBC,GAAWA,EAAOzD,KACnC0D,SAAUA,CAACC,EAAOC,IAAUnE,GAAoB,OAALmE,QAAK,IAALA,OAAK,EAALA,EAAO5D,OAAQ,IAC1D6D,YAAcC,GACZvG,cAACwG,IAAS,IACJD,EACJE,GAAG,cACHC,KAAK,OACLC,YAAY,mBACZtB,WAAS,EACTuB,WAAS,QAKjBnG,eAACoG,IAAa,CAAA5G,SAAA,CACZD,cAAC2E,IAAM,CAACjE,QAAS8D,EAAaK,MAAM,UAAS5E,SAAC,WAG9CD,cAAC2E,IAAM,CAACjE,QApEWoG,KArBLC,MACpB7E,EADoB6E,EAsBP9E,GApBbY,EAAUkE,GACV/E,EAAmB,MAoBnBwC,GAAa,EAkE8BK,MAAM,UAAS5E,SAAC,mBAO/D,EAIA,SAASyE,IACP/D,OAAOqG,SAAStC,QAClB,C,OCpRAuC,IAASC,OACPlH,cAACmH,IAAMC,WAAU,CAAAnH,SACfD,cAAC0B,EAAG,MAENwB,SAASmE,eAAe,Q","file":"static/js/main.11adc92d.chunk.js","sourcesContent":["function CardTamplate({isLoading,error,articles}){\n //const {isLoading,error,article} = props;\n return (\n
\n {isLoading ? (\n

Loading...

\n ) : error ? (\n
\n

{error}

\n
\n ) : (\n
\n {Array.isArray(articles) && articles.length > 0 ? (\n articles.map((article, index) => (\n
window.open(article.page_url, \"_blank\")}>\n
\n \"news\"\n
\n
\n
\n {article.author && article.author.trim() !== \"\" && (\n

{article.author}

\n )} \n {article.blog_date && article.blog_date.trim() !== \"\" && (\n

{article.blog_date}

\n )} \n {article.blog_date && article.blog_date.trim() !== \"\" && (\n

{article.blog_date}

\n )} \n\n
\n

{article.short_title}

\n

\n {article.long_title && article.long_title.length > 100\n ? `${article.long_title.substring(0, 100)}... read more`\n : article.long_title || null}\n

\n
\n
\n ))\n ) : (\n

No articles available

\n )}\n
\n )}\n
\n );\n}\nexport default CardTamplate;","import React, { useState, useEffect } from 'react';\nimport Autocomplete from '@mui/material/Autocomplete';\nimport TextField from '@mui/material/TextField';\nimport Button from '@mui/material/Button';\nimport DialogActions from '@mui/material/DialogActions';\nimport DialogContent from '@mui/material/DialogContent';\nimport DialogTitle from '@mui/material/DialogTitle';\nimport Dialog from '@mui/material/Dialog';\nimport IconButton from '@mui/material/IconButton';\nimport CloseIcon from '@mui/icons-material/Close';\nimport CardTamplate from './components/CardTamplate';\nimport './App.css';\n\nconst dummyArticles = [\n {\n image_url: \"https://via.placeholder.com/400x200\",\n author: \"John Doe\",\n blog_date: \"2024-07-21\",\n blog_read_time: \"5 min read\",\n short_title: \"Dummy Title 1\",\n long_title: \"This is a longer description for the dummy article 1. It provides additional context and details.\",\n page_url: \"#\"\n },\n {\n image_url: \"https://via.placeholder.com/400x200\",\n author: \"Jane Smith\",\n blog_date: \"2024-07-20\",\n blog_read_time: \"4 min read\",\n short_title: \"Dummy Title 2\",\n long_title: \"This is a longer description for the dummy article 2. It provides additional context and details.\",\n page_url: \"#\"\n },\n {\n image_url: \"https://via.placeholder.com/400x200\",\n author: \"Alice Johnson\",\n blog_date: \"2024-07-19\",\n blog_read_time: \"6 min read\",\n short_title: \"Dummy Title 3\",\n long_title: \"This is a longer description for the dummy article 3. It provides additional context and details.\",\n page_url: \"#\"\n },\n {\n image_url: \"https://via.placeholder.com/400x200\",\n author: \"Bob Brown\",\n blog_date: \"2024-07-18\",\n blog_read_time: \"3 min read\",\n short_title: \"Dummy Title 4\",\n long_title: \"This is a longer description for the dummy article 4. It provides additional context and details.\",\n page_url: \"#\"\n },\n {\n image_url: \"https://via.placeholder.com/400x200\",\n author: \"Charlie Davis\",\n blog_date: \"2024-07-17\",\n blog_read_time: \"7 min read\",\n short_title: \"Dummy Title 5\",\n long_title: \"This is a longer description for the dummy article 5. It provides additional context and details.\",\n page_url: \"#\"\n },\n {\n image_url: \"https://via.placeholder.com/400x200\",\n author: \"Dana Evans\",\n blog_date: \"2024-07-16\",\n blog_read_time: \"5 min read\",\n short_title: \"Dummy Title 6\",\n long_title: \"This is a longer description for the dummy article 6. It provides additional context and details.\",\n page_url: \"#\"\n }\n];\n\n\nfunction App() {\n const [articles, setArticles] = useState([]);\n const [currentPage, setCurrentPage] = useState(1); // Track current page\n const [currentCategory, setCurrentCategory] = useState(\"zomato\");\n const [searchQuery, setSearchQuery] = useState(\"\");\n const [companyList, setCompanyList] = useState([]);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState(null);\n const [open, setOpen] = useState(false);\n //const base_ip = \"3.231.236.198\";\n const base_ip = \"127.0.0.1\";\n //const port = \"8081\";\n const port = \"8080\";\n const companyListDummy = [\n { name: \"zomato\" },\n { name: \"paytm\" },\n { name: \"phonepe\" }\n ];\n\n useEffect(() => {\n const cachedArticles = localStorage.getItem('articles');\n const cachedCategory = localStorage.getItem('currentCategory');\n\n // if (cachedArticles && cachedCategory === currentCategory) {\n // setArticles(JSON.parse(cachedArticles));\n // setIsLoading(false);\n // } else {\n // fetchNews(currentCategory);\n // }\n fetchNews(currentCategory);\n }, [currentCategory]);\n\n useEffect(() => {\n fetchCompanies();\n }, []);\n\n useEffect(() => {\n const handleScroll = () => {\n if (window.innerHeight + window.scrollY >= document.body.offsetHeight) {\n setCurrentPage((prevPage) => prevPage + 1); // Load next page\n }\n };\n\n window.addEventListener('scroll', handleScroll);\n return () => {\n window.removeEventListener('scroll', handleScroll);\n };\n }, []);\n\n const fetchCompanies = async () => {\n const baseUrl = `https://uniblog.click/api/companies`;\n //const baseUrl = `http://localhost:8080/api/companies`;\n\n try {\n const res = await fetch(baseUrl, {\n credentials: 'include'\n });\n\n if (!res.ok) {\n throw new Error('Network response was not ok');\n }\n\n const data = await res.json();\n setCompanyList(data.companies || []);\n } catch (error) {\n console.error(\"Error fetching companies:\", error);\n setCompanyList(companyListDummy);\n }\n };\n\n const fetchNews = async (query) => {\n const baseUrl = `https://uniblog.click/api/articles`;\n //const baseUrl = `http://localhost:8080/api/articles`;\n const newsUrl = `${baseUrl}?company=${query || currentCategory}`;\n console.log(newsUrl);\n try {\n const res = await fetch(newsUrl, {\n credentials: 'include'\n });\n\n if (!res.ok) {\n throw new Error('Network response was not ok');\n }\n\n const data = await res.json();\n\n if (Array.isArray(data.articles)) {\n if (data.articles.length === 0) {\n setArticles(dummyArticles);\n localStorage.setItem('articles', JSON.stringify(dummyArticles)); // Cache dummy data\n } else {\n setArticles(data.articles);\n localStorage.setItem('articles', JSON.stringify(data.articles)); // Cache actual data\n }\n } else {\n setArticles(dummyArticles);\n localStorage.setItem('articles', JSON.stringify(dummyArticles)); // Cache dummy data\n }\n localStorage.setItem('currentCategory', currentCategory); // Cache current category\n } catch (error) {\n console.error(\"Error fetching news:\", error);\n setArticles(dummyArticles);\n localStorage.setItem('articles', JSON.stringify(dummyArticles)); // Cache dummy data\n } finally {\n setIsLoading(false);\n }\n };\n\n const handleSearch = (selectedCompany) => {\n setSearchQuery(selectedCompany);\n fetchNews(selectedCompany);\n setCurrentCategory(null);\n };\n\n const scrollToTop = () => {\n window.scrollTo({\n top: 0,\n behavior: 'smooth'\n });\n };\n\n const handleClickOpen = () => {\n setOpen(true);\n };\n\n const handleClose = () => {\n setOpen(false);\n };\n\n const handleSearchSubmit = () => {\n handleSearch(searchQuery);\n handleClose();\n };\n\n return (\n
\n \n \n \n\n
\n
\n

© 2024 UniBlog. All rights reserved.

\n
\n
\n\n \n\n\n {/* Search Popup */}\n \n \n Search Company\n \n \n \n \n \n option.name}\n onChange={(event, value) => setSearchQuery(value?.name || '')}\n renderInput={(params) => (\n \n )}\n />\n \n \n \n \n \n \n
\n );\n}\n\nexport default App;\n\nfunction reload() {\n window.location.reload();\n}","import React from 'react';\nimport ReactDOM from 'react-dom';\nimport App from './App'; // Adjust the path if necessary\nimport './index.css'; // Optional: Import CSS if you have styling for your app\n\nReactDOM.render(\n \n \n ,\n document.getElementById('root')\n);\n"],"sourceRoot":""} \ No newline at end of file diff --git a/static/js/main.3ce1b258.chunk.js b/static/js/main.3ce1b258.chunk.js new file mode 100644 index 0000000..ce558b3 --- /dev/null +++ b/static/js/main.3ce1b258.chunk.js @@ -0,0 +1,2 @@ +(this.webpackJsonpreact=this.webpackJsonpreact||[]).push([[0],{123:function(e,t,a){},130:function(e,t,a){},132:function(e,t,a){"use strict";a.r(t);var o=a(0),i=a.n(o),r=a(29),l=a.n(r),c=a(199),s=a(200),n=a(204),d=a(210),m=a(209),h=a(205),g=a(207),j=a(208),b=a(96),p=a.n(b),u=a(2);var x=function(e){let{isLoading:t,error:a,articles:o}=e;return Object(u.jsx)("main",{children:t?Object(u.jsx)("p",{children:"Loading..."}):a?Object(u.jsx)("div",{className:"error-message",children:Object(u.jsx)("p",{children:a})}):Object(u.jsx)("div",{className:"cards-container container flex",children:Array.isArray(o)&&o.length>0?o.map(((e,t)=>Object(u.jsxs)("div",{className:"card",onClick:()=>window.open(e.page_url,"_blank"),children:[Object(u.jsx)("div",{className:"card-header",children:Object(u.jsx)("img",{src:e.image_url||"https://via.placeholder.com/400x200",alt:"news"})}),Object(u.jsxs)("div",{className:"card-content",children:[Object(u.jsxs)("div",{className:"blog-meta",children:[e.author&&""!==e.author.trim()&&Object(u.jsx)("p",{className:"blog-author",children:e.author}),e.blog_date&&""!==e.blog_date.trim()&&Object(u.jsx)("p",{className:"blog-date",children:e.blog_date}),e.blog_read_time&&""!==e.blog_read_time.trim()&&Object(u.jsx)("p",{className:"blog-read-time",children:e.blog_read_time})]}),Object(u.jsx)("h3",{children:e.short_title}),Object(u.jsx)("p",{className:"news-desc",children:e.long_title&&e.long_title.length>100?"".concat(e.long_title.substring(0,100),"... read more"):e.long_title||null})]})]},t))):Object(u.jsx)("p",{children:"No articles available"})})})};a(123);const _=[{image_url:"https://via.placeholder.com/400x200",author:"John Doe",blog_date:"2024-07-21",blog_read_time:"5 min read",short_title:"Dummy Title 1",long_title:"This is a longer description for the dummy article 1. It provides additional context and details.",page_url:"#"},{image_url:"https://via.placeholder.com/400x200",author:"Jane Smith",blog_date:"2024-07-20",blog_read_time:"4 min read",short_title:"Dummy Title 2",long_title:"This is a longer description for the dummy article 2. It provides additional context and details.",page_url:"#"},{image_url:"https://via.placeholder.com/400x200",author:"Alice Johnson",blog_date:"2024-07-19",blog_read_time:"6 min read",short_title:"Dummy Title 3",long_title:"This is a longer description for the dummy article 3. It provides additional context and details.",page_url:"#"},{image_url:"https://via.placeholder.com/400x200",author:"Bob Brown",blog_date:"2024-07-18",blog_read_time:"3 min read",short_title:"Dummy Title 4",long_title:"This is a longer description for the dummy article 4. It provides additional context and details.",page_url:"#"},{image_url:"https://via.placeholder.com/400x200",author:"Charlie Davis",blog_date:"2024-07-17",blog_read_time:"7 min read",short_title:"Dummy Title 5",long_title:"This is a longer description for the dummy article 5. It provides additional context and details.",page_url:"#"},{image_url:"https://via.placeholder.com/400x200",author:"Dana Evans",blog_date:"2024-07-16",blog_read_time:"5 min read",short_title:"Dummy Title 6",long_title:"This is a longer description for the dummy article 6. It provides additional context and details.",page_url:"#"}];var O=function(){const[e,t]=Object(o.useState)([]),[a,i]=Object(o.useState)(1),[r,l]=Object(o.useState)("zomato"),[b,O]=Object(o.useState)(""),[y,v]=Object(o.useState)([]),[w,N]=Object(o.useState)(!0),[S,k]=Object(o.useState)(null),[C,I]=Object(o.useState)(!1),T=[{name:"zomato"},{name:"paytm"},{name:"phonepe"}];Object(o.useEffect)((()=>{localStorage.getItem("articles"),localStorage.getItem("currentCategory");D(r)}),[r]),Object(o.useEffect)((()=>{E()}),[]),Object(o.useEffect)((()=>{const e=()=>{window.innerHeight+window.scrollY>=document.body.offsetHeight&&i((e=>e+1))};return window.addEventListener("scroll",e),()=>{window.removeEventListener("scroll",e)}}),[]);const E=async()=>{try{const e=await fetch("https://uniblog.click/api/companies",{credentials:"include"});if(!e.ok)throw new Error("Network response was not ok");const t=await e.json();v(t.companies||[])}catch(S){console.error("Error fetching companies:",S),v(T)}},D=async e=>{const a="".concat("https://uniblog.click/api/articles","?company=").concat(e||r);console.log(a);try{const e=await fetch(a,{credentials:"include"});if(!e.ok)throw new Error("Network response was not ok");const o=await e.json();Array.isArray(o.articles)?0===o.articles.length?(t(_),localStorage.setItem("articles",JSON.stringify(_))):(t(o.articles),localStorage.setItem("articles",JSON.stringify(o.articles))):(t(_),localStorage.setItem("articles",JSON.stringify(_))),localStorage.setItem("currentCategory",r)}catch(S){console.error("Error fetching news:",S),t(_),localStorage.setItem("articles",JSON.stringify(_))}finally{N(!1)}},J=()=>{I(!1)};return Object(u.jsxs)("div",{className:"App",children:[Object(u.jsx)("nav",{children:Object(u.jsxs)("div",{className:"main-nav container flex",children:[Object(u.jsx)("a",{href:"#",onClick:f,className:"company-logo",children:Object(u.jsx)("img",{src:"assets/uniBlog_logo.png",alt:"company logo"})}),Object(u.jsx)("div",{className:"search-bar flex",children:Object(u.jsx)(n.a,{className:"company-search",variant:"contained",color:"primary",onClick:()=>{I(!0)},children:"Search Company"})})]})}),Object(u.jsx)(x,{isLoading:w,error:S,articles:e}),Object(u.jsx)("footer",{className:"footer",children:Object(u.jsx)("div",{className:"container footer-text",children:Object(u.jsx)("p",{children:"\xa9 2024 UniBlog. All rights reserved."})})}),Object(u.jsxs)("button",{className:"back-to-top-floating",onClick:()=>{window.scrollTo({top:0,behavior:"smooth"})},children:[Object(u.jsx)("i",{className:"fas fa-arrow-up"})," "]}),Object(u.jsxs)(g.a,{open:C,onClose:J,fullWidth:!0,maxWidth:"sm",children:[Object(u.jsxs)(h.a,{children:["Search Company",Object(u.jsx)(j.a,{edge:"end",color:"inherit",onClick:J,"aria-label":"close",style:{position:"absolute",right:16,top:8},children:Object(u.jsx)(p.a,{})})]}),Object(u.jsx)(m.a,{children:Object(u.jsx)(c.a,{options:y,getOptionLabel:e=>e.name,onChange:(e,t)=>O((null===t||void 0===t?void 0:t.name)||""),renderInput:e=>Object(u.jsx)(s.a,{...e,id:"search-text",type:"text",placeholder:"Search companies",fullWidth:!0,autoFocus:!0})})}),Object(u.jsxs)(d.a,{children:[Object(u.jsx)(n.a,{onClick:J,color:"primary",children:"Cancel"}),Object(u.jsx)(n.a,{onClick:()=>{var e;O(e=b),D(e),l(null),J()},color:"primary",children:"Search"})]})]})]})};function f(){window.location.reload()}a(130);l.a.render(Object(u.jsx)(i.a.StrictMode,{children:Object(u.jsx)(O,{})}),document.getElementById("root"))}},[[132,1,2]]]); +//# sourceMappingURL=main.3ce1b258.chunk.js.map \ No newline at end of file diff --git a/static/js/main.3ce1b258.chunk.js.map b/static/js/main.3ce1b258.chunk.js.map new file mode 100644 index 0000000..92c910d --- /dev/null +++ b/static/js/main.3ce1b258.chunk.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["components/CardTamplate.js","App.js","index.js"],"names":["CardTamplate","_ref","isLoading","error","articles","_jsx","children","className","Array","isArray","length","map","article","index","_jsxs","onClick","window","open","page_url","src","image_url","alt","author","trim","blog_date","blog_read_time","short_title","long_title","concat","substring","dummyArticles","App","setArticles","useState","currentPage","setCurrentPage","currentCategory","setCurrentCategory","searchQuery","setSearchQuery","companyList","setCompanyList","setIsLoading","setError","setOpen","companyListDummy","name","useEffect","localStorage","getItem","fetchNews","fetchCompanies","handleScroll","innerHeight","scrollY","document","body","offsetHeight","prevPage","addEventListener","removeEventListener","async","res","fetch","credentials","ok","Error","data","json","companies","console","newsUrl","query","log","setItem","JSON","stringify","handleClose","href","reload","Button","variant","color","handleClickOpen","scrollToTop","scrollTo","top","behavior","Dialog","onClose","fullWidth","maxWidth","DialogTitle","IconButton","edge","style","position","right","CloseIcon","DialogContent","Autocomplete","options","getOptionLabel","option","onChange","event","value","renderInput","params","TextField","id","type","placeholder","autoFocus","DialogActions","handleSearchSubmit","selectedCompany","location","ReactDOM","render","React","StrictMode","getElementById"],"mappings":"wRAgDeA,MAhDf,SAAqBC,GAA6B,IAA5B,UAACC,EAAS,MAACC,EAAK,SAACC,GAASH,EAE5C,OACII,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AAAnH,SACfD,cAAC0B,EAAG,MAENwB,SAASmE,eAAe,Q","file":"static/js/main.3ce1b258.chunk.js","sourcesContent":["function CardTamplate({isLoading,error,articles}){\n //const {isLoading,error,article} = props;\n return (\n
\n {isLoading ? (\n

Loading...

\n ) : error ? (\n
\n

{error}

\n
\n ) : (\n
\n {Array.isArray(articles) && articles.length > 0 ? (\n articles.map((article, index) => (\n
window.open(article.page_url, \"_blank\")}>\n
\n \"news\"\n
\n
\n
\n {article.author && article.author.trim() !== \"\" && (\n

{article.author}

\n )} \n {article.blog_date && article.blog_date.trim() !== \"\" && (\n

{article.blog_date}

\n )} \n {article.blog_read_time && article.blog_read_time.trim() !== \"\" && (\n

{article.blog_read_time}

\n )} \n \n
\n

{article.short_title}

\n

\n {article.long_title && article.long_title.length > 100\n ? `${article.long_title.substring(0, 100)}... read more`\n : article.long_title || null}\n

\n
\n
\n ))\n ) : (\n

No articles available

\n )}\n
\n )}\n
\n );\n}\nexport default CardTamplate;","import React, { useState, useEffect } from 'react';\nimport Autocomplete from '@mui/material/Autocomplete';\nimport TextField from '@mui/material/TextField';\nimport Button from '@mui/material/Button';\nimport DialogActions from '@mui/material/DialogActions';\nimport DialogContent from '@mui/material/DialogContent';\nimport DialogTitle from '@mui/material/DialogTitle';\nimport Dialog from '@mui/material/Dialog';\nimport IconButton from '@mui/material/IconButton';\nimport CloseIcon from '@mui/icons-material/Close';\nimport CardTamplate from './components/CardTamplate';\nimport './App.css';\n\nconst dummyArticles = [\n {\n image_url: \"https://via.placeholder.com/400x200\",\n author: \"John Doe\",\n blog_date: \"2024-07-21\",\n blog_read_time: \"5 min read\",\n short_title: \"Dummy Title 1\",\n long_title: \"This is a longer description for the dummy article 1. It provides additional context and details.\",\n page_url: \"#\"\n },\n {\n image_url: \"https://via.placeholder.com/400x200\",\n author: \"Jane Smith\",\n blog_date: \"2024-07-20\",\n blog_read_time: \"4 min read\",\n short_title: \"Dummy Title 2\",\n long_title: \"This is a longer description for the dummy article 2. It provides additional context and details.\",\n page_url: \"#\"\n },\n {\n image_url: \"https://via.placeholder.com/400x200\",\n author: \"Alice Johnson\",\n blog_date: \"2024-07-19\",\n blog_read_time: \"6 min read\",\n short_title: \"Dummy Title 3\",\n long_title: \"This is a longer description for the dummy article 3. It provides additional context and details.\",\n page_url: \"#\"\n },\n {\n image_url: \"https://via.placeholder.com/400x200\",\n author: \"Bob Brown\",\n blog_date: \"2024-07-18\",\n blog_read_time: \"3 min read\",\n short_title: \"Dummy Title 4\",\n long_title: \"This is a longer description for the dummy article 4. It provides additional context and details.\",\n page_url: \"#\"\n },\n {\n image_url: \"https://via.placeholder.com/400x200\",\n author: \"Charlie Davis\",\n blog_date: \"2024-07-17\",\n blog_read_time: \"7 min read\",\n short_title: \"Dummy Title 5\",\n long_title: \"This is a longer description for the dummy article 5. It provides additional context and details.\",\n page_url: \"#\"\n },\n {\n image_url: \"https://via.placeholder.com/400x200\",\n author: \"Dana Evans\",\n blog_date: \"2024-07-16\",\n blog_read_time: \"5 min read\",\n short_title: \"Dummy Title 6\",\n long_title: \"This is a longer description for the dummy article 6. It provides additional context and details.\",\n page_url: \"#\"\n }\n];\n\n\nfunction App() {\n const [articles, setArticles] = useState([]);\n const [currentPage, setCurrentPage] = useState(1); // Track current page\n const [currentCategory, setCurrentCategory] = useState(\"zomato\");\n const [searchQuery, setSearchQuery] = useState(\"\");\n const [companyList, setCompanyList] = useState([]);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState(null);\n const [open, setOpen] = useState(false);\n //const base_ip = \"3.231.236.198\";\n const base_ip = \"127.0.0.1\";\n //const port = \"8081\";\n const port = \"8080\";\n const companyListDummy = [\n { name: \"zomato\" },\n { name: \"paytm\" },\n { name: \"phonepe\" }\n ];\n\n useEffect(() => {\n const cachedArticles = localStorage.getItem('articles');\n const cachedCategory = localStorage.getItem('currentCategory');\n\n // if (cachedArticles && cachedCategory === currentCategory) {\n // setArticles(JSON.parse(cachedArticles));\n // setIsLoading(false);\n // } else {\n // fetchNews(currentCategory);\n // }\n fetchNews(currentCategory);\n }, [currentCategory]);\n\n useEffect(() => {\n fetchCompanies();\n }, []);\n\n useEffect(() => {\n const handleScroll = () => {\n if (window.innerHeight + window.scrollY >= document.body.offsetHeight) {\n setCurrentPage((prevPage) => prevPage + 1); // Load next page\n }\n };\n\n window.addEventListener('scroll', handleScroll);\n return () => {\n window.removeEventListener('scroll', handleScroll);\n };\n }, []);\n\n const fetchCompanies = async () => {\n const baseUrl = `https://uniblog.click/api/companies`;\n //const baseUrl = `http://localhost:8080/api/companies`;\n\n try {\n const res = await fetch(baseUrl, {\n credentials: 'include'\n });\n\n if (!res.ok) {\n throw new Error('Network response was not ok');\n }\n\n const data = await res.json();\n setCompanyList(data.companies || []);\n } catch (error) {\n console.error(\"Error fetching companies:\", error);\n setCompanyList(companyListDummy);\n }\n };\n\n const fetchNews = async (query) => {\n const baseUrl = `https://uniblog.click/api/articles`;\n //const baseUrl = `http://localhost:8080/api/articles`;\n const newsUrl = `${baseUrl}?company=${query || currentCategory}`;\n console.log(newsUrl);\n try {\n const res = await fetch(newsUrl, {\n credentials: 'include'\n });\n\n if (!res.ok) {\n throw new Error('Network response was not ok');\n }\n\n const data = await res.json();\n\n if (Array.isArray(data.articles)) {\n if (data.articles.length === 0) {\n setArticles(dummyArticles);\n localStorage.setItem('articles', JSON.stringify(dummyArticles)); // Cache dummy data\n } else {\n setArticles(data.articles);\n localStorage.setItem('articles', JSON.stringify(data.articles)); // Cache actual data\n }\n } else {\n setArticles(dummyArticles);\n localStorage.setItem('articles', JSON.stringify(dummyArticles)); // Cache dummy data\n }\n localStorage.setItem('currentCategory', currentCategory); // Cache current category\n } catch (error) {\n console.error(\"Error fetching news:\", error);\n setArticles(dummyArticles);\n localStorage.setItem('articles', JSON.stringify(dummyArticles)); // Cache dummy data\n } finally {\n setIsLoading(false);\n }\n };\n\n const handleSearch = (selectedCompany) => {\n setSearchQuery(selectedCompany);\n fetchNews(selectedCompany);\n setCurrentCategory(null);\n };\n\n const scrollToTop = () => {\n window.scrollTo({\n top: 0,\n behavior: 'smooth'\n });\n };\n\n const handleClickOpen = () => {\n setOpen(true);\n };\n\n const handleClose = () => {\n setOpen(false);\n };\n\n const handleSearchSubmit = () => {\n handleSearch(searchQuery);\n handleClose();\n };\n\n return (\n
\n \n \n \n\n
\n
\n

© 2024 UniBlog. All rights reserved.

\n
\n
\n\n \n\n\n {/* Search Popup */}\n \n \n Search Company\n \n \n \n \n \n option.name}\n onChange={(event, value) => setSearchQuery(value?.name || '')}\n renderInput={(params) => (\n \n )}\n />\n \n \n \n \n \n \n
\n );\n}\n\nexport default App;\n\nfunction reload() {\n window.location.reload();\n}","import React from 'react';\nimport ReactDOM from 'react-dom';\nimport App from './App'; // Adjust the path if necessary\nimport './index.css'; // Optional: Import CSS if you have styling for your app\n\nReactDOM.render(\n \n \n ,\n document.getElementById('root')\n);\n"],"sourceRoot":""} \ No newline at end of file