Sample: rss reader - upgrade to spfx 1.18.2
This commit is contained in:
parent
72bb01cafc
commit
12ac47d6d7
|
@ -0,0 +1,353 @@
|
|||
require('@rushstack/eslint-config/patch/modern-module-resolution');
|
||||
module.exports = {
|
||||
extends: ['@microsoft/eslint-config-spfx/lib/profiles/react'],
|
||||
parserOptions: { tsconfigRootDir: __dirname },
|
||||
overrides: [
|
||||
{
|
||||
files: ['*.ts', '*.tsx'],
|
||||
parser: '@typescript-eslint/parser',
|
||||
'parserOptions': {
|
||||
'project': './tsconfig.json',
|
||||
'ecmaVersion': 2018,
|
||||
'sourceType': 'module'
|
||||
},
|
||||
rules: {
|
||||
// Prevent usage of the JavaScript null value, while allowing code to access existing APIs that may require null. https://www.npmjs.com/package/@rushstack/eslint-plugin
|
||||
'@rushstack/no-new-null': 1,
|
||||
// Require Jest module mocking APIs to be called before any other statements in their code block. https://www.npmjs.com/package/@rushstack/eslint-plugin
|
||||
'@rushstack/hoist-jest-mock': 1,
|
||||
// Require regular expressions to be constructed from string constants rather than dynamically building strings at runtime. https://www.npmjs.com/package/@rushstack/eslint-plugin-security
|
||||
'@rushstack/security/no-unsafe-regexp': 0,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/adjacent-overload-signatures': 1,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
//
|
||||
// CONFIGURATION: By default, these are banned: String, Boolean, Number, Object, Symbol
|
||||
'@typescript-eslint/ban-types': [
|
||||
1,
|
||||
{
|
||||
'extendDefaults': false,
|
||||
'types': {
|
||||
'String': {
|
||||
'message': 'Use \'string\' instead',
|
||||
'fixWith': 'string'
|
||||
},
|
||||
'Boolean': {
|
||||
'message': 'Use \'boolean\' instead',
|
||||
'fixWith': 'boolean'
|
||||
},
|
||||
'Number': {
|
||||
'message': 'Use \'number\' instead',
|
||||
'fixWith': 'number'
|
||||
},
|
||||
'Object': {
|
||||
'message': 'Use \'object\' instead, or else define a proper TypeScript type:'
|
||||
},
|
||||
'Symbol': {
|
||||
'message': 'Use \'symbol\' instead',
|
||||
'fixWith': 'symbol'
|
||||
},
|
||||
'Function': {
|
||||
'message': 'The \'Function\' type accepts any function-like value.\nIt provides no type safety when calling the function, which can be a common source of bugs.\nIt also accepts things like class declarations, which will throw at runtime as they will not be called with \'new\'.\nIf you are expecting the function to accept certain arguments, you should explicitly define the function shape.'
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
// RATIONALE: Code is more readable when the type of every variable is immediately obvious.
|
||||
// Even if the compiler may be able to infer a type, this inference will be unavailable
|
||||
// to a person who is reviewing a GitHub diff. This rule makes writing code harder,
|
||||
// but writing code is a much less important activity than reading it.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/explicit-function-return-type': [
|
||||
1,
|
||||
{
|
||||
'allowExpressions': true,
|
||||
'allowTypedFunctionExpressions': true,
|
||||
'allowHigherOrderFunctions': false
|
||||
}
|
||||
],
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
// Rationale to disable: although this is a recommended rule, it is up to dev to select coding style.
|
||||
// Set to 1 (warning) or 2 (error) to enable.
|
||||
'@typescript-eslint/explicit-member-accessibility': 0,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/no-array-constructor': 1,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
//
|
||||
// RATIONALE: The "any" keyword disables static type checking, the main benefit of using TypeScript.
|
||||
// This rule should be suppressed only in very special cases such as JSON.stringify()
|
||||
// where the type really can be anything. Even if the type is flexible, another type
|
||||
// may be more appropriate such as "unknown", "{}", or "Record<k,V>".
|
||||
'@typescript-eslint/no-explicit-any': 0,
|
||||
// RATIONALE: The #1 rule of promises is that every promise chain must be terminated by a catch()
|
||||
// handler. Thus wherever a Promise arises, the code must either append a catch handler,
|
||||
// or else return the object to a caller (who assumes this responsibility). Unterminated
|
||||
// promise chains are a serious issue. Besides causing errors to be silently ignored,
|
||||
// they can also cause a NodeJS process to terminate unexpectedly.
|
||||
'@typescript-eslint/no-floating-promises': 0,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'@typescript-eslint/no-for-in-array': 2,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/no-misused-new': 2,
|
||||
// RATIONALE: The "namespace" keyword is not recommended for organizing code because JavaScript lacks
|
||||
// a "using" statement to traverse namespaces. Nested namespaces prevent certain bundler
|
||||
// optimizations. If you are declaring loose functions/variables, it's better to make them
|
||||
// static members of a class, since classes support property getters and their private
|
||||
// members are accessible by unit tests. Also, the exercise of choosing a meaningful
|
||||
// class name tends to produce more discoverable APIs: for example, search+replacing
|
||||
// the function "reverse()" is likely to return many false matches, whereas if we always
|
||||
// write "Text.reverse()" is more unique. For large scale organization, it's recommended
|
||||
// to decompose your code into separate NPM packages, which ensures that component
|
||||
// dependencies are tracked more conscientiously.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/no-namespace': [
|
||||
1,
|
||||
{
|
||||
'allowDeclarations': false,
|
||||
'allowDefinitionFiles': false
|
||||
}
|
||||
],
|
||||
// RATIONALE: Parameter properties provide a shorthand such as "constructor(public title: string)"
|
||||
// that avoids the effort of declaring "title" as a field. This TypeScript feature makes
|
||||
// code easier to write, but arguably sacrifices readability: In the notes for
|
||||
// "@typescript-eslint/member-ordering" we pointed out that fields are central to
|
||||
// a class's design, so we wouldn't want to bury them in a constructor signature
|
||||
// just to save some typing.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
// Set to 1 (warning) or 2 (error) to enable the rule
|
||||
'@typescript-eslint/parameter-properties': 0,
|
||||
// RATIONALE: When left in shipping code, unused variables often indicate a mistake. Dead code
|
||||
// may impact performance.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
0,
|
||||
{
|
||||
'vars': 'all',
|
||||
// Unused function arguments often indicate a mistake in JavaScript code. However in TypeScript code,
|
||||
// the compiler catches most of those mistakes, and unused arguments are fairly common for type signatures
|
||||
// that are overriding a base class method or implementing an interface.
|
||||
'args': 'none'
|
||||
}
|
||||
],
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/no-use-before-define': [
|
||||
2,
|
||||
{
|
||||
'functions': false,
|
||||
'classes': true,
|
||||
'variables': true,
|
||||
'enums': true,
|
||||
'typedefs': true
|
||||
}
|
||||
],
|
||||
// Disallows require statements except in import statements.
|
||||
// In other words, the use of forms such as var foo = require("foo") are banned. Instead use ES6 style imports or import foo = require("foo") imports.
|
||||
'@typescript-eslint/no-var-requires': 'error',
|
||||
// RATIONALE: The "module" keyword is deprecated except when describing legacy libraries.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/prefer-namespace-keyword': 1,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
// Rationale to disable: it's up to developer to decide if he wants to add type annotations
|
||||
// Set to 1 (warning) or 2 (error) to enable the rule
|
||||
'@typescript-eslint/no-inferrable-types': 0,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
// Rationale to disable: declaration of empty interfaces may be helpful for generic types scenarios
|
||||
'@typescript-eslint/no-empty-interface': 0,
|
||||
// RATIONALE: This rule warns if setters are defined without getters, which is probably a mistake.
|
||||
'accessor-pairs': 1,
|
||||
// RATIONALE: In TypeScript, if you write x["y"] instead of x.y, it disables type checking.
|
||||
'dot-notation': [
|
||||
1,
|
||||
{
|
||||
'allowPattern': '^_'
|
||||
}
|
||||
],
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
'eqeqeq': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'for-direction': 1,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'guard-for-in': 2,
|
||||
// RATIONALE: If you have more than 2,000 lines in a single source file, it's probably time
|
||||
// to split up your code.
|
||||
'max-lines': ['warn', { max: 2000 }],
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-async-promise-executor': 0,
|
||||
// RATIONALE: Deprecated language feature.
|
||||
'no-caller': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-compare-neg-zero': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-cond-assign': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-constant-condition': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-control-regex': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-debugger': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-delete-var': 2,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-duplicate-case': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-empty': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-empty-character-class': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-empty-pattern': 1,
|
||||
// RATIONALE: Eval is a security concern and a performance concern.
|
||||
'no-eval': 1,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-ex-assign': 2,
|
||||
// RATIONALE: System types are global and should not be tampered with in a scalable code base.
|
||||
// If two different libraries (or two versions of the same library) both try to modify
|
||||
// a type, only one of them can win. Polyfills are acceptable because they implement
|
||||
// a standardized interoperable contract, but polyfills are generally coded in plain
|
||||
// JavaScript.
|
||||
'no-extend-native': 1,
|
||||
// Disallow unnecessary labels
|
||||
'no-extra-label': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-fallthrough': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-func-assign': 1,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-implied-eval': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-invalid-regexp': 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-label-var': 2,
|
||||
// RATIONALE: Eliminates redundant code.
|
||||
'no-lone-blocks': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-misleading-character-class': 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-multi-str': 2,
|
||||
// RATIONALE: It's generally a bad practice to call "new Thing()" without assigning the result to
|
||||
// a variable. Either it's part of an awkward expression like "(new Thing()).doSomething()",
|
||||
// or else implies that the constructor is doing nontrivial computations, which is often
|
||||
// a poor class design.
|
||||
'no-new': 1,
|
||||
// RATIONALE: Obsolete language feature that is deprecated.
|
||||
'no-new-func': 2,
|
||||
// RATIONALE: Obsolete language feature that is deprecated.
|
||||
'no-new-object': 2,
|
||||
// RATIONALE: Obsolete notation.
|
||||
'no-new-wrappers': 1,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-octal': 2,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
'no-octal-escape': 2,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-regex-spaces': 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-return-assign': 0,
|
||||
// RATIONALE: Security risk.
|
||||
'no-script-url': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-self-assign': 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-self-compare': 2,
|
||||
// RATIONALE: This avoids statements such as "while (a = next(), a && a.length);" that use
|
||||
// commas to create compound expressions. In general code is more readable if each
|
||||
// step is split onto a separate line. This also makes it easier to set breakpoints
|
||||
// in the debugger.
|
||||
'no-sequences': 1,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-shadow-restricted-names': 2,
|
||||
// RATIONALE: Obsolete language feature that is deprecated.
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-sparse-arrays': 2,
|
||||
// RATIONALE: Although in theory JavaScript allows any possible data type to be thrown as an exception,
|
||||
// such flexibility adds pointless complexity, by requiring every catch block to test
|
||||
// the type of the object that it receives. Whereas if catch blocks can always assume
|
||||
// that their object implements the "Error" contract, then the code is simpler, and
|
||||
// we generally get useful additional information like a call stack.
|
||||
'no-throw-literal': 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-unmodified-loop-condition': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-unsafe-finally': 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-unused-expressions': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-unused-labels': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-useless-catch': 0,
|
||||
// RATIONALE: Avoids a potential performance problem.
|
||||
'no-useless-concat': 1,
|
||||
// RATIONALE: The "var" keyword is deprecated because of its confusing "hoisting" behavior.
|
||||
// Always use "let" or "const" instead.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'no-var': 2,
|
||||
// RATIONALE: Generally not needed in modern code.
|
||||
'no-void': 1,
|
||||
// RATIONALE: Obsolete language feature that is deprecated.
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-with': 2,
|
||||
// RATIONALE: Makes logic easier to understand, since constants always have a known value
|
||||
// @typescript-eslint\eslint-plugin\dist\configs\eslint-recommended.js
|
||||
'prefer-const': 1,
|
||||
// RATIONALE: Catches a common coding mistake where "resolve" and "reject" are confused.
|
||||
'promise/param-names': 2,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'require-atomic-updates': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'require-yield': 1,
|
||||
// "Use strict" is redundant when using the TypeScript compiler.
|
||||
'strict': [
|
||||
2,
|
||||
'never'
|
||||
],
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'use-isnan': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
// Set to 1 (warning) or 2 (error) to enable.
|
||||
// Rationale to disable: !!{}
|
||||
'no-extra-boolean-cast': 0,
|
||||
// ====================================================================
|
||||
// @microsoft/eslint-plugin-spfx
|
||||
// ====================================================================
|
||||
'@microsoft/spfx/import-requires-chunk-name': 1,
|
||||
'@microsoft/spfx/no-require-ensure': 2,
|
||||
'@microsoft/spfx/pair-react-dom-render-unmount': 1,
|
||||
'react/self-closing-comp': 'off'
|
||||
}
|
||||
},
|
||||
{
|
||||
// For unit tests, we can be a little bit less strict. The settings below revise the
|
||||
// defaults specified in the extended configurations, as well as above.
|
||||
files: [
|
||||
// Test files
|
||||
'*.test.ts',
|
||||
'*.test.tsx',
|
||||
'*.spec.ts',
|
||||
'*.spec.tsx',
|
||||
|
||||
// Facebook convention
|
||||
'**/__mocks__/*.ts',
|
||||
'**/__mocks__/*.tsx',
|
||||
'**/__tests__/*.ts',
|
||||
'**/__tests__/*.tsx',
|
||||
|
||||
// Microsoft convention
|
||||
'**/test/*.ts',
|
||||
'**/test/*.tsx'
|
||||
],
|
||||
rules: {}
|
||||
}
|
||||
]
|
||||
};
|
|
@ -9,9 +9,10 @@ node_modules
|
|||
# Build generated files
|
||||
dist
|
||||
lib
|
||||
solution
|
||||
temp
|
||||
*.sppkg
|
||||
.heft
|
||||
release
|
||||
package-lock.json
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
!dist
|
||||
config
|
||||
|
||||
gulpfile.js
|
||||
|
||||
release
|
||||
src
|
||||
temp
|
||||
|
||||
tsconfig.json
|
||||
tslint.json
|
||||
|
||||
*.log
|
||||
|
||||
.yo-rc.json
|
||||
.vscode
|
|
@ -2,11 +2,16 @@
|
|||
"@microsoft/generator-sharepoint": {
|
||||
"isCreatingSolution": true,
|
||||
"environment": "spo",
|
||||
"version": "1.11.0",
|
||||
"version": "1.18.2",
|
||||
"libraryName": "react-rssreader",
|
||||
"libraryId": "fcb53167-e0d5-4ed1-9648-149146649aa1",
|
||||
"packageManager": "npm",
|
||||
"isDomainIsolated": false,
|
||||
"componentType": "webpart"
|
||||
"componentType": "webpart",
|
||||
"nodeVersion": "18.17.1",
|
||||
"sdkVersions": {
|
||||
"@microsoft/teams-js": "2.12.0",
|
||||
"@microsoft/microsoft-graph-client": "3.0.2"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
A RSS Reader original based [on work by Olivier Carpentier](https://github.com/OlivierCC/spfx-40-fantastics/tree/master/src/webparts/rssReader), part of the [SPFx Fantastic 40 Web Parts](https://github.com/OlivierCC/spfx-40-fantastics)
|
||||
|
||||
This RSS Reader utilizes SharePoint Framework v1.11.0 with no dependency on jQuery or a RSS Feed library. This project does utilize [
|
||||
@pnp/spfx-property-controls](https://sharepoint.github.io/sp-dev-fx-property-controls/), and Moment React for date manipulation. Handlebar template option derived from React Search Refiners ([PnP Modern Search](https://microsoft-search.github.io/pnp-modern-search/)) . Use NodeJS version 10 to compile or rebuild the SPFx solution.
|
||||
This RSS Reader utilizes SharePoint Framework v1.18.2 with no dependency on jQuery or a RSS Feed library. This project does utilize [
|
||||
@pnp/spfx-property-controls](https://sharepoint.github.io/sp-dev-fx-property-controls/), and Moment React for date manipulation. Handlebar template option derived from React Search Refiners ([PnP Modern Search](https://microsoft-search.github.io/pnp-modern-search/)). Use NodeJS version 18 (validated using v18.17.1) to compile or rebuild the SPFx solution.
|
||||
|
||||
Main features include:
|
||||
|
||||
|
@ -27,17 +27,16 @@ Main features include:
|
|||
| Every SPFx version is only compatible with specific version(s) of Node.js. In order to be able to build this sample, please ensure that the version of Node on your workstation matches one of the versions listed in this section. This sample will not work on a different version of Node.|
|
||||
|Refer to <https://aka.ms/spfx-matrix> for more information on SPFx compatibility. |
|
||||
|
||||
![SPFx 1.11](https://img.shields.io/badge/SPFx-1.11.0-green.svg)
|
||||
![Node.js v10](https://img.shields.io/badge/Node.js-v10-green.svg)
|
||||
![SPFx 1.18.2](https://img.shields.io/badge/SPFx-1.18.2-green.svg)
|
||||
![Node.js v18](https://img.shields.io/badge/Node.js-v18-green.svg)
|
||||
![Compatible with SharePoint Online](https://img.shields.io/badge/SharePoint%20Online-Compatible-green.svg)
|
||||
![Does not work with SharePoint 2019](https://img.shields.io/badge/SharePoint%20Server%202019-Incompatible-red.svg "SharePoint Server 2019 requires SPFx 1.4.1 or lower")
|
||||
![Does not work with SharePoint 2016 (Feature Pack 2)](https://img.shields.io/badge/SharePoint%20Server%202016%20(Feature%20Pack%202)-Incompatible-red.svg "SharePoint Server 2016 Feature Pack 2 requires SPFx 1.1")
|
||||
![Teams Incompatible](https://img.shields.io/badge/Teams-Incompatible-lightgrey.svg)
|
||||
![Local Workbench Compatible](https://img.shields.io/badge/Local%20Workbench-Compatible-green.svg)
|
||||
![Hosted Workbench Compatible](https://img.shields.io/badge/Hosted%20Workbench-Compatible-green.svg)
|
||||
![Compatible with Remote Containers](https://img.shields.io/badge/Remote%20Containers-Compatible-green.svg)
|
||||
|
||||
Tested with: Node.js v10.16.3
|
||||
Tested with: Node.js v18.17.1
|
||||
|
||||
## Applies to
|
||||
|
||||
|
@ -60,6 +59,7 @@ Version|Date|Comments
|
|||
1.0.2 | April 6, 2023 | Fix bug in Direct request retrieval service
|
||||
1.0.3 | April 21, 2023 | Added theme awareness
|
||||
1.0.4 | May 25, 2023 | Fixed direct request issues
|
||||
1.1.0 | February 6, 2024 | Upgraded to SPFx 1.18.2
|
||||
|
||||
## Minimal Path to Awesome
|
||||
|
||||
|
@ -69,7 +69,7 @@ Version|Date|Comments
|
|||
|
||||
### SPFx
|
||||
|
||||
- In the command line, with a version of Node 10, i.e. 10.16.3, run:
|
||||
- In the command line, with a version of Node 18, i.e. 18.17.1, run:
|
||||
- `npm install`
|
||||
- `gulp serve`
|
||||
|
||||
|
@ -91,13 +91,13 @@ Feed URL | The URL of the RSS Feed for readers. Normally will URL will return XM
|
|||
Feed Retrieval Service | The service to use to retrieve the feed. **Direct** = Make a direct call from the web part to the feed. Note, may have issues with CORS depending on the feed owner. **Feed2Json** = Retrieve a JSON version of feed via feed2json.org. Note, not for production, and may have issues with CORS. For production use, host your own feed2json service. Learn more at https://github.com/appsattic/feed2json.org. **Rss2Json** = CORS safe method to retieve a feed response. Note, subject to limitations with paid options available.
|
||||
Feed Service URL | If using Feed2Json, the URL of the feed2json service. Host your own service, learn more at https://github.com/appsattic/feed2json.org
|
||||
Feed Service API Key | If using rss2json, an optional API key for paid services
|
||||
Max Count | The maximum results to return, default: 10
|
||||
Max Count | The maximum results to return, default: 10. **Note** When using the free versions of feed2json or rss2json, results are limited to 10 or less by the services.
|
||||
Cache Results | Locally store results in browser local storage, default: no
|
||||
Mins to Cache Results | If storing results in browser, number of minutes to store. Valid 1 to 1440 (one day), default: 60
|
||||
Storage Key Prefix | An optional local storage key prefix to use when storing results
|
||||
Loading Message | An optional custom message to display while the RSS feed is being loaded
|
||||
Use a CORS proxy | Use a CORS proxy to assist with feed retrieval, default: no
|
||||
CORS Proxy URL | The URL of a CORS proxy if allowed. {0} will be replaced with Feed URL, i.e. https://cors-anywhere.herokuapp.com/{0}
|
||||
CORS Proxy URL | The URL of a CORS proxy if allowed. {0} will be replaced with Feed URL, i.e. https://cors-anywhere.herokuapp.com/{0}. To use CORS anywhere by Herokuapp for testing, be sure to visit ![https://cors-anywhere.herokuapp.com](https://cors-anywhere.herokuapp.com) first to unlock yourself for testing.
|
||||
Disable CORS | Set request header mode to "no-cors", thus not requesting CORS response from service. Will disable CORS request, default: no
|
||||
|
||||
#### Styling Options
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/copy-assets.schema.json",
|
||||
"deployCdnPath": "temp/deploy"
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
|
||||
"workingDir": "./temp/deploy/",
|
||||
"workingDir": "./release/assets/",
|
||||
"account": "<!-- STORAGE ACCOUNT NAME -->",
|
||||
"container": "react-rssreader",
|
||||
"accessKey": "<!-- ACCESS KEY -->"
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
|
||||
"solution": {
|
||||
"name": "react-rssreader-client-side-solution",
|
||||
"name": "PnP Sample - React RssReader",
|
||||
"id": "fcb53167-e0d5-4ed1-9648-149146649aa1",
|
||||
"version": "1.0.2.0",
|
||||
"version": "1.1.0.0",
|
||||
"developer": {
|
||||
"name": "Eric Overfield",
|
||||
"privacyUrl": "https://contoso.com/privacy",
|
||||
|
@ -13,7 +13,29 @@
|
|||
},
|
||||
"includeClientSideAssets": true,
|
||||
"skipFeatureDeployment": true,
|
||||
"isDomainIsolated": false
|
||||
"isDomainIsolated": false,
|
||||
"metadata": {
|
||||
"shortDescription": {
|
||||
"default": "react-rssreader description"
|
||||
},
|
||||
"longDescription": {
|
||||
"default": "react-rssreader description"
|
||||
},
|
||||
"screenshotPaths": [],
|
||||
"videoUrl": "",
|
||||
"categories": []
|
||||
},
|
||||
"features": [
|
||||
{
|
||||
"title": "PnP Sample - React RssReader Webpart Feature",
|
||||
"description": "The feature that activates RssReaderWebPart from the PnP Sample - React RssReader solution.",
|
||||
"id": "f489b1fd-98bf-4b41-8db0-85d5018ba484",
|
||||
"version": "1.1.0.0",
|
||||
"componentIds": [
|
||||
"f489b1fd-98bf-4b41-8db0-85d5018ba484"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"paths": {
|
||||
"zippedPackage": "solution/react-rssreader.sppkg"
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/core-build/sass.schema.json"
|
||||
}
|
|
@ -1,10 +1,6 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/core-build/serve.schema.json",
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/spfx-serve.schema.json",
|
||||
"port": 4321,
|
||||
"https": true,
|
||||
"initialPage": "https://localhost:5432/workbench",
|
||||
"api": {
|
||||
"port": 5432,
|
||||
"entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/"
|
||||
}
|
||||
"initialPage": "https://{tenantDomain}/_layouts/workbench.aspx"
|
||||
}
|
||||
|
|
|
@ -47,4 +47,15 @@ build.configureWebpack.mergeConfig({
|
|||
}
|
||||
});
|
||||
|
||||
var getTasks = build.rig.getTasks;
|
||||
build.rig.getTasks = function () {
|
||||
var result = getTasks.call(build.rig);
|
||||
|
||||
result.set('serve', result.get('serve-deprecated'));
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
// build.tslintCmd.enabled = false;
|
||||
|
||||
build.initialize(gulp);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"name": "react-rssreader",
|
||||
"version": "1.0.0",
|
||||
"version": "1.1.0",
|
||||
"private": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
"node": "18.17.1"
|
||||
},
|
||||
"resolutions": {
|
||||
"@types/react": "16.8.8"
|
||||
|
@ -15,41 +15,44 @@
|
|||
"test": "gulp test"
|
||||
},
|
||||
"dependencies": {
|
||||
"@microsoft/sp-core-library": "1.11.0",
|
||||
"@microsoft/sp-lodash-subset": "1.11.0",
|
||||
"@microsoft/sp-office-ui-fabric-core": "1.11.0",
|
||||
"@microsoft/sp-property-pane": "1.11.0",
|
||||
"@microsoft/sp-webpart-base": "1.11.0",
|
||||
"@pnp/common": "1.2.6",
|
||||
"@pnp/logging": "1.2.6",
|
||||
"@pnp/spfx-controls-react": "^2.10.0",
|
||||
"@pnp/spfx-property-controls": "1.12.0",
|
||||
"@fluentui/react": "8.106.4",
|
||||
"@microsoft/sp-core-library": "1.18.2",
|
||||
"@microsoft/sp-lodash-subset": "1.18.2",
|
||||
"@microsoft/sp-office-ui-fabric-core": "1.18.2",
|
||||
"@microsoft/sp-property-pane": "1.18.2",
|
||||
"@microsoft/sp-webpart-base": "1.18.2",
|
||||
"@pnp/logging": "3.22.0",
|
||||
"@pnp/spfx-controls-react": "^3.17.0",
|
||||
"@pnp/spfx-property-controls": "3.16.0",
|
||||
"@types/handlebars": "4.0.39",
|
||||
"ace-builds": "1.32.5",
|
||||
"common-tags": "1.8.0",
|
||||
"handlebars": "4.7.7",
|
||||
"handlebars-helpers": "^0.8.4",
|
||||
"moment": "2.22.2",
|
||||
"office-ui-fabric-react": "6.214.0",
|
||||
"react": "16.8.5",
|
||||
"react-dom": "16.8.5",
|
||||
"react-moment": "0.8.3",
|
||||
"moment": "2.29.0",
|
||||
"react": "17.0.1",
|
||||
"react-ace": "10.1.0",
|
||||
"react-dom": "17.0.1",
|
||||
"react-moment": "1.1.3",
|
||||
"ts-md5": "1.2.4",
|
||||
"tslib": "2.3.1",
|
||||
"xml2js": "0.4.19"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@microsoft/rush-stack-compiler-3.3": "0.3.5",
|
||||
"@microsoft/sp-build-web": "1.18.0",
|
||||
"@microsoft/sp-module-interfaces": "1.11.0",
|
||||
"@microsoft/sp-tslint-rules": "1.11.0",
|
||||
"@microsoft/sp-webpart-workbench": "1.12.1",
|
||||
"@types/chai": "3.4.34",
|
||||
"@types/es6-promise": "0.0.33",
|
||||
"@types/mocha": "2.2.38",
|
||||
"@types/react": "16.8.8",
|
||||
"@types/react-dom": "16.8.3",
|
||||
"@types/webpack-env": "1.13.1",
|
||||
"ajv": "~5.2.2",
|
||||
"gulp": "~3.9.1",
|
||||
"@microsoft/eslint-config-spfx": "1.18.2",
|
||||
"@microsoft/eslint-plugin-spfx": "1.18.2",
|
||||
"@microsoft/rush-stack-compiler-4.7": "0.1.0",
|
||||
"@microsoft/sp-build-web": "1.18.2",
|
||||
"@microsoft/sp-module-interfaces": "1.18.2",
|
||||
"@rushstack/eslint-config": "2.5.1",
|
||||
"@types/react": "17.0.45",
|
||||
"@types/react-dom": "17.0.17",
|
||||
"@types/webpack-env": "1.15.2",
|
||||
"ajv": "6.12.5",
|
||||
"eslint": "8.7.0",
|
||||
"eslint-plugin-react-hooks": "4.3.0",
|
||||
"gulp": "4.0.2",
|
||||
"typescript": "4.7.4",
|
||||
"unlazy-loader": "0.1.3",
|
||||
"webpack-bundle-analyzer": "^3.0.3"
|
||||
}
|
||||
|
|
|
@ -63,6 +63,9 @@ export class PropertyPaneTextDialog implements IPropertyPaneField<IPropertyPaneT
|
|||
ReactDom.render(textDialog, elem);
|
||||
}
|
||||
|
||||
protected onDispose(): void {
|
||||
ReactDom.unmountComponentAtNode(this.elem);
|
||||
}
|
||||
|
||||
/*****************************************************************************************
|
||||
* Call the property pane's onPropertyChange when the TextDialog changes
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
@import '~@fluentui/react/dist/sass/References.scss';
|
||||
|
||||
.ace_editor.ace_autocomplete {
|
||||
z-index: 2000000 !important;
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
@import '~@fluentui/react/dist/sass/References.scss';
|
||||
|
||||
.textDialog {
|
||||
max-width: 100%;
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
import * as React from 'react';
|
||||
import AceEditor from 'react-ace';
|
||||
import { Dialog, DialogType, DialogFooter } from 'office-ui-fabric-react/lib/Dialog';
|
||||
import { Button, ButtonType } from 'office-ui-fabric-react/lib/Button';
|
||||
import { Label } from 'office-ui-fabric-react/lib/Label';
|
||||
import { Dialog, DialogType, DialogFooter } from '@fluentui/react/lib/Dialog';
|
||||
import { Button, ButtonType } from '@fluentui/react/lib/Button';
|
||||
import { Label } from '@fluentui/react/lib/Label';
|
||||
import { ITextDialogProps } from './ITextDialogProps';
|
||||
import { ITextDialogState } from './ITextDialogState';
|
||||
import styles from './TextDialog.module.scss';
|
||||
|
@ -29,7 +29,7 @@ export class TextDialog extends React.Component<ITextDialogProps, ITextDialogSta
|
|||
/*************************************************************************************
|
||||
* Shows the dialog
|
||||
*************************************************************************************/
|
||||
private showDialog() {
|
||||
private showDialog(): void {
|
||||
this.setState({ dialogText: this.state.dialogText, showDialog: true });
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ export class TextDialog extends React.Component<ITextDialogProps, ITextDialogSta
|
|||
/*************************************************************************************
|
||||
* Notifies the parent with the dialog's latest value, then closes the dialog
|
||||
*************************************************************************************/
|
||||
private saveDialog() {
|
||||
private saveDialog(): void {
|
||||
this.setState({ dialogText: this.state.dialogText, showDialog: false });
|
||||
|
||||
if(this.props.onChanged) {
|
||||
|
@ -49,7 +49,7 @@ export class TextDialog extends React.Component<ITextDialogProps, ITextDialogSta
|
|||
/*************************************************************************************
|
||||
* Closes the dialog without notifying the parent for any changes
|
||||
*************************************************************************************/
|
||||
private cancelDialog() {
|
||||
private cancelDialog(): void {
|
||||
this.setState({ dialogText: this.state.dialogText, showDialog: false });
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ export class TextDialog extends React.Component<ITextDialogProps, ITextDialogSta
|
|||
/*************************************************************************************
|
||||
* Updates the dialog's value each time the textfield changes
|
||||
*************************************************************************************/
|
||||
private onDialogTextChanged(newValue: string) {
|
||||
private onDialogTextChanged(newValue: string): void {
|
||||
this.setState({ dialogText: newValue, showDialog: this.state.showDialog });
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ export class TextDialog extends React.Component<ITextDialogProps, ITextDialogSta
|
|||
/*************************************************************************************
|
||||
* Renders the the TextDialog component
|
||||
*************************************************************************************/
|
||||
public render() {
|
||||
public render(): any {
|
||||
return (
|
||||
<div>
|
||||
<Label>{ this.props.strings.dialogButtonLabel }</Label>
|
||||
|
|
|
@ -10,8 +10,8 @@ export class DomHelper {
|
|||
* @param callback the callback function
|
||||
* @param scope the scope
|
||||
*/
|
||||
public static forEach(array, callback, scope?) {
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
public static forEach(array: any, callback: any, scope?: any): void {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
callback.call(scope, i, array[i]);
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ export class DomHelper {
|
|||
* @param el the dom element to insert
|
||||
* @param referenceNode the parent node to insert after
|
||||
*/
|
||||
public static insertAfter(el, referenceNode) {
|
||||
public static insertAfter(el: any, referenceNode: any): void {
|
||||
referenceNode.parentNode.insertBefore(el, referenceNode.nextSibling);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,8 @@
|
|||
import { Logger, LogLevel, ConsoleListener } from '@pnp/logging';
|
||||
import {
|
||||
Logger,
|
||||
ConsoleListener,
|
||||
LogLevel
|
||||
} from "@pnp/logging";
|
||||
|
||||
import {
|
||||
ILocalStorageService,
|
||||
|
@ -11,10 +15,7 @@ import {Md5} from 'ts-md5/dist/md5';
|
|||
class LocalStorageService implements ILocalStorageService {
|
||||
public constructor() {
|
||||
// Setup the Logger
|
||||
const consoleListener = new ConsoleListener();
|
||||
Logger.subscribe(consoleListener);
|
||||
|
||||
|
||||
Logger.subscribe(ConsoleListener());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,15 +25,15 @@ class LocalStorageService implements ILocalStorageService {
|
|||
*/
|
||||
public async get(keyToken: ILocalStorageKey): Promise<any> {
|
||||
|
||||
var p = new Promise<any>(async (resolve, reject) => {
|
||||
const p = new Promise<any>((resolve, reject): void => {
|
||||
try {
|
||||
|
||||
var returnValue: any;
|
||||
let returnValue: any;
|
||||
|
||||
//get the hash of the local storage token based on value
|
||||
//var keyHash: string = md5(keyToken.keyName);
|
||||
//var keyHash: string = ObjectHash.MD5(keyToken.keyName);
|
||||
var keyHash: string | Int32Array = Md5.hashStr(JSON.stringify(keyToken.keyName));
|
||||
const keyHash: string | Int32Array = Md5.hashStr(JSON.stringify(keyToken.keyName));
|
||||
console.log("LS get: keyhash - " + keyHash);
|
||||
|
||||
|
||||
|
@ -103,13 +104,13 @@ class LocalStorageService implements ILocalStorageService {
|
|||
*/
|
||||
public async set(keyToken: ILocalStorageKey): Promise<boolean> {
|
||||
|
||||
var p = new Promise<any>(async (resolve, reject) => {
|
||||
const p = new Promise<any>((resolve, reject): void => {
|
||||
try {
|
||||
|
||||
//get the hash of the local storage token based on value
|
||||
//var keyHash: string = md5(keyToken.keyName);
|
||||
//var keyHash: string = ObjectHash.MD5(keyToken.keyName);
|
||||
var keyHash: string | Int32Array = Md5.hashStr(JSON.stringify(keyToken.keyName));
|
||||
const keyHash: string | Int32Array = Md5.hashStr(JSON.stringify(keyToken.keyName));
|
||||
console.log("LS set: keyhash - " + keyHash);
|
||||
|
||||
//create the corrrect storage key based on keyHash and possible prefix
|
||||
|
|
|
@ -21,7 +21,7 @@ import { RssXmlParserService } from '../../services/RssXm
|
|||
export class RssHttpClientDirectService implements IRssHttpClientComponentService {
|
||||
public async get(feedRequest: IRssReaderRequest): Promise<IRssReaderResponse> {
|
||||
|
||||
var p = new Promise<IRssReaderResponse>(async (resolve, reject) => {
|
||||
const p = new Promise<IRssReaderResponse>(async (resolve, reject) => {
|
||||
|
||||
let rawFeedOutput: any = null;
|
||||
let response: IRssReaderResponse = null;
|
||||
|
@ -47,7 +47,7 @@ export class RssHttpClientDirectService implements IRssHttpClientComponentServic
|
|||
RssXmlParserService.init();
|
||||
|
||||
try {
|
||||
let feedOutput = await RssXmlParserService.parse(rawFeedOutput);
|
||||
const feedOutput = await RssXmlParserService.parse(rawFeedOutput);
|
||||
|
||||
if (feedOutput) {
|
||||
response = this.convertRssFeedToRssReaderResponse(feedOutput, feedRequest.maxCount);
|
||||
|
@ -73,7 +73,7 @@ export class RssHttpClientDirectService implements IRssHttpClientComponentServic
|
|||
}
|
||||
|
||||
public convertRssFeedToRssReaderResponse(input: any, maxCount: number) : IRssReaderResponse {
|
||||
var response: IRssReaderResponse = {query: null} as IRssReaderResponse;
|
||||
const response: IRssReaderResponse = {query: null} as IRssReaderResponse;
|
||||
|
||||
if (!input) {
|
||||
return null;
|
||||
|
@ -109,7 +109,7 @@ export class RssHttpClientDirectService implements IRssHttpClientComponentServic
|
|||
} as IRssQueryResults;
|
||||
|
||||
input.items.map((item: any) => {
|
||||
let newItem: IRssResult = {} as IRssResult;
|
||||
const newItem: IRssResult = {} as IRssResult;
|
||||
|
||||
newItem.channel = {} as IRssChannel;
|
||||
newItem.channel.item = {} as IRssItem;
|
||||
|
|
|
@ -21,7 +21,7 @@ import {
|
|||
export class RssHttpClientFeed2JsonService implements IRssHttpClientComponentService {
|
||||
public async get(feedRequest: IRssReaderRequest): Promise<IRssReaderResponse> {
|
||||
|
||||
var p = new Promise<IRssReaderResponse>(async (resolve, reject) => {
|
||||
const p = new Promise<IRssReaderResponse>(async (resolve, reject) => {
|
||||
|
||||
let rawFeedOutput: any = null;
|
||||
let response: IRssReaderResponse = null;
|
||||
|
@ -29,7 +29,7 @@ export class RssHttpClientFeed2JsonService implements IRssHttpClientComponentSer
|
|||
try {
|
||||
|
||||
//Create the url to the feed2json service url per documentation at: https://feed2json.org/
|
||||
let rssUrl: string = (feedRequest.feedServiceUrl ? feedRequest.feedServiceUrl : "https://feed2json.org/convert") + "?url=" + feedRequest.url;
|
||||
const rssUrl: string = (feedRequest.feedServiceUrl ? feedRequest.feedServiceUrl : "https://www.toptal.com/developers/feed2json/convert") + "?url=" + feedRequest.url;
|
||||
|
||||
rawFeedOutput = await RssHttpClientService.getRssJson(rssUrl, feedRequest.useCorsProxy ? feedRequest.corsProxyUrl : "", feedRequest.disableCorsMode);
|
||||
|
||||
|
@ -65,7 +65,7 @@ export class RssHttpClientFeed2JsonService implements IRssHttpClientComponentSer
|
|||
}
|
||||
|
||||
public convertRssFeedToRssReaderResponse(input: any, maxCount: number) : IRssReaderResponse {
|
||||
var response: IRssReaderResponse = {query: null} as IRssReaderResponse;
|
||||
const response: IRssReaderResponse = {query: null} as IRssReaderResponse;
|
||||
|
||||
if (!input) {
|
||||
return null;
|
||||
|
@ -101,7 +101,7 @@ export class RssHttpClientFeed2JsonService implements IRssHttpClientComponentSer
|
|||
} as IRssQueryResults;
|
||||
|
||||
input.items.map((item: any) => {
|
||||
let newItem: IRssResult = {} as IRssResult;
|
||||
const newItem: IRssResult = {} as IRssResult;
|
||||
|
||||
newItem.channel = {} as IRssChannel;
|
||||
newItem.channel.item = {} as IRssItem;
|
||||
|
|
|
@ -20,7 +20,7 @@ import {
|
|||
export class RssHttpClientRss2JsonService implements IRssHttpClientComponentService {
|
||||
public async get(feedRequest: IRssReaderRequest): Promise<IRssReaderResponse> {
|
||||
|
||||
var p = new Promise<IRssReaderResponse>(async (resolve, reject) => {
|
||||
const p = new Promise<IRssReaderResponse>(async (resolve, reject) => {
|
||||
|
||||
let rawFeedOutput: any = null;
|
||||
let response: IRssReaderResponse = null;
|
||||
|
@ -28,7 +28,7 @@ export class RssHttpClientRss2JsonService implements IRssHttpClientComponentServ
|
|||
try {
|
||||
|
||||
//Create the url to the rss2json service per documentation at: https://rss2json.com/docs
|
||||
let rssUrl: string = "https://api.rss2json.com/v1/api.json?rss_url=" + encodeURIComponent(feedRequest.url)
|
||||
const rssUrl: string = "https://api.rss2json.com/v1/api.json?rss_url=" + encodeURIComponent(feedRequest.url)
|
||||
+ (feedRequest.feedServiceApiKey ? "&api_key=" + encodeURIComponent(feedRequest.feedServiceApiKey) : "")
|
||||
+ ((feedRequest.maxCount && feedRequest.feedServiceApiKey) ? "&count=" + feedRequest.maxCount : ""); //a valid API key is required to use count
|
||||
|
||||
|
@ -65,7 +65,7 @@ export class RssHttpClientRss2JsonService implements IRssHttpClientComponentServ
|
|||
}
|
||||
|
||||
public convertRssFeedToRssReaderResponse(input: any, maxCount?: number) : IRssReaderResponse {
|
||||
var response: IRssReaderResponse = {query: null} as IRssReaderResponse;
|
||||
const response: IRssReaderResponse = {query: null} as IRssReaderResponse;
|
||||
|
||||
if (!input) {
|
||||
return null;
|
||||
|
@ -101,7 +101,7 @@ export class RssHttpClientRss2JsonService implements IRssHttpClientComponentServ
|
|||
} as IRssQueryResults;
|
||||
|
||||
input.items.map((item: any) => {
|
||||
let newItem: IRssResult = {} as IRssResult;
|
||||
const newItem: IRssResult = {} as IRssResult;
|
||||
|
||||
newItem.channel = {} as IRssChannel;
|
||||
newItem.channel.item = {} as IRssItem;
|
||||
|
|
|
@ -16,7 +16,7 @@ export class RssHttpClientService {
|
|||
/*
|
||||
initialize the static class
|
||||
*/
|
||||
public static async init(context: WebPartContext) {
|
||||
public static async init(context: WebPartContext): Promise<void> {
|
||||
|
||||
//obtain the httpClient from the webpart context
|
||||
this._httpClient = await context.httpClient;
|
||||
|
@ -30,9 +30,9 @@ export class RssHttpClientService {
|
|||
|
||||
public static async getRssJson(url: string, corsProxyUrl: string, disableCors: boolean): Promise<any> {
|
||||
|
||||
var p = new Promise<string>(async (resolve, reject) => {
|
||||
const p = new Promise<string>(async (resolve, reject) => {
|
||||
|
||||
let requestHeaders = new Headers();
|
||||
const requestHeaders = new Headers();
|
||||
|
||||
//if Cors is disabled, then we must send a simple Accept type
|
||||
if (!disableCors) {
|
||||
|
@ -49,7 +49,7 @@ export class RssHttpClientService {
|
|||
mode: !disableCors ? "cors" : "no-cors"
|
||||
};
|
||||
|
||||
let query = this._httpClient.fetch(
|
||||
const query = this._httpClient.fetch(
|
||||
corsProxyUrl ? RssHttpClientService.processCorsProxyUrl(url, corsProxyUrl) : url,
|
||||
HttpClient.configurations.v1,
|
||||
requestGetOptions)
|
||||
|
@ -93,9 +93,9 @@ export class RssHttpClientService {
|
|||
*/
|
||||
public static async getRssXml(url: string, corsProxyUrl: string, disableCors: boolean): Promise<any> {
|
||||
|
||||
var p = new Promise<string>(async (resolve, reject) => {
|
||||
const p = new Promise<string>(async (resolve, reject) => {
|
||||
|
||||
let requestHeaders = new Headers();
|
||||
const requestHeaders = new Headers();
|
||||
requestHeaders.append('Accept', 'text/xml; application/xml');
|
||||
|
||||
//set up get options
|
||||
|
@ -105,7 +105,7 @@ export class RssHttpClientService {
|
|||
mode: !disableCors ? "cors" : "no-cors"
|
||||
};
|
||||
|
||||
let query = this._httpClient.fetch(
|
||||
const query = this._httpClient.fetch(
|
||||
corsProxyUrl ? RssHttpClientService.processCorsProxyUrl(url, corsProxyUrl) : url,
|
||||
HttpClient.configurations.v1,
|
||||
requestGetOptions)
|
||||
|
|
|
@ -18,9 +18,6 @@ export interface IRssReaderService {
|
|||
export class RssReaderService implements IRssReaderService {
|
||||
private static storageKeyPrefix: string = 'rssFeed';
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
/*
|
||||
given a feedRequest, determine the specific local storage keyname
|
||||
*/
|
||||
|
@ -44,15 +41,15 @@ export class RssReaderService implements IRssReaderService {
|
|||
return a resolved IRssReaderResponse or reject message
|
||||
*/
|
||||
public async getFeed(feedRequest: IRssReaderRequest): Promise<IRssReaderResponse> {
|
||||
var p = new Promise<IRssReaderResponse>(async (resolve, reject) => {
|
||||
const p = new Promise<IRssReaderResponse>(async (resolve, reject) => {
|
||||
|
||||
let localStorageService: ILocalStorageService = new LocalStorageService();
|
||||
const localStorageService: ILocalStorageService = new LocalStorageService();
|
||||
|
||||
//attempt to get local storage if needed
|
||||
if (feedRequest.useLocalStorage && feedRequest.useLocalStorageTimeout >= 0) {
|
||||
|
||||
//set up the local storage key to search in local storage for valid stored results
|
||||
let localStorageKey:ILocalStorageKey = {
|
||||
const localStorageKey:ILocalStorageKey = {
|
||||
keyName: RssReaderService.getFeedStorageKeyName(feedRequest),
|
||||
keyPrefix: RssReaderService.getFeedStorageKeyPrefix(feedRequest),
|
||||
timeOutInMinutes: feedRequest.useLocalStorageTimeout
|
||||
|
@ -61,7 +58,7 @@ export class RssReaderService implements IRssReaderService {
|
|||
try {
|
||||
|
||||
//try and get cached results from local storage
|
||||
let cachedResults: IRssReaderResponse = await localStorageService.get(localStorageKey);
|
||||
const cachedResults: IRssReaderResponse = await localStorageService.get(localStorageKey);
|
||||
|
||||
if (cachedResults) {
|
||||
|
||||
|
@ -92,16 +89,16 @@ export class RssReaderService implements IRssReaderService {
|
|||
|
||||
try {
|
||||
//set up the base rssHttpClient object
|
||||
var rssHttpClient: IRssHttpClientComponentService;
|
||||
let rssHttpClient: IRssHttpClientComponentService;
|
||||
|
||||
//set up the http client service for each particular feed service
|
||||
if (feedRequest.feedService == FeedServiceOption.Default) {
|
||||
if (feedRequest.feedService === FeedServiceOption.Default) {
|
||||
rssHttpClient = new RssHttpClientDirectService();
|
||||
}
|
||||
else if (feedRequest.feedService == FeedServiceOption.Feed2Json) {
|
||||
else if (feedRequest.feedService === FeedServiceOption.Feed2Json) {
|
||||
rssHttpClient = new RssHttpClientFeed2JsonService();
|
||||
}
|
||||
else if (feedRequest.feedService == FeedServiceOption.Rss2Json) {
|
||||
else if (feedRequest.feedService === FeedServiceOption.Rss2Json) {
|
||||
rssHttpClient = new RssHttpClientRss2JsonService();
|
||||
}
|
||||
|
||||
|
@ -126,13 +123,13 @@ export class RssReaderService implements IRssReaderService {
|
|||
|
||||
if (feedRequest.useLocalStorage && feedRequest.useLocalStorageTimeout >= 0) {
|
||||
|
||||
let localStorageKeyValue: ILocalStorageKey = {
|
||||
const localStorageKeyValue: ILocalStorageKey = {
|
||||
keyName: RssReaderService.getFeedStorageKeyName(feedRequest),
|
||||
keyPrefix: RssReaderService.getFeedStorageKeyPrefix(feedRequest),
|
||||
keyValue: response
|
||||
} as ILocalStorageKey;
|
||||
|
||||
let storedResult: any = await localStorageService.set(localStorageKeyValue);
|
||||
const storedResult: any = await localStorageService.set(localStorageKeyValue);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ export class Fields {
|
|||
'comments',
|
||||
];
|
||||
|
||||
public static mapItunesField(f) {
|
||||
public static mapItunesField(f: string) : any {
|
||||
return ['itunes:' + f, f];
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ export class RssXmlParserService {
|
|||
|
||||
private static options: any;
|
||||
|
||||
public static async init(options: any = {}) {
|
||||
public static async init(options: any = {}): Promise<void> {
|
||||
options.headers = options.headers || {};
|
||||
options.customFields = options.customFields || {};
|
||||
options.customFields.item = options.customFields.item || [];
|
||||
|
@ -29,15 +29,15 @@ export class RssXmlParserService {
|
|||
}
|
||||
|
||||
public static async parse(xmlFeed: string, options?: any): Promise<any> {
|
||||
var p = new Promise<string>(async (resolve, reject) => {
|
||||
const p = new Promise<string>(async (resolve, reject) => {
|
||||
//ensure that we have some options
|
||||
options = options ? options : {};
|
||||
|
||||
//we want the string items to not have to be an array
|
||||
var xmlParser = new Parser({explicitArray: false});
|
||||
const xmlParser = new Parser({explicitArray: false});
|
||||
|
||||
//parse the xml
|
||||
xmlParser.parseString(xmlFeed, (err, result) => {
|
||||
xmlParser.parseString(xmlFeed, (err: any, result: any) => {
|
||||
//console.log("parser called");
|
||||
//console.log(result);
|
||||
|
||||
|
@ -84,8 +84,8 @@ export class RssXmlParserService {
|
|||
return p;
|
||||
}
|
||||
|
||||
private static buildAtomFeed(xmlObj) {
|
||||
let feed: any = {items: []};
|
||||
private static buildAtomFeed(xmlObj: any): void {
|
||||
const feed: any = {items: []};
|
||||
|
||||
Utils.copyFromXML(xmlObj.feed, feed, this.options.customFields.feed);
|
||||
if (xmlObj.feed.link) {
|
||||
|
@ -104,7 +104,7 @@ export class RssXmlParserService {
|
|||
}
|
||||
|
||||
(xmlObj.feed.entry || []).forEach(entry => {
|
||||
let item:any = {};
|
||||
const item:any = {};
|
||||
Utils.copyFromXML(entry, item, this.options.customFields.item);
|
||||
|
||||
if (entry.title) {
|
||||
|
@ -146,38 +146,38 @@ export class RssXmlParserService {
|
|||
return feed;
|
||||
}
|
||||
|
||||
public static buildRSS0_9(xmlObj) {
|
||||
var channel = xmlObj.rss.channel[0];
|
||||
var items = channel.item;
|
||||
public static buildRSS0_9(xmlObj: any): void {
|
||||
const channel = xmlObj.rss.channel[0];
|
||||
const items = channel.item;
|
||||
return this.buildRSS(channel, items);
|
||||
}
|
||||
|
||||
public static buildRSS1(xmlObj) {
|
||||
public static buildRSS1(xmlObj: any): void {
|
||||
xmlObj = xmlObj['rdf:RDF'];
|
||||
let channel = xmlObj.channel[0];
|
||||
let items = xmlObj.item;
|
||||
const channel = xmlObj.channel[0];
|
||||
const items = xmlObj.item;
|
||||
return this.buildRSS(channel, items);
|
||||
}
|
||||
|
||||
public static buildRSS2(xmlObj) {
|
||||
let channel:any = Array.isArray(xmlObj.rss.channel) ? xmlObj.rss.channel[0] : xmlObj.rss.channel;
|
||||
let items = Array.isArray(channel.item) ? channel.item : [channel.item];
|
||||
let feed = this.buildRSS(channel, items);
|
||||
public static buildRSS2(xmlObj: any): void {
|
||||
const channel:any = Array.isArray(xmlObj.rss.channel) ? xmlObj.rss.channel[0] : xmlObj.rss.channel;
|
||||
const items = Array.isArray(channel.item) ? channel.item : [channel.item];
|
||||
const feed = this.buildRSS(channel, items);
|
||||
if (xmlObj.rss.$ && xmlObj.rss.$['xmlns:itunes']) {
|
||||
this.decorateItunes(feed, channel);
|
||||
}
|
||||
return feed;
|
||||
}
|
||||
|
||||
public static buildRSS(channel, items) {
|
||||
public static buildRSS(channel: any, items: any): void {
|
||||
items = items || [];
|
||||
let feed: any = {
|
||||
const feed: any = {
|
||||
items: [] as Array<any>
|
||||
};
|
||||
|
||||
//set up lists of fields and items keys
|
||||
let feedFields: any = Fields.feed.concat(this.options.customFields.feed);
|
||||
let itemFields: any = Fields.item.concat(this.options.customFields.item);
|
||||
const feedFields: any = Fields.feed.concat(this.options.customFields.feed);
|
||||
const itemFields: any = Fields.item.concat(this.options.customFields.item);
|
||||
|
||||
if (Array.isArray(channel['atom:link'])) {
|
||||
feed.feedUrl = channel['atom:link'][0].$;
|
||||
|
@ -189,7 +189,7 @@ export class RssXmlParserService {
|
|||
//if there is an image, then get additional properties
|
||||
if (channel.image && channel.image[0] && channel.image[0].url) {
|
||||
feed.image = {};
|
||||
let image = channel.image[0];
|
||||
const image = channel.image[0];
|
||||
if (image.link) feed.image.link = image.link[0];
|
||||
if (image.url) feed.image.url = image.url[0];
|
||||
if (image.title) feed.image.title = image.title[0];
|
||||
|
@ -200,7 +200,7 @@ export class RssXmlParserService {
|
|||
Utils.copyFromXML(channel, feed, feedFields);
|
||||
|
||||
items.forEach(xmlItem => {
|
||||
let item: any = {};
|
||||
const item: any = {};
|
||||
Utils.copyFromXML(xmlItem, item, itemFields);
|
||||
if (xmlItem.enclosure) {
|
||||
if (Array.isArray(xmlItem.enclosure)) {
|
||||
|
@ -239,15 +239,15 @@ export class RssXmlParserService {
|
|||
* @param {object} feed extracted
|
||||
* @param {object} channel parsed XML
|
||||
*/
|
||||
public static decorateItunes(feed, channel) {
|
||||
let items:any = channel.item || [];
|
||||
public static decorateItunes(feed: any, channel: any): void {
|
||||
const items:any = channel.item || [];
|
||||
let entry:any = {};
|
||||
|
||||
feed.itunes = {};
|
||||
|
||||
if (channel['itunes:owner']) {
|
||||
let owner:any = {},
|
||||
image;
|
||||
const owner:any = {};
|
||||
let image: string;
|
||||
|
||||
if(channel['itunes:owner'][0]['itunes:name']) {
|
||||
owner.name = channel['itunes:owner'][0]['itunes:name'][0];
|
||||
|
@ -256,7 +256,7 @@ export class RssXmlParserService {
|
|||
owner.email = channel['itunes:owner'][0]['itunes:email'][0];
|
||||
}
|
||||
if(channel['itunes:image']) {
|
||||
let hasImageHref = (channel['itunes:image'][0] &&
|
||||
const hasImageHref = (channel['itunes:image'][0] &&
|
||||
channel['itunes:image'][0].$ &&
|
||||
channel['itunes:image'][0].$.href);
|
||||
image = hasImageHref ? channel['itunes:image'][0].$.href : null;
|
||||
|
@ -274,15 +274,15 @@ export class RssXmlParserService {
|
|||
entry = feed.items[index];
|
||||
entry.itunes = {};
|
||||
Utils.copyFromXML(item, entry.itunes, Fields.podcastItem);
|
||||
let image = item['itunes:image'];
|
||||
const image = item['itunes:image'];
|
||||
if (image && image[0] && image[0].$ && image[0].$.href) {
|
||||
entry.itunes.image = image[0].$.href;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static setISODate(item) {
|
||||
let date = item.pubDate || item.date;
|
||||
public static setISODate(item: any): void {
|
||||
const date = item.pubDate || item.date;
|
||||
if (date) {
|
||||
try {
|
||||
item.isoDate = new Date(date.trim()).toISOString();
|
||||
|
|
|
@ -3,19 +3,17 @@
|
|||
import { Builder } from 'xml2js';
|
||||
|
||||
export class Utils {
|
||||
public static async init() {
|
||||
}
|
||||
|
||||
public static stripHtml(str) {
|
||||
public static stripHtml(str: string): string {
|
||||
return str.replace(/<(?:.|\n)*?>/gm, '');
|
||||
}
|
||||
|
||||
public static getSnippet(str) {
|
||||
public static getSnippet(str: string): string {
|
||||
//return entities.decode(this.stripHtml(str)).trim();
|
||||
return this.stripHtml(str).trim();
|
||||
}
|
||||
|
||||
public static getLink (links, rel, fallbackIdx) {
|
||||
public static getLink (links: any, rel: string, fallbackIdx: number): string {
|
||||
if (!links) return;
|
||||
for (let i = 0; i < links.length; ++i) {
|
||||
if (links[i].$.rel === rel) {
|
||||
|
@ -28,7 +26,7 @@ export class Utils {
|
|||
}
|
||||
}
|
||||
|
||||
public static copyFromXML(xml, dest, fields) {
|
||||
public static copyFromXML(xml: any, dest: any, fields: any): void {
|
||||
fields.forEach((f) => {
|
||||
let from = f;
|
||||
let to = f;
|
||||
|
@ -47,12 +45,12 @@ export class Utils {
|
|||
});
|
||||
}
|
||||
|
||||
public static getContent(content) {
|
||||
public static getContent(content: any): any {
|
||||
if (typeof content._ === 'string') {
|
||||
return content._;
|
||||
}
|
||||
else if (typeof content === 'object') {
|
||||
let builder = new Builder({headless: true, explicitRoot: true, rootName: 'div', renderOpts: {pretty: false}});
|
||||
const builder = new Builder({headless: true, explicitRoot: true, rootName: 'div', renderOpts: {pretty: false}});
|
||||
return builder.buildObject(content);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
.hoverIcon {
|
||||
@import '~@fluentui/react/dist/sass/References.scss';
|
||||
|
||||
.hoverIcon {
|
||||
color: '[theme:themeDarker, default:#0078d7]';
|
||||
}
|
||||
|
|
|
@ -2,22 +2,22 @@ import { html } from 'common-tags';
|
|||
import * as Handlebars from 'handlebars';
|
||||
import * as HandlebarsHelpers from 'handlebars-helpers';
|
||||
|
||||
import 'core-js/modules/es7.array.includes.js';
|
||||
import 'core-js/modules/es6.string.includes.js';
|
||||
import 'core-js/modules/es6.number.is-nan.js';
|
||||
// import 'core-js/modules/es7.array.includes.js';
|
||||
// import 'core-js/modules/es6.string.includes.js';
|
||||
// import 'core-js/modules/es6.number.is-nan.js';
|
||||
|
||||
import templateStyles from './BaseTemplateService.module.scss';
|
||||
|
||||
abstract class BaseTemplateService {
|
||||
private _helper = null;
|
||||
public CurrentLocale = "en";
|
||||
private _helper: any = null;
|
||||
public CurrentLocale: string = "en";
|
||||
|
||||
constructor() {
|
||||
// Registers all helpers
|
||||
this.registerTemplateServices();
|
||||
}
|
||||
|
||||
private async LoadHandlebarsHelpers() {
|
||||
private async LoadHandlebarsHelpers(): Promise<void> {
|
||||
this._helper = HandlebarsHelpers({
|
||||
handlebars: Handlebars
|
||||
});
|
||||
|
@ -92,11 +92,11 @@ abstract class BaseTemplateService {
|
|||
/**
|
||||
* Registers useful helpers for search results templates
|
||||
*/
|
||||
private registerTemplateServices() {
|
||||
private registerTemplateServices(): void {
|
||||
// Return the URL or Title part of a URL automatic managed property
|
||||
// <p>{{getUrlField MyLinkOWSURLH "Title"}}</p>
|
||||
Handlebars.registerHelper("getUrlField", (urlField: string, value: "URL" | "Title") => {
|
||||
let separatorPos = urlField.indexOf(",");
|
||||
const separatorPos = urlField.indexOf(",");
|
||||
if (value === "URL") {
|
||||
return urlField.substr(0, separatorPos);
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ abstract class BaseTemplateService {
|
|||
// <p>{{getDate Created "LL"}}</p>
|
||||
Handlebars.registerHelper("getDate", (date: string, format: string) => {
|
||||
try {
|
||||
let d = this._helper.moment(date, format, { lang: this.CurrentLocale, datejs: false });
|
||||
const d = this._helper.moment(date, format, { lang: this.CurrentLocale, datejs: false });
|
||||
return d;
|
||||
} catch (error) {
|
||||
return;
|
||||
|
@ -123,9 +123,9 @@ abstract class BaseTemplateService {
|
|||
|
||||
//remove Html tags if necessary
|
||||
if (ignoreHtml) {
|
||||
let div = document.createElement("div");
|
||||
const div = document.createElement("div");
|
||||
div.innerHTML = inputString;
|
||||
inputString = (div.textContent || div.innerText || "").replace(/\ /ig, "").trim();
|
||||
inputString = (div.textContent || div.innerText || "").replace(/ /ig, "").trim();
|
||||
}
|
||||
|
||||
if (inputString.length < maxLength) {
|
||||
|
@ -298,15 +298,16 @@ abstract class BaseTemplateService {
|
|||
for (let i = 0; i < handlebarFunctionNames.length; i++) {
|
||||
const element = handlebarFunctionNames[i];
|
||||
|
||||
let regEx = new RegExp("{{#?.*?" + element + ".*?}}", "m");
|
||||
const regExString: string = "{{#?.*?" + element + ".*?}}";
|
||||
const regEx = new RegExp(regExString, "m");
|
||||
if (regEx.test(templateContent)) {
|
||||
await this.LoadHandlebarsHelpers();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let template = Handlebars.compile(templateContent);
|
||||
let result = template(templateContext);
|
||||
const template = Handlebars.compile(templateContent);
|
||||
const result = template(templateContext);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -317,9 +318,9 @@ abstract class BaseTemplateService {
|
|||
*/
|
||||
public static isValidTemplateFile(filePath: string): boolean {
|
||||
|
||||
let path = filePath.toLowerCase().trim();
|
||||
let pathExtension = path.substring(path.lastIndexOf('.'));
|
||||
return (pathExtension == '.htm' || pathExtension == '.html');
|
||||
const path = filePath.toLowerCase().trim();
|
||||
const pathExtension = path.substring(path.lastIndexOf('.'));
|
||||
return (pathExtension === '.htm' || pathExtension === '.html');
|
||||
}
|
||||
|
||||
public abstract getFileContent(fileUrl: string): Promise<string>;
|
||||
|
|
|
@ -42,7 +42,7 @@ class TemplateService extends BaseTemplateService {
|
|||
if(response.ok) {
|
||||
|
||||
if(response.url.indexOf('AccessDenied.aspx') > -1){
|
||||
throw 'Access Denied';
|
||||
throw new Error('Access Denied');
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
|
@ -229,7 +229,7 @@ export default class RssReaderWebPart extends BaseClientSideWebPart<IRssReaderWe
|
|||
};
|
||||
}
|
||||
|
||||
protected async onPropertyPaneFieldChanged(propertyPath: string) {
|
||||
protected async onPropertyPaneFieldChanged(propertyPath: string): Promise<void> {
|
||||
|
||||
if (propertyPath === 'selectedLayout') {
|
||||
|
||||
|
@ -257,7 +257,7 @@ export default class RssReaderWebPart extends BaseClientSideWebPart<IRssReaderWe
|
|||
/**
|
||||
* Initializes the Web Part required properties if there are not present in the manifest (i.e. during an update scenario)
|
||||
*/
|
||||
private initializeRequiredProperties() {
|
||||
private initializeRequiredProperties(): void {
|
||||
|
||||
this.properties.useCorsProxy = this.properties.useCorsProxy ? true : false;
|
||||
this.properties.corsProxyUrl = this.properties.corsProxyUrl ? this.properties.corsProxyUrl : "";
|
||||
|
@ -332,7 +332,7 @@ export default class RssReaderWebPart extends BaseClientSideWebPart<IRssReaderWe
|
|||
|
||||
|
||||
// Sets up styling fields
|
||||
let feedFields: IPropertyPaneField<any>[] = [
|
||||
const feedFields: IPropertyPaneField<any>[] = [
|
||||
PropertyPaneTextField('feedUrl', {
|
||||
label: strings.FeedUrlLabel
|
||||
}),
|
||||
|
@ -342,14 +342,14 @@ export default class RssReaderWebPart extends BaseClientSideWebPart<IRssReaderWe
|
|||
})
|
||||
];
|
||||
|
||||
if (this.properties.feedService == FeedServiceOption.Feed2Json) {
|
||||
if (this.properties.feedService === FeedServiceOption.Feed2Json) {
|
||||
feedFields.push(PropertyPaneTextField('feedServiceUrl', {
|
||||
label: strings.FeedServiceUrlLabel,
|
||||
description: strings.FeedServiceUrlDescription
|
||||
}));
|
||||
}
|
||||
|
||||
if (this.properties.feedService == FeedServiceOption.Rss2Json) {
|
||||
if (this.properties.feedService === FeedServiceOption.Rss2Json) {
|
||||
feedFields.push(PropertyPaneTextField('feedServiceApiKey', {
|
||||
label: strings.FeedServiceApiKeyLabel,
|
||||
description: strings.FeedServiceApiKeyDescription
|
||||
|
@ -404,7 +404,7 @@ export default class RssReaderWebPart extends BaseClientSideWebPart<IRssReaderWe
|
|||
*/
|
||||
private _getCorsSettingsFields(): IPropertyPaneField<any>[] {
|
||||
// Sets up styling fields
|
||||
let feedFields: IPropertyPaneField<any>[] = [
|
||||
const feedFields: IPropertyPaneField<any>[] = [
|
||||
PropertyPaneToggle('useCorsProxy', {
|
||||
label: strings.UseCorsProxyLabel,
|
||||
checked: this.properties.useCorsProxy,
|
||||
|
@ -457,7 +457,7 @@ export default class RssReaderWebPart extends BaseClientSideWebPart<IRssReaderWe
|
|||
const canEditTemplate = this.properties.externalTemplateUrl && this.properties.selectedLayout === FeedLayoutOption.Custom ? false : true;
|
||||
|
||||
// Sets up styling fields
|
||||
let layoutFields: IPropertyPaneField<any>[] = [
|
||||
const layoutFields: IPropertyPaneField<any>[] = [
|
||||
PropertyPaneChoiceGroup('selectedLayout', {
|
||||
label: strings.SelectedLayoutLabel,
|
||||
options: layoutOptions
|
||||
|
@ -572,7 +572,7 @@ export default class RssReaderWebPart extends BaseClientSideWebPart<IRssReaderWe
|
|||
* from https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-search-refiners
|
||||
* @param value the template file URL value
|
||||
*/
|
||||
private async _onTemplateUrlChange(value: string): Promise<String> {
|
||||
private async _onTemplateUrlChange(value: string): Promise<string> {
|
||||
|
||||
try {
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
:global {
|
||||
.template_root {
|
||||
/*include fabric here to surpress warnings*/
|
||||
@import '~office-ui-fabric-react/dist/sass/References.scss';
|
||||
@import '~@fluentui/react/dist/sass/References.scss';
|
||||
|
||||
.template_rss_tileList {
|
||||
.singleCard {
|
||||
|
|
|
@ -21,7 +21,7 @@ export default class RssResultsTemplate extends React.Component<IRssResultsTempl
|
|||
};
|
||||
}
|
||||
|
||||
public render() {
|
||||
public render(): any {
|
||||
const objectNode: any = document.querySelector("object[data='about:blank']");
|
||||
|
||||
if (objectNode) {
|
||||
|
@ -33,21 +33,22 @@ export default class RssResultsTemplate extends React.Component<IRssResultsTempl
|
|||
|
||||
}
|
||||
|
||||
public componentDidMount() {
|
||||
public componentDidMount(): void {
|
||||
|
||||
this._updateTemplate(this.props);
|
||||
|
||||
}
|
||||
|
||||
public componentWillReceiveProps(nextProps: IRssResultsTemplateProps) {
|
||||
// public componentWillReceiveProps(nextProps: IRssResultsTemplateProps): void {
|
||||
public componentDidUpdate(prevProps: any): void {
|
||||
|
||||
this._updateTemplate(nextProps);
|
||||
this._updateTemplate(this.props);
|
||||
|
||||
}
|
||||
|
||||
private async _updateTemplate(props: IRssResultsTemplateProps): Promise<void> {
|
||||
|
||||
let templateContent = props.templateContent;
|
||||
const templateContent = props.templateContent;
|
||||
|
||||
// Process the Handlebars template
|
||||
const template = await this.props.templateService.processTemplate(props.templateContext, templateContent);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@import '~office-ui-fabric-react/dist/sass/References.scss';
|
||||
@import '~@fluentui/react/dist/sass/References.scss';
|
||||
|
||||
.rssReader {
|
||||
.rssReaderHeader {
|
||||
|
|
|
@ -3,12 +3,11 @@ import Moment from 'react-moment';
|
|||
|
||||
import { WebPartTitle } from '@pnp/spfx-controls-react/lib/WebPartTitle';
|
||||
import { Placeholder } from '@pnp/spfx-controls-react/lib/Placeholder';
|
||||
import { List } from 'office-ui-fabric-react/lib/List';
|
||||
import { Link } from 'office-ui-fabric-react/lib/Link';
|
||||
import { Label } from 'office-ui-fabric-react/lib/Label';
|
||||
import { Icon } from 'office-ui-fabric-react/lib/Icon';
|
||||
import { Spinner, SpinnerSize } from 'office-ui-fabric-react/lib/Spinner';
|
||||
import { autobind } from 'office-ui-fabric-react/lib/Utilities';
|
||||
import { List } from '@fluentui/react/lib/List';
|
||||
import { Link } from '@fluentui/react/lib/Link';
|
||||
import { Label } from '@fluentui/react/lib/Label';
|
||||
import { Icon } from '@fluentui/react/lib/Icon';
|
||||
import { Spinner, SpinnerSize } from '@fluentui/react/lib/Spinner';
|
||||
|
||||
import * as strings from 'RssReaderWebPartStrings';
|
||||
import styles from './RssReader.module.scss';
|
||||
|
@ -30,6 +29,7 @@ export default class RssReader extends React.Component<IRssReaderProps, IRssRead
|
|||
|
||||
private viewAllLinkLabel: string = strings.DefaultFeedViewAllLinkLabel;
|
||||
private feedLoadingLabel: string = strings.DefaultFeedLoadingLabel;
|
||||
private themeVariant: IReadonlyTheme;
|
||||
|
||||
constructor(props:IRssReaderProps) {
|
||||
super(props);
|
||||
|
@ -48,21 +48,22 @@ export default class RssReader extends React.Component<IRssReaderProps, IRssRead
|
|||
rssFeedError: ''
|
||||
};
|
||||
|
||||
this.themeVariant = this.props.themeVariant;
|
||||
|
||||
//load the rss feed
|
||||
this.loadRssFeed();
|
||||
}
|
||||
|
||||
public render(): React.ReactElement<IRssReaderProps> {
|
||||
const { semanticColors }: IReadonlyTheme = this.props.themeVariant;
|
||||
return (
|
||||
<div className={ styles.rssReader } style={{backgroundColor: semanticColors.bodyBackground}}>
|
||||
<div className={ styles.rssReader } style={{backgroundColor: this.themeVariant.semanticColors.bodyBackground}}>
|
||||
<div className={styles.rssReaderHeader}>
|
||||
<WebPartTitle displayMode={this.props.displayMode}
|
||||
title={this.props.title}
|
||||
updateProperty={this.props.updateProperty}
|
||||
themeVariant={this.props.themeVariant}
|
||||
moreLink={this.state.rssFeedReady && this.state.rssFeed && this.props.feedViewAllLink && this.props.feedViewAllLink.length > 0 && (
|
||||
<Link style={{color: semanticColors.link}} href={this.props.feedViewAllLink}>{this.viewAllLinkLabel}</Link>
|
||||
<Link style={{color: this.themeVariant.semanticColors.link}} href={this.props.feedViewAllLink}>{this.viewAllLinkLabel}</Link>
|
||||
)}/>
|
||||
</div>
|
||||
|
||||
|
@ -93,16 +94,16 @@ export default class RssReader extends React.Component<IRssReaderProps, IRssRead
|
|||
<div>
|
||||
{this.state.rssFeed ? (
|
||||
<div>
|
||||
{this.props.selectedLayout == FeedLayoutOption.Default && (
|
||||
{this.props.selectedLayout === FeedLayoutOption.Default && (
|
||||
<List
|
||||
className={styles.rssReaderList + (this.props.backgroundColor ? " " + styles.rssReaderListPadding : "")}
|
||||
items={this.state.rssFeed.query.results.rss}
|
||||
onRenderCell={this._onRenderListRow}
|
||||
style={this.props.useThemeBackgroundColor ? {backgroundColor: semanticColors.bodyBackground} : this.props.backgroundColor ? {backgroundColor: this.props.backgroundColor} : {}}
|
||||
style={this.props.useThemeBackgroundColor ? {backgroundColor: this.themeVariant.semanticColors.bodyBackground} : this.props.backgroundColor ? {backgroundColor: this.props.backgroundColor} : {}}
|
||||
/>
|
||||
)}
|
||||
|
||||
{this.props.selectedLayout == FeedLayoutOption.Custom && (
|
||||
{this.props.selectedLayout === FeedLayoutOption.Custom && (
|
||||
<div>
|
||||
<RssResultsTemplate
|
||||
templateService={this.props.templateService}
|
||||
|
@ -132,52 +133,51 @@ export default class RssReader extends React.Component<IRssReaderProps, IRssRead
|
|||
);
|
||||
}
|
||||
|
||||
public componentDidUpdate(nextProps): void {
|
||||
public componentDidUpdate(prevProps: any): void {
|
||||
//if specific resources change, we need to reload feed
|
||||
if(this.props.feedUrl != nextProps.feedUrl ||
|
||||
this.props.feedService != nextProps.feedService ||
|
||||
this.props.feedServiceApiKey != nextProps.feedServiceApiKey ||
|
||||
this.props.feedServiceUrl != nextProps.feedServiceUrl ||
|
||||
if(this.props.feedUrl !== prevProps.feedUrl ||
|
||||
this.props.feedService !== prevProps.feedService ||
|
||||
this.props.feedServiceApiKey !== prevProps.feedServiceApiKey ||
|
||||
this.props.feedServiceUrl !== prevProps.feedServiceUrl ||
|
||||
|
||||
this.props.useCorsProxy != nextProps.useCorsProxy ||
|
||||
this.props.corsProxyUrl != nextProps.corsProxyUrl ||
|
||||
this.props.disableCorsMode != nextProps.disableCorsMode ||
|
||||
this.props.useCorsProxy !== prevProps.useCorsProxy ||
|
||||
this.props.corsProxyUrl !== prevProps.corsProxyUrl ||
|
||||
this.props.disableCorsMode !== prevProps.disableCorsMode ||
|
||||
|
||||
this.props.maxCount != nextProps.maxCount ||
|
||||
this.props.maxCount !== prevProps.maxCount ||
|
||||
|
||||
this.props.selectedLayout != nextProps.selectedLayout ||
|
||||
this.props.externalTemplateUrl != nextProps.externalTemplateUrl ||
|
||||
this.props.inlineTemplateText != nextProps.inlineTemplateText ||
|
||||
this.props.selectedLayout !== prevProps.selectedLayout ||
|
||||
this.props.externalTemplateUrl !== prevProps.externalTemplateUrl ||
|
||||
this.props.inlineTemplateText !== prevProps.inlineTemplateText ||
|
||||
|
||||
this.props.showDesc != nextProps.showDesc ||
|
||||
this.props.showPubDate != nextProps.showPubDate ||
|
||||
this.props.descCharacterLimit != nextProps.descCharacterLimit ||
|
||||
this.props.titleLinkTarget != nextProps.titleLinkTarget ||
|
||||
this.props.dateFormat != nextProps.dateFormat ||
|
||||
this.props.backgroundColor != nextProps.backgroundColor ||
|
||||
this.props.useThemeBackgroundColor != nextProps.useThemeBackgroundColor ||
|
||||
this.props.useThemeFontColor != nextProps.useThemeFontColor ||
|
||||
this.props.fontColor != nextProps.fontColor ||
|
||||
this.props.themeVariant != nextProps.themeVariant
|
||||
this.props.showDesc !== prevProps.showDesc ||
|
||||
this.props.showPubDate !== prevProps.showPubDate ||
|
||||
this.props.descCharacterLimit !== prevProps.descCharacterLimit ||
|
||||
this.props.titleLinkTarget !== prevProps.titleLinkTarget ||
|
||||
this.props.dateFormat !== prevProps.dateFormat ||
|
||||
this.props.backgroundColor !== prevProps.backgroundColor ||
|
||||
this.props.useThemeBackgroundColor !== prevProps.useThemeBackgroundColor ||
|
||||
this.props.useThemeFontColor !== prevProps.useThemeFontColor ||
|
||||
this.props.fontColor !== prevProps.fontColor ||
|
||||
this.props.themeVariant !== prevProps.themeVariant
|
||||
) {
|
||||
this.loadRssFeed();
|
||||
}
|
||||
|
||||
if(this.props.feedViewAllLinkLabel != nextProps.feedViewAllLinkLabel) {
|
||||
if(this.props.feedViewAllLinkLabel !== prevProps.feedViewAllLinkLabel) {
|
||||
this.viewAllLinkLabel = this.props.feedViewAllLinkLabel;
|
||||
}
|
||||
if(this.props.feedLoadingLabel != nextProps.feedLoadingLabel) {
|
||||
if(this.props.feedLoadingLabel !== prevProps.feedLoadingLabel) {
|
||||
this.feedLoadingLabel = this.props.feedLoadingLabel;
|
||||
}
|
||||
}
|
||||
|
||||
@autobind
|
||||
private _onConfigure() {
|
||||
private _onConfigure = (): void => {
|
||||
this.props.propertyPane.open();
|
||||
}
|
||||
|
||||
private decodeHtml(html) {
|
||||
var txt = document.createElement("textarea");
|
||||
private decodeHtml = (html: string): string => {
|
||||
const txt = document.createElement("textarea");
|
||||
txt.innerHTML = html;
|
||||
return txt.value;
|
||||
}
|
||||
|
@ -185,16 +185,14 @@ export default class RssReader extends React.Component<IRssReaderProps, IRssRead
|
|||
/*
|
||||
_onReaderListRow used by Default feed Layout
|
||||
*/
|
||||
@autobind
|
||||
private _onRenderListRow(item: IRssResult, index: number | undefined): JSX.Element {
|
||||
let thisItem: IRssItem = item.channel.item;
|
||||
private _onRenderListRow = (item: IRssResult, index: number | undefined): JSX.Element => {
|
||||
const thisItem: IRssItem = item.channel.item;
|
||||
|
||||
//may need to strip html from description
|
||||
let displayDesc: string = thisItem.description;
|
||||
let div = document.createElement("div");
|
||||
const div = document.createElement("div");
|
||||
div.innerHTML = displayDesc;
|
||||
displayDesc = (div.textContent || div.innerText || "").replace(/\ /ig, "").trim();
|
||||
const { semanticColors }: IReadonlyTheme = this.props.themeVariant;
|
||||
displayDesc = (div.textContent || div.innerText || "").replace(/ /ig, "").trim();
|
||||
|
||||
return (
|
||||
<div className={styles.rssReaderListItem} data-is-focusable={true}>
|
||||
|
@ -202,7 +200,7 @@ export default class RssReader extends React.Component<IRssReaderProps, IRssRead
|
|||
<Link
|
||||
href={thisItem.link}
|
||||
target={this.props.titleLinkTarget ? this.props.titleLinkTarget : "_self"}
|
||||
style={this.props.useThemeFontColor ? {color: semanticColors.link} : this.props.fontColor ? {color: this.props.fontColor} : {}}
|
||||
style={this.props.useThemeFontColor ? {color: this.themeVariant.semanticColors.link} : this.props.fontColor ? {color: this.props.fontColor} : {}}
|
||||
>
|
||||
{this.decodeHtml(thisItem.title)}
|
||||
</Link>
|
||||
|
@ -210,7 +208,7 @@ export default class RssReader extends React.Component<IRssReaderProps, IRssRead
|
|||
</div>
|
||||
|
||||
{this.props.showPubDate && (
|
||||
<div className={styles.itemDate} style={{color: semanticColors.bodySubtext}}>
|
||||
<div className={styles.itemDate} style={{color: this.themeVariant.semanticColors.bodySubtext}}>
|
||||
{this.props.dateFormat && this.props.dateFormat.length > 0 ? (
|
||||
<Moment
|
||||
format={this.props.dateFormat}
|
||||
|
@ -223,7 +221,7 @@ export default class RssReader extends React.Component<IRssReaderProps, IRssRead
|
|||
)}
|
||||
|
||||
{this.props.showDesc && (
|
||||
<div className={styles.itemContent} style={{color: semanticColors.bodyText}}>
|
||||
<div className={styles.itemContent} style={{color: this.themeVariant.semanticColors.bodyText}}>
|
||||
{this.props.descCharacterLimit && (displayDesc.length > this.props.descCharacterLimit) ? (
|
||||
<div>
|
||||
{displayDesc.substring(0, this.props.descCharacterLimit) + '...'}
|
||||
|
@ -244,18 +242,17 @@ export default class RssReader extends React.Component<IRssReaderProps, IRssRead
|
|||
/*
|
||||
load a rss feed based on properties
|
||||
*/
|
||||
private async loadRssFeed(): Promise<void> {
|
||||
|
||||
private loadRssFeed = async (): Promise<void> => {
|
||||
//require a feed url
|
||||
if (this.props.feedUrl && this.props.feedUrl.length > 0) {
|
||||
|
||||
//always reset set
|
||||
this.setState({rssFeedReady: false, rssFeed: null});
|
||||
|
||||
let rssReaderService: IRssReaderService = new RssReaderService();
|
||||
const rssReaderService: IRssReaderService = new RssReaderService();
|
||||
|
||||
//build the query
|
||||
let feedRequest: IRssReaderRequest = {} as IRssReaderRequest;
|
||||
const feedRequest: IRssReaderRequest = {} as IRssReaderRequest;
|
||||
feedRequest.url = this.props.feedUrl;
|
||||
feedRequest.feedService = this.props.feedService;
|
||||
feedRequest.feedServiceApiKey = this.props.feedServiceApiKey;
|
||||
|
@ -279,7 +276,7 @@ export default class RssReader extends React.Component<IRssReaderProps, IRssRead
|
|||
|
||||
try {
|
||||
//attempt to get feed
|
||||
var rssFeed: IRssReaderResponse = await rssReaderService.getFeed(feedRequest);
|
||||
const rssFeed: IRssReaderResponse = await rssReaderService.getFeed(feedRequest);
|
||||
|
||||
if (rssFeed && rssFeed.query && rssFeed.query.results) {
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"extends": "./node_modules/@microsoft/rush-stack-compiler-4.7/includes/tsconfig-web.json",
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
|
@ -13,27 +14,23 @@
|
|||
"inlineSources": false,
|
||||
"strictNullChecks": false,
|
||||
"noUnusedLocals": false,
|
||||
"noImplicitAny": false,
|
||||
"typeRoots": [
|
||||
"./node_modules/@types",
|
||||
"./node_modules/@microsoft"
|
||||
],
|
||||
"types": [
|
||||
"es6-promise",
|
||||
"webpack-env"
|
||||
],
|
||||
"lib": [
|
||||
"es5",
|
||||
"dom",
|
||||
"es2015.collection"
|
||||
"es2015.collection",
|
||||
"es2015.promise"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.tsx"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"lib"
|
||||
],
|
||||
"extends": "./node_modules/@microsoft/rush-stack-compiler-3.3/includes/tsconfig-web.json"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"extends": "./node_modules/@microsoft/sp-tslint-rules/base-tslint.json"
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
{
|
||||
"extends": "@microsoft/sp-tslint-rules/base-tslint.json",
|
||||
"rules": {
|
||||
"class-name": false,
|
||||
"export-name": false,
|
||||
"forin": false,
|
||||
"label-position": false,
|
||||
"member-access": true,
|
||||
"no-arg": false,
|
||||
"no-console": false,
|
||||
"no-construct": false,
|
||||
"no-duplicate-variable": true,
|
||||
"no-eval": false,
|
||||
"no-function-expression": true,
|
||||
"no-internal-module": true,
|
||||
"no-shadowed-variable": true,
|
||||
"no-switch-case-fall-through": true,
|
||||
"no-unnecessary-semicolons": true,
|
||||
"no-unused-expression": true,
|
||||
"no-use-before-declare": true,
|
||||
"no-with-statement": true,
|
||||
"semicolon": true,
|
||||
"trailing-comma": false,
|
||||
"typedef": false,
|
||||
"typedef-whitespace": false,
|
||||
"use-named-parameter": true,
|
||||
"variable-name": false,
|
||||
"whitespace": false
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue