Skip to content

Commit

Permalink
Update dependencies and fix filter scrollbar
Browse files Browse the repository at this point in the history
  • Loading branch information
maxontech committed Mar 17, 2024
1 parent bd6b184 commit 32453dd
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 91 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/markdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 1 addition & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 |
Regular Readme
15 changes: 15 additions & 0 deletions companies.md
Original file line number Diff line number Diff line change
@@ -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 |
28 changes: 14 additions & 14 deletions docs/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"companyName": "Scale",
"screenshotPath": "screenshots/Scale.jpeg",
"tags": [
"startup",
"startup",
"bootstrap",
"technology",
"software"
Expand Down Expand Up @@ -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",
Expand All @@ -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
}
]
80 changes: 21 additions & 59 deletions docs/parse-readme.js
Original file line number Diff line number Diff line change
@@ -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');


Expand All @@ -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]))
Expand Down Expand Up @@ -79,8 +70,8 @@ const getWebsiteStack = async (page) => {

if (!!window.Nuxt || !!window.__NUXT__)
return 'Nuxt.js';
return '';

return '';
});
}

Expand All @@ -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');
Expand All @@ -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);
Expand All @@ -138,7 +140,7 @@ const processFile = async (filePath) => {
console.log(dataObject);
dataObjects.push(dataObject);
}
await browser.close();
await browser.close();

await updateDataFile(dataObjects);

Expand All @@ -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');
});
});
*/
Binary file modified docs/screenshots/Scale.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshots/Spotify.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshots/Uber.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion next-site/src/components/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 32453dd

Please sign in to comment.