Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Google App Engine generated folder
appengine-generated/

# Node.js
node_modules/
npm-debug.log
# 🛡️ Sentinel: Standard security-focused ignores
node_modules/
dist/
Expand Down
28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
# eco-growth
uncover your story
ontdek je verhaal
# Eco-growth Discovery

## About
`Template.pptm` is a PowerPoint macro-enabled template for Microsoft Office Web Extensions.
Uncover your story with Eco-growth Discovery, a PowerPoint Add-in designed to explore data and narratives.

## New Features: Jules API Integration
The add-in now integrates with the **Jules API** to fetch and display "sources" directly within PowerPoint.

### How it works:
1. **Authentication**: Uses `Office.auth.getAccessToken()` to securely retrieve an OAuth2 token.
2. **Data Retrieval**: Fetches sources from `https://jules.googleapis.com/v1alpha/sources` using the authenticated token.
3. **Visualization**: Dynamically renders the retrieved sources in the task pane.

## Getting Started
1. Run `npm install` to install dependencies.
2. Run `npm start` to start the local development server.
3. Side-load the `manifest.xml` in PowerPoint to start using the extension.
# master
1. Run `npm install` to install dependencies (including `jest` for testing).
2. Run `npm start` to start the local development server on port 3000.
3. Run `npm test` to execute unit tests.
4. Side-load the `manifest.xml` in PowerPoint to start using the extension.

## Development
- `index.html`: The main task pane UI.
- `index.js`: Core logic for authentication, API calls, and UI rendering.
- `api.test.js`: Unit tests for the API integration.
42 changes: 42 additions & 0 deletions api.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const { getAuthToken, fetchSources } = require('./index-test-wrapper.js');

describe('Jules API Integration', () => {
beforeEach(() => {
global.fetch = jest.fn();
global.Office = {
auth: {
getAccessToken: jest.fn()
}
};
global.console = {
log: jest.fn(),
error: jest.fn(),
warn: jest.fn()
};
});

test('getAuthToken calls Office.auth.getAccessToken', async () => {
global.Office.auth.getAccessToken.mockResolvedValue('fake-token');
const token = await getAuthToken();
expect(token).toBe('fake-token');
expect(global.Office.auth.getAccessToken).toHaveBeenCalled();
});

test('fetchSources calls fetch with correct headers', async () => {
global.fetch.mockResolvedValue({
ok: true,
json: jest.fn().mockResolvedValue({ sources: ['source1'] })
});

const data = await fetchSources('fake-token');
expect(data.sources).toContain('source1');
expect(global.fetch).toHaveBeenCalledWith(
'https://jules.googleapis.com/v1alpha/sources',
expect.objectContaining({
headers: expect.objectContaining({
'Authorization': 'Bearer fake-token'
})
})
);
});
});
38 changes: 38 additions & 0 deletions index-test-wrapper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Wrapper for index.js to allow testing in Node.js
// In a real project, we'd use modules, but here we just copy the functions
// for the sake of the test script.

async function getAuthToken() {
try {
if (global.Office && global.Office.auth && global.Office.auth.getAccessToken) {
return await global.Office.auth.getAccessToken();
}
console.warn("Office.auth.getAccessToken is not available in this environment.");
return null;
} catch (error) {
console.error("Error getting access token:", error);
return null;
}
}

async function fetchSources(token) {
try {
const response = await fetch("https://jules.googleapis.com/v1alpha/sources", {
headers: {
"Authorization": `Bearer ${token}`,
"Content-Type": "application/json"
}
});

if (!response.ok) {
throw new Error(`API request failed with status ${response.status}`);
}

return await response.json();
} catch (error) {
console.error("Error fetching sources:", error);
return null;
}
}

module.exports = { getAuthToken, fetchSources };
40 changes: 40 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,43 @@
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<title>Eco-growth Discovery</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
margin: 20px;
text-align: center;
}
#initials-display {
display: inline-block;
width: 50px;
height: 50px;
line-height: 50px;
border-radius: 50%;
background-color: #0078d4;
color: white;
text-align: center;
font-weight: bold;
font-size: 20px;
margin-top: 20px;
}
.label {
font-size: 14px;
color: #666;
margin-top: 10px;
}
#api-response-display {
margin-top: 30px;
text-align: left;
border: 1px solid #ccc;
padding: 10px;
border-radius: 4px;
min-height: 100px;
}
.source-item {
padding: 5px;
border-bottom: 1px solid #eee;
}
</style>
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' https://appsforoffice.microsoft.com; style-src 'self'; object-src 'none'; base-uri 'self';" />
<link rel="stylesheet" type="text/css" href="index.css">
<script src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js" type="text/javascript"></script>
Expand All @@ -16,5 +53,8 @@ <h1>Eco-growth Discovery</h1>

<div class="label">Co Op Initials</div>
<div id="initials-display">--</div>

<div class="label">Jules API Sources</div>
<div id="api-response-display">Loading sources...</div>
</body>
</html>
1 change: 1 addition & 0 deletions manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
xsi:type="TaskPaneApp">
<Id>47adf105-bcee-4e37-bf03-b5d0c15d7aee</Id>
<Version>1.0.0.0</Version>
<ProviderName>JulienVink</ProviderName>
<ProviderName>ZinoFlo</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<DisplayName DefaultValue="Eco-growth Discovery" />
Expand Down
Loading