-
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Manual deploy as of commit:066be2cfa226a71403c6ed592425c911a032eb78 * fix(unlock-app): fixing the broken login flows (#13914) * Revert "fix(unlock-account): Checkout email waiting fix (#13906)" This reverts commit 5511627. * some simplification and refactoring for our login flows * Updated autoSignIn flow * Update Connected.tsx --------- Co-authored-by: Viacheslav <surzhenkoviacheslav@gmail.com> --------- Co-authored-by: Viacheslav <surzhenkoviacheslav@gmail.com>
- Loading branch information
Showing
166 changed files
with
6,671 additions
and
8,098 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<rss version="2.0"> | ||
<channel> | ||
<title>Sample Blog</title> | ||
<link>https://example.com</link> | ||
<description>This is a sample RSS feed for testing.</description> | ||
<language>en-us</language> | ||
|
||
<item> | ||
<title>First Blog Post</title> | ||
<link>https://example.com/first-blog-post</link> | ||
<pubDate>Wed, 01 Apr 2023 12:00:00 GMT</pubDate> | ||
<description>This is the summary of the first blog post.</description> | ||
<author>Author One</author> | ||
<content:encoded | ||
><![CDATA[<p>This is the <strong>content</strong> of the first blog post.</p>]]></content:encoded> | ||
<image> | ||
<href>https://example.com/images/first.jpg</href> | ||
</image> | ||
</item> | ||
|
||
<item> | ||
<title>Second Blog Post</title> | ||
<link>https://example.com/second-blog-post</link> | ||
<pubDate>Thu, 02 Apr 2023 12:00:00 GMT</pubDate> | ||
<description>This is the summary of the second blog post.</description> | ||
<author>Author Two</author> | ||
<content:encoded | ||
><![CDATA[<p>This is the <strong>content</strong> of the second blog post.</p>]]></content:encoded> | ||
<image> | ||
<href>https://example.com/images/second.jpg</href> | ||
</image> | ||
</item> | ||
|
||
</channel> | ||
</rss> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
const fs = require('fs-extra') | ||
const path = require('path') | ||
const fetch = require('node-fetch') | ||
const feedparser = require('feedparser-promised') | ||
|
||
// Fetch the RSS feed | ||
const rssUrl = 'https://paragraph.xyz/api/blogs/rss/@unlockprotocol' | ||
//const rssUrl = 'https://gist.githubusercontent.com/njokuScript/49c95765a21de9a7cf01c72f06149769/raw/5f62f27fc2a9c37e992d7834e86361a72cbfeeca/mock_rss_feed.xml' | ||
|
||
// Create the base directory for storing blog posts | ||
const blogDir = '../../../unlock-protocol-com/blog' | ||
fs.ensureDirSync(blogDir) | ||
|
||
// Load the titles of existing blog posts to check for duplicates | ||
const existingTitles = new Set() | ||
fs.readdirSync(blogDir).forEach((filename) => { | ||
if (filename.endsWith('.md')) { | ||
const content = fs.readFileSync(path.join(blogDir, filename), 'utf8') | ||
const titleMatch = content.match(/^title: "(.*)"/m) | ||
if (titleMatch) { | ||
existingTitles.add(titleMatch[1]) | ||
} | ||
} | ||
}) | ||
|
||
const downloadImage = (url, filepath) => { | ||
return fetch(url) | ||
.then((res) => res.buffer()) | ||
.then((buffer) => fs.writeFile(filepath, buffer)) | ||
.catch((error) => console.error(`Error downloading image ${url}:`, error)) | ||
} | ||
|
||
const extractAndDownloadImages = (content, postImagesDir, slug) => { | ||
const imageRegex = /<img[^>]+src="([^">]+)"/g | ||
let updatedContent = content | ||
let match | ||
const imagePromises = [] | ||
|
||
while ((match = imageRegex.exec(content)) !== null) { | ||
const imageUrl = match[1] | ||
const imageFilename = path.basename(imageUrl) | ||
const localImagePath = path.join(postImagesDir, imageFilename) | ||
// Extract and download images from the content and update the content with local image paths | ||
const imagePromise = downloadImage(imageUrl, localImagePath).then(() => { | ||
updatedContent = updatedContent.replace( | ||
imageUrl, | ||
`/images/blog/${slug}/${imageFilename}` | ||
) | ||
}) | ||
imagePromises.push(imagePromise) | ||
} | ||
|
||
return Promise.all(imagePromises).then(() => updatedContent) | ||
} | ||
// Iterate over each post in the feed | ||
feedparser | ||
.parse(rssUrl) | ||
.then((entries) => { | ||
entries.forEach((entry, count) => { | ||
const title = entry.title | ||
const subtitle = entry.subtitle || '' | ||
const authorName = entry.author || 'Unlock Labs team' | ||
const publishDate = entry.pubDate | ||
const description = entry.summary | ||
let imageUrl = entry.image && entry.image.href ? entry.image.href : '' | ||
|
||
if (!imageUrl) { | ||
const enclosuresImage = entry.enclosures.find((enclosure) => { | ||
return enclosure.type.startsWith('image') | ||
|
||
}) | ||
if (enclosuresImage) { | ||
imageUrl = enclosuresImage.url | ||
} | ||
} | ||
|
||
// Skip if the title already exists | ||
if (existingTitles.has(title)) { | ||
return | ||
} | ||
// Generate a slug for the blog post | ||
const slug = title | ||
.replace(/[^\w\-_\. ]/g, '-') | ||
.toLowerCase() | ||
.replace(/ /g, '-') | ||
const postImagesDir = path.join( | ||
'../../../unlock-protocol-com/public/images/blog', | ||
slug | ||
) | ||
fs.ensureDirSync(postImagesDir) | ||
// Download the featured image and save it locally | ||
let imageDownloadPromise = Promise.resolve() | ||
if (imageUrl) { | ||
const imageFilename = path.basename(imageUrl) | ||
const localImagePath = path.join(postImagesDir, imageFilename) | ||
imageDownloadPromise = downloadImage(imageUrl, localImagePath) | ||
} | ||
|
||
// Create the post content with the updated content | ||
imageDownloadPromise | ||
.then(() => { | ||
return extractAndDownloadImages( | ||
entry.description, | ||
postImagesDir, | ||
slug | ||
) | ||
}) | ||
.then((updatedContent) => { | ||
const postContent = `--- | ||
title: "${title}" | ||
subtitle: "${subtitle}" | ||
authorName: "${authorName}" | ||
publishDate: "${publishDate}" | ||
description: "${description}" | ||
image: "/images/blog/${slug}/${path.basename( | ||
imageUrl | ||
)}" | ||
--- | ||
![${title}](${imageUrl}) | ||
${updatedContent}` | ||
|
||
const postFilename = `${slug}.md` | ||
const postFilePath = path.join(blogDir, postFilename) | ||
fs.writeFileSync(postFilePath, postContent) | ||
existingTitles.add(title) | ||
}) | ||
}) | ||
}) | ||
.catch((error) => { | ||
console.error('Error fetching RSS feed:', error) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Fetch and Create Blog Posts | ||
on: | ||
schedule: | ||
- cron: '0 0 * * *' # Run once per day at midnight | ||
workflow_dispatch: | ||
|
||
jobs: | ||
fetch_and_create_posts: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '20' | ||
|
||
- name: Run RSS Feed Script | ||
run: node rss_feed.js | ||
|
||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v4 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
commit-message: 'Add new blog posts' | ||
title: 'New blog posts from RSS feed' | ||
body: 'Automatically generated PR to add new blog posts fetched from the RSS feed.' | ||
branch: new-blog-posts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.