-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into weather8384
- Loading branch information
Showing
56 changed files
with
13,918 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="style.css"> | ||
<title>Contentful CMS</title> | ||
</head> | ||
<body> | ||
<header> | ||
<h1>Contentful API Explorer</h1> | ||
</header> | ||
<main id="app"> | ||
<section> | ||
<h2>Discover Content</h2> | ||
<button id="fetchContentButton">Fetch Random Content</button> | ||
</section> | ||
<section id="content-info"> | ||
<h2>Content Details</h2> | ||
<div id="content"></div> | ||
</section> | ||
</main> | ||
<script src="index.js"></script> | ||
</body> | ||
</html> |
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,48 @@ | ||
document.addEventListener('DOMContentLoaded', function () { | ||
document.getElementById('fetchContentButton').addEventListener('click', fetchRandomContent); | ||
}); | ||
|
||
async function fetchRandomContent() { | ||
const spaceId = 'YOUR_SPACE_ID'; | ||
const accessToken = 'YOUR_ACCESS_TOKEN'; | ||
const endpoint = `https://cdn.contentful.com/spaces/${spaceId}/entries?access_token=${accessToken}`; | ||
|
||
try { | ||
const response = await fetch(endpoint, { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
} | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error(`HTTP error! Status: ${response.status}`); | ||
} | ||
|
||
const data = await response.json(); | ||
console.log('Fetched data:', data); | ||
|
||
if (data.items && data.items.length > 0) { | ||
const randomItem = data.items[Math.floor(Math.random() * data.items.length)]; | ||
displayContent(randomItem); | ||
} else { | ||
displayError('No content found.'); | ||
} | ||
} catch (error) { | ||
console.error('Error fetching content:', error); | ||
displayError('Failed to fetch content details.'); | ||
} | ||
} | ||
|
||
function displayContent(content) { | ||
const contentDiv = document.getElementById('content'); | ||
contentDiv.innerHTML = ` | ||
<h3>${content.fields.title}</h3> | ||
<p><strong>Description:</strong> ${content.fields.description}</p> | ||
`; | ||
} | ||
|
||
function displayError(message) { | ||
const contentDiv = document.getElementById('content'); | ||
contentDiv.innerHTML = `<p>${message}</p>`; | ||
} |
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,15 @@ | ||
{ | ||
"short_name": "ContentfulApp", | ||
"name": "Contentful API Explorer", | ||
"icons": [ | ||
{ | ||
"src": "icon.png", | ||
"type": "image/png", | ||
"sizes": "192x192" | ||
} | ||
], | ||
"start_url": ".", | ||
"display": "standalone", | ||
"theme_color": "#00c6ff", | ||
"background_color": "#0072ff" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,15 @@ | ||
{ | ||
"name": "contentful-api-explorer", | ||
"version": "1.0.0", | ||
"description": "A simple app to explore content from Contentful API", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "node server.js" | ||
}, | ||
"author": "Revanth", | ||
"license": "ISC", | ||
"dependencies": { | ||
"express": "^4.17.1" | ||
} | ||
} | ||
|
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,70 @@ | ||
body { | ||
font-family: 'Arial', sans-serif; | ||
background: linear-gradient(135deg, #00c6ff, #e7ae3e); | ||
color: #333; | ||
margin: 0; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
min-height: 100vh; | ||
} | ||
|
||
header { | ||
text-align: center; | ||
margin-bottom: 20px; | ||
} | ||
|
||
header h1 { | ||
font-size: 3em; | ||
color: #fff; | ||
} | ||
|
||
main { | ||
background: rgba(255, 255, 255, 0.9); | ||
padding: 20px; | ||
border-radius: 10px; | ||
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); | ||
text-align: center; | ||
} | ||
|
||
section { | ||
margin-bottom: 20px; | ||
} | ||
|
||
h2 { | ||
font-size: 2em; | ||
margin-bottom: 10px; | ||
color: #00c6ff; | ||
} | ||
|
||
button { | ||
padding: 10px 20px; | ||
font-size: 1em; | ||
color: #fff; | ||
background-color: #00c6ff; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
transition: background-color 0.3s; | ||
} | ||
|
||
button:hover { | ||
background-color: #0072ff; | ||
} | ||
|
||
#content-info { | ||
margin-top: 20px; | ||
} | ||
|
||
#content { | ||
font-size: 1.2em; | ||
background: #fff; | ||
padding: 20px; | ||
border-radius: 10px; | ||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
#content p { | ||
margin: 10px 0; | ||
} |
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,39 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="style.css"> | ||
<title>Filestack File Uploader</title> | ||
</head> | ||
<body> | ||
<header> | ||
<h1>Filestack File Uploader</h1> | ||
</header> | ||
<main> | ||
<section> | ||
<form id="upload-form"> | ||
<input type="file" id="fileInput" accept="image/*"> | ||
<button type="submit">Upload and Transform</button> | ||
</form> | ||
<div id="transform-options"> | ||
<label for="resizeWidth">Resize Width (px):</label> | ||
<input type="number" id="resizeWidth" placeholder="e.g. 300"> | ||
|
||
<label for="resizeHeight">Resize Height (px):</label> | ||
<input type="number" id="resizeHeight" placeholder="e.g. 300"> | ||
|
||
<label for="watermark">Watermark Text:</label> | ||
<input type="text" id="watermark" placeholder="Enter watermark text"> | ||
</div> | ||
<div id="status"></div> | ||
<div id="transformed-image"> | ||
<h2>Transformed Image:</h2> | ||
<img id="imagePreview" src="" alt="Your transformed image will appear here"> | ||
</div> | ||
</section> | ||
</main> | ||
<script src="https://cdn.filestackcontent.com/filestack.js"></script> | ||
<script src="index.js"></script> | ||
</body> | ||
</html> |
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,43 @@ | ||
const client = filestack.init('YOUR_FILESTACK_API_KEY'); | ||
|
||
document.getElementById('upload-form').addEventListener('submit', async (e) => { | ||
e.preventDefault(); | ||
|
||
const fileInput = document.getElementById('fileInput'); | ||
const resizeWidth = document.getElementById('resizeWidth').value; | ||
const resizeHeight = document.getElementById('resizeHeight').value; | ||
const watermark = document.getElementById('watermark').value; | ||
|
||
if (fileInput.files.length === 0) { | ||
document.getElementById('status').textContent = 'Please select a file to upload.'; | ||
return; | ||
} | ||
|
||
const file = fileInput.files[0]; | ||
|
||
try { | ||
const uploadResponse = await client.upload(file); | ||
let handle = uploadResponse.handle; | ||
|
||
let url = `https://cdn.filestackcontent.com/${handle}`; | ||
|
||
// Apply transformations if specified | ||
let transformations = []; | ||
if (resizeWidth || resizeHeight) { | ||
transformations.push(`resize=w:${resizeWidth},h:${resizeHeight}`); | ||
} | ||
if (watermark) { | ||
transformations.push(`watermark=text:${watermark}`); | ||
} | ||
|
||
if (transformations.length > 0) { | ||
url += `?${transformations.join('&')}`; | ||
} | ||
|
||
document.getElementById('imagePreview').src = url; | ||
document.getElementById('status').textContent = 'File uploaded and transformed successfully!'; | ||
} catch (error) { | ||
console.error('Error:', error); | ||
document.getElementById('status').textContent = 'An error occurred while uploading the file.'; | ||
} | ||
}); |
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,76 @@ | ||
body { | ||
font-family: 'Arial', sans-serif; | ||
background: linear-gradient(135deg, #FF6F61, #FFB88C); | ||
color: #333; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
min-height: 100vh; | ||
margin: 0; | ||
} | ||
|
||
header { | ||
text-align: center; | ||
margin-bottom: 20px; | ||
} | ||
|
||
header h1 { | ||
font-size: 2.5em; | ||
color: #fff; | ||
} | ||
|
||
main { | ||
background: #fff; | ||
padding: 20px; | ||
border-radius: 10px; | ||
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); | ||
width: 400px; | ||
} | ||
|
||
form { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 10px; | ||
} | ||
|
||
input[type="file"], | ||
input[type="text"], | ||
input[type="number"] { | ||
padding: 10px; | ||
font-size: 1em; | ||
border: 1px solid #ccc; | ||
border-radius: 5px; | ||
} | ||
|
||
button { | ||
padding: 10px; | ||
font-size: 1em; | ||
color: #fff; | ||
background-color: #FF6F61; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
transition: background-color 0.3s; | ||
} | ||
|
||
button:hover { | ||
background-color: #FFB88C; | ||
} | ||
|
||
#status { | ||
margin-top: 10px; | ||
font-weight: bold; | ||
color: #FF6F61; | ||
} | ||
|
||
#transformed-image { | ||
margin-top: 20px; | ||
text-align: center; | ||
} | ||
|
||
#transformed-image img { | ||
max-width: 100%; | ||
border-radius: 10px; | ||
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); | ||
} |
Oops, something went wrong.