diff --git a/.github/workflows/markdown.yml b/.github/workflows/markdown.yml index 31267f2..eee54ee 100644 --- a/.github/workflows/markdown.yml +++ b/.github/workflows/markdown.yml @@ -21,8 +21,8 @@ jobs: - name: Check out repository code uses: actions/checkout@v4 - - name: Setup Chrome - uses: browser-actions/setup-chrome@latest + - name: Install dependencies + uses: npm install - name: Run parse-readme.js run: node docs/parse-readme.js diff --git a/README.md b/README.md index 788742e..0b958eb 100644 --- a/README.md +++ b/README.md @@ -1,15 +1 @@ - - -| Page | Hashtags | -| ------------------------------------ | ----------------------------- | -| [Scale](https://www.scale.ai) | #startup | -| [Head Shot Pro](https://www.headshotpro.com) | #startup | -| [Airbnb](https://www.airbnb.com) | #travel; #rental | -| [Uber](https://www.uber.com) | #transportation; #ridesharing | -| [Google](https://www.google.com) | #search; #technology | -| [Facebook](https://www.facebook.com) | #socialmedia; #networking | -| [Amazon](https://www.amazon.com) | #ecommerce; #retail | -| [Netflix](https://www.netflix.com) | #streaming; #entertainment | -| [Spotify](https://www.spotify.com) | #music; #streaming | -| [Microsoft](https://www.microsoft.com) | #technology; #software | -| [Github](https://www.github.com) | #technology; #software | \ No newline at end of file +Regular Readme \ No newline at end of file diff --git a/companies.md b/companies.md new file mode 100644 index 0000000..fb8b140 --- /dev/null +++ b/companies.md @@ -0,0 +1,15 @@ + + +| Page | Hashtags | +| -------------------------------------------- | ----------------------------- | +| [Scale](https://www.scale.ai) | #startup | +| [Head Shot Pro](https://www.headshotpro.com) | #startup | +| [Airbnb](https://www.airbnb.com) | #travel; #rental | +| [Uber](https://www.uber.com) | #transportation; #ridesharing | +| [Google](https://www.google.com) | #search; #technology | +| [Facebook](https://www.facebook.com) | #socialmedia; #networking | +| [Amazon](https://www.amazon.com) | #ecommerce; #retail | +| [Netflix](https://www.netflix.com) | #streaming; #entertainment | +| [Spotify](https://www.spotify.com) | #music; #streaming | +| [Microsoft](https://www.microsoft.com) | #technology; #software | +| [Github](https://www.github.com) | #technology; #software | \ No newline at end of file diff --git a/docs/data.json b/docs/data.json index 089df63..dd30778 100644 --- a/docs/data.json +++ b/docs/data.json @@ -6,7 +6,7 @@ "companyName": "Scale", "screenshotPath": "screenshots/Scale.jpeg", "tags": [ - "startup", + "startup", "bootstrap", "technology", "software" @@ -117,19 +117,6 @@ "stack": "React", "timeToPageLoad": 70 }, - { - "timestamp": "2024-03-14T20:17:43.056Z", - "title": "Microsoft – Cloud, Computer, Apps und Gaming", - "url": "https://www.microsoft.com", - "companyName": "Microsoft", - "screenshotPath": "screenshots/Microsoft.jpeg", - "tags": [ - "technology", - "software" - ], - "stack": "jQuery", - "timeToPageLoad": 1060 - }, { "timestamp": "2024-03-15T11:27:03.097Z", "title": "GitHub: Let’s build from here · GitHub", @@ -142,5 +129,18 @@ ], "stack": "React", "timeToPageLoad": 51 + }, + { + "timestamp": "2024-03-17T14:34:25.702Z", + "title": "Microsoft – Cloud, Computer, Apps und Gaming", + "url": "https://www.microsoft.com", + "companyName": "Microsoft", + "screenshotPath": "screenshots/Microsoft.jpeg", + "tags": [ + "technology", + "software" + ], + "stack": "jQuery", + "timeToPageLoad": 780 } ] \ No newline at end of file diff --git a/docs/parse-readme.js b/docs/parse-readme.js index b927c7f..db7d1f3 100644 --- a/docs/parse-readme.js +++ b/docs/parse-readme.js @@ -1,7 +1,7 @@ const fs = require('fs').promises; +const fsSync = require('fs'); const path = require('path'); -const filePath = path.join(__dirname, '..', 'README.md'); -const dataFilePath = path.join(__dirname, 'data.json'); +const filePath = path.join(__dirname, '..', 'companies.md'); const puppeteer = require('puppeteer'); @@ -14,15 +14,6 @@ const parseTableRow = (row) => { return { companyName, url, tags }; }; -const getH1Content = async (page) => { - try { - return await page.$eval('h1', element => element.textContent); - } catch (error) { - console.log('No h1 element found'); - return ''; - } -}; - const getPerformanceMetrics = async (page) => { const performanceMetrics = JSON.parse( await page.evaluate(() => JSON.stringify(performance.getEntriesByType("navigation")[0])) @@ -79,8 +70,8 @@ const getWebsiteStack = async (page) => { if (!!window.Nuxt || !!window.__NUXT__) return 'Nuxt.js'; - - return ''; + + return ''; }); } @@ -94,13 +85,15 @@ const updateDataFile = async (dataObjects) => { existingData = []; } - const newData = dataObjects.filter(dataObject => + const newData = dataObjects.filter(dataObject => !existingData.some(existingObject => existingObject.companyName === dataObject.companyName) ); await fs.writeFile(dataFilePath, JSON.stringify([...existingData, ...newData], null, 2)); } + + const processFile = async (filePath) => { data = await fs.readFile(filePath, 'utf8'); @@ -109,18 +102,27 @@ const processFile = async (filePath) => { let dataObjects = []; let match; + // Read the file + const dataJSON = fsSync.readFileSync(path.join(__dirname, 'data.json'), 'utf8'); + // Parse the JSON string into an object + const dataJSONArray = JSON.parse(dataJSON); + + while ((match = tableRowRegex.exec(data)) !== null) { const { companyName, url, tags } = parseTableRow(match[0]); + + if (dataJSONArray.some(entry => entry.companyName === companyName)) { + console.log(`DataObject already exists for ${companyName}, skipping.`); + continue; + } + const page = await browser.newPage(); - await page.setExtraHTTPHeaders({'Accept-Language': 'en-US,en'}); + await page.setExtraHTTPHeaders({ 'Accept-Language': 'en-US,en' }); await page.setViewport({ width: 1280, height: 720 }); await page.goto(url); - //const bodyContent = await page.$eval('body', element => element.innerHTML); - //console.log(bodyContent); - const websiteStack = await getWebsiteStack(page); const title = await page.title(); const timeToPageLoad = await getPerformanceMetrics(page); @@ -138,7 +140,7 @@ const processFile = async (filePath) => { console.log(dataObject); dataObjects.push(dataObject); } - await browser.close(); + await browser.close(); await updateDataFile(dataObjects); @@ -148,43 +150,3 @@ const processFile = async (filePath) => { processFile(filePath); -/* -// Read the file specified by dataFilePath -fs.readFile(dataFilePath, 'utf8', (err, data) => { - - // If there's an error reading the file, log the error and exit - if (err) { - console.error(err); - return; - } - - // Initialize an array to hold the existing data objects - let existingDataObjects = []; - - // If the file has data, parse the data into an array - if (data) { - existingDataObjects = JSON.parse(data); - } - - // Filter out the users that already exist in the data file - const newDataObjects = users.filter(user => !existingUsers.some(existingUser => existingUser.githubProfile === user.githubProfile)); - - // Combine the existing users and the new users - const allUsers = [...existingUsers, ...newUsers]; - - // Convert the allUsers array into a JSON string with a 2-space indentation - const json = JSON.stringify(allUsers, null, 2); - - // Write the JSON string to the same file - fs.writeFile(dataFilePath, `${json}`, 'utf8', err => { - - // If there's an error writing to the file, log the error and exit - if (err) { - console.error(err); - return; - } - // Log a success message - console.log('Data written to file'); - }); -}); -*/ \ No newline at end of file diff --git a/docs/screenshots/Scale.jpeg b/docs/screenshots/Scale.jpeg index 4fa0ccf..c90d488 100644 Binary files a/docs/screenshots/Scale.jpeg and b/docs/screenshots/Scale.jpeg differ diff --git a/docs/screenshots/Spotify.jpeg b/docs/screenshots/Spotify.jpeg index 8a7dd78..9d016f0 100644 Binary files a/docs/screenshots/Spotify.jpeg and b/docs/screenshots/Spotify.jpeg differ diff --git a/docs/screenshots/Uber.jpeg b/docs/screenshots/Uber.jpeg index b1320b6..bcd9c7f 100644 Binary files a/docs/screenshots/Uber.jpeg and b/docs/screenshots/Uber.jpeg differ diff --git a/next-site/src/components/filters.js b/next-site/src/components/filters.js index b80e0e3..9c243fa 100644 --- a/next-site/src/components/filters.js +++ b/next-site/src/components/filters.js @@ -6,10 +6,11 @@ export default function Filters({ selectedTags, handleTagClick, resetFilters }) let startX; let scrollLeft; - const slider = document.querySelector('.custom-scrollbar'); + const slider = document.querySelector('.filter-scrollbar'); if (slider) { slider.addEventListener('mousedown', (e) => { + console.log('mousedown'); isDown = true; startX = e.pageX - slider.offsetLeft; scrollLeft = slider.scrollLeft;