-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2171 from ORCID/lmendoza/WORDPRESS_HOME_PAGE
WORDPRESS_HOME_PAGE
- Loading branch information
Showing
16 changed files
with
6,833 additions
and
147 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Import fetch if it's not globally available (uncomment if needed) | ||
// const fetch = require('node-fetch'); | ||
const fs = require('fs') | ||
|
||
// URLs of the CSS files | ||
const cssUrls = [ | ||
'https://info.orcid.org/wp-content/themes/orcid-outreach-pro/style.css', | ||
'https://info.orcid.org/wp-includes/css/dist/block-library/style.css', | ||
'https://info.orcid.org/wp-content/plugins/genesis-blocks/dist/style-blocks.build.css', | ||
] | ||
|
||
// Function to fetch and combine CSS content | ||
async function fetchAndCombineCSS(urls) { | ||
let combinedCSS = '::ng-deep .wordpress-styles {\n' // Starting the wrapper class | ||
|
||
for (const url of urls) { | ||
try { | ||
const response = await fetch(url) | ||
let data = await response.text() | ||
data = data.replace(/@charset "UTF-8";\s*/g, '') // REMOVE CHARSET | ||
data = data.replace( | ||
/\} \*\/[\s\S]*?\/\* ROB 10\/07\/22 /g, | ||
'/* ROB 10/07/22 ' | ||
) // REMOVE A ERROR WITH THE ORIGINAL CSS | ||
data = data.replace(/.*\.png.*\n/g, '') // REMOBE IMAGES | ||
data = data.replace(/:root\s*\{([\s\S]*?)\}/g, '$1') // UNWRAPS THE :root variables | ||
|
||
combinedCSS += ` /* Content from ${url} */\n` | ||
combinedCSS += data + '\n' // Add the CSS content | ||
} catch (error) { | ||
console.error(`Failed to fetch CSS from ${url}: ${error}`) | ||
} | ||
} | ||
|
||
combinedCSS += '}' // Closing the wrapper class | ||
|
||
// Writing the combined CSS to a SCSS file | ||
fs.writeFile( | ||
'src/app/home/pages/home/wordpress-styles.scss', | ||
combinedCSS, | ||
(err) => { | ||
if (err) { | ||
console.error('Failed to write SCSS file:', err) | ||
} else { | ||
console.log('Successfully wrote combined.scss') | ||
} | ||
} | ||
) | ||
} | ||
|
||
// Run the function | ||
fetchAndCombineCSS(cssUrls) |
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 |
---|---|---|
@@ -1,3 +1,2 @@ | ||
// tslint:disable-next-line: max-line-length | ||
export const BROWSERLIST_REGEXP = | ||
/((CPU[ +]OS|iPhone[ +]OS|CPU[ +]iPhone|CPU IPhone OS)[ +]+(13[_.]4|13[_.]([5-9]|\d{2,})|13[_.]7|13[_.]([8-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})[_.]\d+|14[_.]0|14[_.]([1-9]|\d{2,})|14[_.]4|14[_.]([5-9]|\d{2,})|14[_.]8|14[_.](9|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})[_.]\d+|15[_.]0|15[_.]([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})[_.]\d+|16[_.]0|16[_.]([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})[_.]\d+|17[_.]0|17[_.]([1-9]|\d{2,})|(1[8-9]|[2-9]\d|\d{3,})[_.]\d+)(?:[_.]\d+)?)|((?:Chrome).*OPR\/(74|(7[5-9]|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Edge\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))(?:\.\d+)?)|((Chromium|Chrome)\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))\.\d+(?:\.\d+)?)|(Version\/(13\.1|13\.([2-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})\.\d+|14\.0|14\.([1-9]|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})\.\d+|15\.0|15\.([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})\.\d+|16\.0|16\.([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})\.\d+|17\.0|17\.([1-9]|\d{2,})|(1[8-9]|[2-9]\d|\d{3,})\.\d+)(?:\.\d+)? Safari\/)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+(pre|[ab]\d+[a-z]*)?)/ | ||
export const BROWSERLIST_REGEXP = /((CPU[ +]OS|iPhone[ +]OS|CPU[ +]iPhone|CPU IPhone OS)[ +]+(13[_.]4|13[_.]([5-9]|\d{2,})|13[_.]7|13[_.]([8-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})[_.]\d+|14[_.]0|14[_.]([1-9]|\d{2,})|14[_.]4|14[_.]([5-9]|\d{2,})|14[_.]8|14[_.](9|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})[_.]\d+|15[_.]0|15[_.]([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})[_.]\d+|16[_.]0|16[_.]([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})[_.]\d+|17[_.]0|17[_.]([1-9]|\d{2,})|(1[8-9]|[2-9]\d|\d{3,})[_.]\d+)(?:[_.]\d+)?)|((?:Chrome).*OPR\/(74|(7[5-9]|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Edge\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))(?:\.\d+)?)|((Chromium|Chrome)\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))\.\d+(?:\.\d+)?)|(Version\/(13\.1|13\.([2-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})\.\d+|14\.0|14\.([1-9]|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})\.\d+|15\.0|15\.([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})\.\d+|16\.0|16\.([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})\.\d+|17\.0|17\.([1-9]|\d{2,})|(1[8-9]|[2-9]\d|\d{3,})\.\d+)(?:\.\d+)? Safari\/)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+(pre|[ab]\d+[a-z]*)?)/ |
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,23 @@ | ||
import { TestBed } from '@angular/core/testing' | ||
|
||
import { WordpressService } from './wordpress.service' | ||
import { HttpClientTestingModule } from '@angular/common/http/testing' | ||
import { RouterTestingModule } from '@angular/router/testing' | ||
import { PlatformInfoService } from 'src/app/cdk/platform-info' | ||
import { WINDOW_PROVIDERS } from 'src/app/cdk/window' | ||
|
||
describe('WordpressService', () => { | ||
let service: WordpressService | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [HttpClientTestingModule, RouterTestingModule], | ||
providers: [WINDOW_PROVIDERS, PlatformInfoService], | ||
}) | ||
service = TestBed.inject(WordpressService) | ||
}) | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy() | ||
}) | ||
}) |
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,29 @@ | ||
import { HttpClient } from '@angular/common/http' | ||
import { Inject, Injectable, LOCALE_ID } from '@angular/core' | ||
import { WordpressPost } from 'src/app/types/wordpress' | ||
import { environment } from 'src/environments/environment' | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class WordpressService { | ||
constructor( | ||
private httpClient: HttpClient, | ||
@Inject(LOCALE_ID) public locale: string | ||
) {} | ||
|
||
getHomePagePost() { | ||
return this.httpClient.get<WordpressPost>( | ||
environment.WORDPRESS_API + | ||
this.getWordpressLocalizationCode() + | ||
'/wp-json/wp/v2/posts/' + | ||
(localStorage.getItem('homeId') || environment.WORDPRESS_API_HOME_ID) | ||
) | ||
} | ||
getWordpressLocalizationCode() { | ||
if (this.locale.includes('en')) { | ||
return '' | ||
} | ||
return this.locale | ||
} | ||
} |
Oops, something went wrong.